Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpannerPool shutdown hook can fail with ClassNotFoundException #949

Closed
olavloite opened this issue Mar 11, 2021 · 0 comments · Fixed by #950
Closed

SpannerPool shutdown hook can fail with ClassNotFoundException #949

olavloite opened this issue Mar 11, 2021 · 0 comments · Fixed by #950
Assignees
Labels
api: spanner Issues related to the googleapis/java-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@olavloite
Copy link
Collaborator

The shutdown hook in SpannerPool can in some cases fail with a ClassNotFoundException, for example when running Liquibase in Maven. This seems to be caused by a difference in class loader during startup and shutdown.

Exception in thread "SpannerPool shutdown hook" java.lang.NoClassDefFoundError: com/google/cloud/spanner/connection/SpannerPool$CheckAndCloseSpannersMode
	at com.google.cloud.spanner.connection.SpannerPool$CloseSpannerRunnable.run(SpannerPool.java:96)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: com.google.cloud.spanner.connection.SpannerPool$CheckAndCloseSpannersMode
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 2 more
@olavloite olavloite added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Mar 11, 2021
@olavloite olavloite self-assigned this Mar 11, 2021
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Mar 11, 2021
olavloite added a commit that referenced this issue Mar 11, 2021
All throwables (and not just exceptions) should be ignored in the shutdown hook.
Failing to close these resources during shutdown is not a major problem, as they
will be garbage collected by the backend anyways. Without this wide catch, some
applications will log a ClassNotFoundException when shutting down, which can be
confusing for end users.

Fixes #949
thiagotnunes pushed a commit that referenced this issue Mar 16, 2021
All throwables (and not just exceptions) should be ignored in the shutdown hook.
Failing to close these resources during shutdown is not a major problem, as they
will be garbage collected by the backend anyways. Without this wide catch, some
applications will log a ClassNotFoundException when shutting down, which can be
confusing for end users.

Fixes #949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant