Skip to content

Prevent ConcurrentModificationException in TempTableThread shutdown#7463

Merged
labkey-tchad merged 1 commit intorelease26.3-SNAPSHOTfrom
fb_tempTableShutdownException
Mar 2, 2026
Merged

Prevent ConcurrentModificationException in TempTableThread shutdown#7463
labkey-tchad merged 1 commit intorelease26.3-SNAPSHOTfrom
fb_tempTableShutdownException

Conversation

@labkey-tchad
Copy link
Member

Rationale

TempTableThread.shutdownStarted() enumerates createdTableNames.values() and calls CleanupState.run(), which may end up removing elements from createdTableNames.values(). All operations are synchronized, but values() is not a concurrent collection.
Iterating over a copy will prevent this exception.

INFO  ContextListener          2026-02-26T13:42:09,901 gApplicationShutdownHook : Calling Temp table cleanup shutdownStarted()
ERROR ContextListener          2026-02-26T13:42:09,933 gApplicationShutdownHook : Exception during shutdownStarted(): 
java.util.ConcurrentModificationException
    at java.base/java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1522)
    at java.base/java.util.TreeMap$ValueIterator.next(TreeMap.java:1567)
    at org.labkey.api.data.TempTableTracker$TempTableThread.shutdownStarted(TempTableTracker.java:289)
    at org.labkey.api.util.ContextListener.callShutdownListeners(ContextListener.java:148)
    at org.labkey.api.util.ContextListener.contextDestroyed(ContextListener.java:99)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4048)

Related Pull Requests

  • N/A

Changes

  • Prevent ConcurrentModificationException in TempTableThread shutdown

Copy link
Contributor

@labkey-jeckels labkey-jeckels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did no testing but seems straightforward

@labkey-tchad labkey-tchad changed the base branch from develop to release26.3-SNAPSHOT March 2, 2026 19:40
@labkey-tchad labkey-tchad merged commit d2090d7 into release26.3-SNAPSHOT Mar 2, 2026
20 checks passed
@labkey-tchad labkey-tchad deleted the fb_tempTableShutdownException branch March 2, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants