Re: com.mysql.jdbc.Messages static ctor bug report and fix
Posted by: Mark Matthews
Date: January 11, 2005 11:33AM

Jason Winnebeck wrote:
> There are actually two problems in the
> com.mysql.jdbc.Messages static constructor for
> Connector/J 3.1.6 that I downloaded from the MySQL
> site 1/7/05.
>
> Summary:
> com.mysql.jdbc.Messages class fails to load
> because of null pointer exception in some JVMs.
>
> Occurs in: 3.1.6
> Does not occur in: 3.0.11
>
> First problem:
> static constructor catch clause crashes for any
> exception thrown.
> Cause:
> Util.stackTraceToString calls static method
> Message.getString. As the Message class is not
> yet initialized, RESOURCE_BUNDLE is null, and NPE
> is thrown in the exception handler.
> Solution: Do not call Util.stackTraceToString, and
> instead do the work directly in catch handler for
> Throwable.
>
> Second problem:
> ResourceBundle.getBundle(BUNDLE_NAME,
> Locale.getDefault(),
> Messages.class.getClassLoader()); throws
> NullPointerException on some JVMs.
> Cause:
> Contract for getBundle specifies that none of the
> three parameters may be null, and getBundle will
> throw NPE if any of them are. This does occur.
> Contract for Class.getClassLoader() says that it
> may return null: javadoc: "Some implementations
> may use null to represent the bootstrap class
> loader. This method will return null in such
> implementations if this class was loaded by the
> bootstrap class loader."
> This is true for my JVM. I am using Sun's CVM,
> the reference implementation for Java CDC 1.1
> (compatible with Java 1.3), as I am running in an
> embedded environment.
[snip]

Jason,

Thanks for your suggestions I'll take a look. Unfortunately, we had to use the three-arg constructor to get around other exceptions and classloader issues that other users were experiencing with appservers and their hierarchical classloaders, so it will require some regression testing to get it truly right, maybe just trying both ways in the static initializer, and the one that works first wins :(

-Mark

Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html

Options: ReplyQuote


Subject
Written By
Posted
Re: com.mysql.jdbc.Messages static ctor bug report and fix
January 11, 2005 11:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.