Skip to content

Commit 59292eb

Browse files
authored
Merge pull request #430 from AxonIQ/fix/reconnect-persistent-streams
Prevent reconnect actions on already closed Persistent Stream
2 parents bde0b91 + b7108d8 commit 59292eb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/io/axoniq/axonserver/connector/event/impl/PersistentStreamImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ public void openConnection(InitializationProperties initializationProperties) {
131131
* streams, and those closed with the intent to re-establish a connection.
132132
*/
133133
public void triggerReconnect() {
134+
if (closed.get()) {
135+
logger.info("{}: Already closed, cannot trigger reconnect", streamId);
136+
return;
137+
}
134138
// first, close gracefully
135139
close();
136140
AxonServerException reconnectRequested = new AxonServerException(ErrorCategory.OTHER,
@@ -259,7 +263,11 @@ private void sendCompleted() {
259263
}
260264

261265
private void close(Throwable throwable) {
262-
closed.set(true);
266+
boolean wasClosed = closed.getAndSet(true);
267+
if (wasClosed) {
268+
logger.info("{}: Already closed, cannot close again", streamId);
269+
return;
270+
}
263271
openSegments.forEach((segment, buffer) -> {
264272
try {
265273
if (throwable != null) {

0 commit comments

Comments
 (0)