Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException occurred when i was serializing data from redis with quarkus redis extension #42131

Closed
Awen92 opened this issue Jul 25, 2024 · 6 comments · Fixed by #42142
Labels
area/redis kind/bug Something isn't working
Milestone

Comments

@Awen92
Copy link

Awen92 commented Jul 25, 2024

Describe the bug

As the title, when i was serializing data from redis, i got an excetion, i found that there were sth wrong with Marshaller while JDK compiles the code.

Here is the sourece code of Marshaller

final <F, V> Map<F, V> decodeAsOrderedMap(Response response, Type typeOfValue, F[] fields) {
        Iterator<Response> iterator = response.iterator();
        Map<F, V> map = new LinkedHashMap<>();
        for (F field : fields) {
            Response v = iterator.next();
            map.put(field, decode(typeOfValue, v));
        }
        return map;
    }

The JDK compiles code as

final <F, V> Map<F, V> decodeAsOrderedMap(Response response, Class<V> typeOfValue, F[] fields) {
        Iterator<Response> iterator = response.iterator();
        Map<F, V> map = new LinkedHashMap();
        Object[] var6 = fields;
        int var7 = fields.length;

        for(int var8 = 0; var8 < var7; ++var8) {
            F field = var6[var8];
            Response v = (Response)iterator.next();
            map.put(field, this.decode(typeOfValue, v));
        }

        return map;
    }

Here is my test code

HashCommands<String, String, String> infoHashCommands = redisDs.hash(String.class, String.class, String.class);
        infoHashCommands.hmget("", code, code2);

if the code parameter is null,it will caused ArrayIndexOutOfBoundsException
image

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@Awen92 Awen92 added the kind/bug Something isn't working label Jul 25, 2024
Copy link

quarkus-bot bot commented Jul 25, 2024

/cc @Ladicek (redis), @cescoffier (redis), @machi1990 (redis)

@cescoffier
Copy link
Member

Do you have some code reproducing this issue?

Also, check your redis server version.

@cescoffier cescoffier added the triage/needs-reproducer We are waiting for a reproducer. label Jul 25, 2024
@Awen92
Copy link
Author

Awen92 commented Jul 25, 2024

Do you have some code reproducing this issue?

Also, check your redis server version.

Here was my test code

HashCommands<String, String, String> infoHashCommands = redisDs.hash(String.class, String.class, String.class);
infoHashCommands.hmget("", code, code2);

Pass the code parameter as null object, you can reproduce this issue

@cescoffier
Copy link
Member

Ah ok, you pass 'null'. I don't believe it should be possible (I will check). Anyway, the error message is incorrect.

@cescoffier
Copy link
Member

So as indicated on https://redis.io/docs/latest/commands/hmget/, fields cannot contain null values. I will update the code to check for that and throw a more accurate error message.

@cescoffier
Copy link
Member

Opened #42142 to improve the error message.

@quarkus-bot quarkus-bot bot added this to the 3.14 - main milestone Jul 25, 2024
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redis kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants