Skip to content

Prevent ConcurrentModificationException in TempTableThread shutdown#7463

Open
labkey-tchad wants to merge 1 commit intodevelopfrom
fb_tempTableShutdownException
Open

Prevent ConcurrentModificationException in TempTableThread shutdown#7463
labkey-tchad wants to merge 1 commit intodevelopfrom
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

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