Skip to content

Commit

Permalink
Fixed a bug in SpringMongoSubscriptionModel in which it didn't restar…
Browse files Browse the repository at this point in the history
…t correctly on non DataAccessException's
  • Loading branch information
johanhaleby committed Jan 19, 2024
1 parent 1fb69c1 commit f0efdcb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### Changelog next version
### 0.17.0
* spring-boot-starter-mongodb no longer autoconfigures itself by just importing the library in the classpath, instead you need to bootstrap by annotating your Spring Boot class with @EnableOccurrent.
* Fixed bug in spring-boot-starter-mongodb module in which it didn't automatically configured MongoDB.
* Domain event subscriptions now accepts metadata as the first parameter, besides just the event. The metadata currently contains the stream version and stream id, which can be useful when building projections.
* Fixed bug in spring-boot-starter-mongodb module in which it didn't automatically configure MongoDB.
* Domain event subscriptions now accepts metadata as the first parameter, besides just the event. The metadata currently contains the stream version and stream id, which can be useful when building projections.
* Fixed a bug in SpringMongoSubscriptionModel in which it didn't restart correctly on non DataAccessException's
* Upgraded from Kotlin 1.9.20 to 1.9.22
* Upgraded amqp-client from 5.16.0 to 5.20.0
* Upgraded Spring Boot from 3.1.4 to 3.2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ private org.springframework.data.mongodb.core.messaging.Subscription registerNew
log.debug("Cursor is no longer open for subscription {}, this may happen if you pause a subscription very soon after subscribing.", subscriptionId, throwable);
}
} else {
log.error("An error occurred for subscription {}", subscriptionId, throwable);
log.error("An error occurred for subscription {}, will restart", subscriptionId, throwable);
restartInternalSubscription(subscriptionId, StartAt.subscriptionModelDefault());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,14 @@ void restarts_subscription_on_DataAccessResourceFailureException() {
assertSubscriptionIsRestartedForException(exception);
}

@Timeout(value = 20, unit = SECONDS)
@Test
void restarts_subscription_on_non_DataAccessException() {
var exception = new IllegalStateException("Cursor com.mongodb.client.internal.MongoChangeStreamCursorImpl@3ab4fcd8 is not longer open");

assertSubscriptionIsRestartedForException(exception);
}

@SuppressWarnings("unchecked")
private void assertSubscriptionIsRestartedForException(Exception exception) {
// Given
Expand Down

0 comments on commit f0efdcb

Please sign in to comment.