Skip to content

Initialize PostgreSQL SharedTimer on JUnit launcher thread#36979

Open
LordKay-sudo wants to merge 1 commit into
spring-projects:mainfrom
LordKay-sudo:gh-36737-postgresql-shared-timer
Open

Initialize PostgreSQL SharedTimer on JUnit launcher thread#36979
LordKay-sudo wants to merge 1 commit into
spring-projects:mainfrom
LordKay-sudo:gh-36737-postgresql-shared-timer

Conversation

@LordKay-sudo

Copy link
Copy Markdown

Summary

Addresses the PostgreSQL JDBC SharedTimer / InheritableThreadLocal context pinning reported by @pkernevez in gh-36737.

Registers a JUnit Platform LauncherSessionListener (via SPI) that eagerly initializes org.postgresql.Driver.getSharedTimer() on the launcher thread, so the driver's TimerThread does not inherit TransactionContextHolder from a @Transactional test worker thread.

Notes

  • No-op when the PostgreSQL driver is not on the classpath (uses reflection)
  • Complements user workarounds that register a custom LauncherSessionListener manually

Test plan

  • ./gradlew :spring-test:test --tests "org.springframework.test.context.jdbc.PostgresqlSharedTimerLauncherSessionListenerTests"

Related to gh-36737

Prevent the PostgreSQL JDBC driver timer thread from inheriting Spring
TransactionContextHolder from transactional test threads, which can pin
ApplicationContext instances for the JVM lifetime (spring-projectsgh-36737).

Related to spring-projectsgh-36737

Signed-off-by: LordKay-sudo <lkandiro@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants