Fix #25220 The number of Logging pump threads grows infinitely #25221
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.
Fix to destroy old threads through LoggingOutputStream.close() when updating contents of logging.properties.
First, fix LoggingOutputStream.close() to be called when logging.properties is updated.
When logging.properties is updated, GlassFishLogHandler.reconfigure() is called to recreate the LoggingOutputStream based on the updated contents of logging.properties.
glassfish/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/GlassFishLogHandler.java
Lines 191 to 217 in c354344
However, there is no process to stop the existing LoggingOutputStream's Pump Thread during this recreation.
Second, fix processing so that the Pump Thread is destroyed when LoggingOutputStream.close() is called.
When LoggingOutputStream.close() is called, Pump.shutdown() is called, but Pump.shutdown() cannot stop the Pump thread.
glassfish/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LoggingOutputStream.java
Lines 171 to 175 in c354344
If Pump.interrupt() is called, the implementation absorbs the InterruptException inside the LogRecordBuffer class.
glassfish/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LogRecordBuffer.java
Lines 159 to 168 in c354344
Therefore, the while loop of the Pump thread does not stop when Pump.shutdown() is called.
So, the fix is to add a flag and modify Pump.shutdown() to stop Thread.