ExpediaGroup / graphql-kotlin

Libraries for running GraphQL in Kotlin

Home Page:https://opensource.expediagroup.com/graphql-kotlin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GetCurrentFutures ArrayIndexOutOfBoundsException issue

younseunghyun opened this issue · comments

Library Version
6.3.4

Describe the bug
Sometime when batch query exexcuted following error are occurred

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 565 out of bounds for length 565
	at java.base/java.util.HashMap.valuesToArray(HashMap.java:973)
	at java.base/java.util.HashMap$Values.toArray(HashMap.java:1050)
	at java.base/java.util.ArrayList.addAll(ArrayList.java:670)
	at kotlin.collections.CollectionsKt__MutableCollectionsKt.addAll(MutableCollections.kt:116)
	at kotlin.collections.CollectionsKt__IterablesKt.flatten(Iterables.kt:49)
	at com.expediagroup.graphql.dataloader.KotlinDataLoaderRegistry.getCurrentFutures(KotlinDataLoaderRegistry.kt:64)

To Reproduce
Hard to reproduce.
Condition

  1. Batch Query
  2. Large amount of entries

Expected behavior
getCurrentFutures have to be thread safe.
may be avoid to use flatten

probably related to
#1819

taking a look

@samuelAndalon Yes it looks same.
Is there are any suggestion way to handle this issue?

Should I have to implement cacheMap with thread-safe hashmap?

gonna look into this today, it is a synchronization issue, will make it thread safe

@samuelAndalon Thx
I will test and let you know

@samuelAndalon
This patch reduce the error frequency lower.
But the same error is occured.
I make a PR #1843 for this issue.