The StackOverflowError occurred after automatic reconnection 2,000 times
java.lang.StackOverflowError: null
at io.vertx.core.impl.AbstractContext.isRunningOnContext(AbstractContext.java:41) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:50) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.onSuccess(PromiseImpl.java:49) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.onSuccess(PromiseImpl.java:49) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.onSuccess(PromiseImpl.java:49) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
at io.vertx.core.impl.future.PromiseImpl.onSuccess(PromiseImpl.java:49) ~[vertx-core-4.2.0-20211009.081319-114.jar:4.2.0-SNAPSHOT]
......
I can reproduce the stackoverflow error by following steps :
The client connects to the MQ server using the following reconnection configuration:
RabbitMQOptions options = new RabbitMQOptions();
options.setAutomaticRecoveryEnabled(false);
options.setReconnectAttempts(Integer.MAX_VALUE);
options.setReconnectInterval(50); // To reproduce the stackoverflow error quickly.
Stop the MQ server, the client starts to reconnect automatically.
After the client failed to reconnect for 2000 times, I restart the MQ server.
The client should reconnect successfully, but the program threw a stackoverflow error. Because every time the client tries to reconnect, a new promise is created here. Nesting promises lead to the stackoverflow error. In order to solve this problem, only the same pomise is used in the process of reconnecting.
Motivation:
The StackOverflowError occurred after automatic reconnection 2,000 times
I can reproduce the stackoverflow error by following steps :
The client should reconnect successfully, but the program threw a stackoverflow error. Because every time the client tries to reconnect, a new promise is created here. Nesting promises lead to the stackoverflow error. In order to solve this problem, only the same pomise is used in the process of reconnecting.