Repository navigation
8.0 (fix): Load what the embedded MongoDB's event loops need as it starts - #16878
Closed
codeconsole wants to merge 1 commit into
Closed
codeconsole wants to merge 1 commit into
codeconsole wants to merge 1 commit into
Conversation
Spring Boot closes the jars of an executable jar's class loader when the context has refreshed, through ClearCachesApplicationListener, and a class being loaded at that moment fails with IllegalStateException: Zip file closed. That listener did not reach the class loader until Spring Boot 4.2.0-RC2, 4.1.3 and 4.0.10 (spring-projects/spring-boot#52582), so 8.0.x meets this when it moves to 4.1.3. It is reported as spring-projects/spring-boot#52634. The driver connects just before that moment, and reading its first bytes allocates the event loop's first buffer. Netty logs the failure, Logback fails the same way to load a class to log it, and that ends the event loop's thread. The driver gets no answer, and stopping the server waits forever for its connection on that thread to close. On 4.2.0-RC2 an application with the in-memory backend run from its executable jar hung when stopped 3 times out of 3 with Netty 4.2.20 and 1 out of 6 with Netty 4.2.19. The server now answers one isMaster as it starts, so the event loop has loaded what the first client needs long before that moment. The race remains for anything else loading a class right then. ClearedJarsServerApplication fails class loading for a moment as a client sends its first bytes. The spec fails without this.
codeconsole
requested review from
jamesfredley,
jdaugherty,
matrei and
sbglasius
November 6, 2026 03:37
Contributor
Author
|
Closing: 8.x does not have this problem. The hang needs spring-projects/spring-boot#52246 as well as #52582, and only 4.2 has both. With the loader of 4.1.3-SNAPSHOT and this change taken out, the application stopped cleanly 10 times out of 10. The change remains in #16871 for 9.1.x, and Spring Boot's fix is proposed in spring-projects/spring-boot#52635. |
codeconsole
removed request for
jamesfredley,
jdaugherty,
matrei and
sbglasius
November 6, 2026 04:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This does not fix a problem 8.x has. I opened it believing 8.x would hang like this once it moves to Spring Boot 4.1.3, and that was wrong, as is the same sentence in the commit message. The hang needs spring-projects/spring-boot#52246 as well as #52582, and only 4.2 has both. With the loader of 4.1.3-SNAPSHOT and the fix taken out, the application stopped cleanly 10 times out of 10, where the loader of 4.2.0-RC2 hung 3 times out of 3. The fix for 9.1.x is in #16871, and Spring Boot's own is proposed in spring-projects/spring-boot#52635.
What is left here is hardening:
InMemoryMongoBackendhas the server answer oneisMasteras it starts, so the event loop has loaded what its first client needs before that client connects.ClearedJarsServerApplicationandEmbeddedMongoLifecycleSpeccover it, and the spec fails without the change on this branch.