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

Index 12 out of bounds for length 12 #66

Open
janyyy opened this issue Jun 25, 2024 · 1 comment
Open

Index 12 out of bounds for length 12 #66

janyyy opened this issue Jun 25, 2024 · 1 comment

Comments

@janyyy
Copy link

janyyy commented Jun 25, 2024

ERROR_INFO

com.sengi.exception.ThrowableMapper [ThrowableMapper.java : 25] java.lang.IndexOutOfBoundsException: Index 12 out of bounds for length 12
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.base/java.util.Objects.checkIndex(Objects.java:359)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at io.quarkus.eureka.client.loadBalancer.RoundRobin.getHomeUrl(RoundRobin.java:57)
at io.quarkus.eureka.client.EurekaClient.app(EurekaClient.java:38)
at com.sengi.rest.RedisRestClientService.hGetAll(RedisRestClientService.java:60)
at com.sengi.rest.RedisRestClientService_ClientProxy.hGetAll(Unknown Source)
at com.sengi.service.impl.AuthServiceImpl.checkAuth(AuthServiceImpl.java:40)
at com.sengi.service.impl.AuthServiceImpl_ClientProxy.checkAuth(Unknown Source)
at com.sengi.resource.TrackingSearchResource.customerTrackingSearch(TrackingSearchResource.java:49)
at jdk.internal.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:564)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)

ERROR_CODE

public Optional getHomeUrl(String appId) {
String target = null;
try {
List urlList = cache.get(appId);
if (!urlList.isEmpty()) {
if (position.intValue() > urlList.size() - 1) {
position.set(0);
}
target = urlList.get(position.getAndIncrement());
logger.info("Target from RoundRobin LB is: " + target);
}
} catch (ExecutionException e) {
e.printStackTrace();
}
return Optional.ofNullable(target);
}

FIXED_CODE

public Optional getHomeUrl(String appId) {
String target = null;
try {
List urlList = cache.get(appId);
if (!urlList.isEmpty()) {
synchronized (position) {
if (position.intValue() >= urlList.size()) {
position.set(0);
}
target = urlList.get(position.getAndIncrement() % urlList.size());
}
logger.info("Target from RoundRobin LB is: " + target);
}
} catch (ExecutionException e) {
e.printStackTrace();
}
return Optional.ofNullable(target);
}

@janyyy
Copy link
Author

janyyy commented Jun 25, 2024

@fmcejudo
Hi fmcejudo,
can you fix this problem ? when the highly concurrent requests,it will reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant