jasperMin opened SPR-14736 and commented
Recently, I use "@Configurable
annotation in my project.I found serious problems below when I trace the errors in my project.
1.XXX.class.getPackage() returns null
2.XXX.class.getProtectionDomain().getCodeSource().getLocation() returns null
These problems disappear when I don't use "
packageName = MultiHostConnectionProxy.class.getPackage().getName();
The null result of Class.getPackage() causes NullPointerException.
No further details from SPR-14736
Comment From: spring-projects-issues
Juergen Hoeller commented
Note that Class.getPackage()
is allowed to return {{null}: https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getPackage()
This is also why we do not rely on Class.getPackage()
within our own codebase. It's arguably a bug that MySQL relies on that method to deliver a non-null result; instead, it should extract the package name from the fully-qualified class name which is the only safe option there.
As for our own load-time weaving exposing the package and protection domain there, that's worth considering as an improvement.
Comment From: spring-projects-issues
jasperMin commented
I did create a bug for Mysql :http://bugs.mysql.com/bug.php?id=83052 And, I hope this improvement could be released soon, best in next version. Haaa! Cause we can't expect all the dependencies won't rely on the non-null result of
Class.getpackage()
. THX!
Comment From: jhoeller
Closing this issue since it got addressed on the MySQL side: https://bugs.mysql.com/bug.php?id=83052