JDK 9 RFR [8137005]: java.util.logging.Formatter#formatMessage() swallows Exceptions

Alexander Fomin alexander.fomin at oracle.com
Fri Nov 20 13:48:29 UTC 2015


Hi,
please, review this patch to report errors  in 
java.util.logging.Formatter#formatMessage().

Bug: https://bugs.openjdk.java.net/browse/JDK-8137005
Webrev: http://cr.openjdk.java.net/~dfuchs/alexander/8137005/webrev.00

Summary:
     j.u.logging.Formatter#formatMessage() swallows exceptions that 
happening during formatting of a message. In the result the exceptions 
are lost and users don't know about reasons why the message hasn't been 
formatted as expected. We would avoid to throw any exceptions in 
Formatter#formatMessage() from compatibility stand point. To report an 
error  in consistent way we have to pass ErrorManager in Formatter. It's 
require API changes. So, I'm going to file CCC when if the fix approved.
     The suggested fix is to add 2 new methods in j.u.logging.Formatter 
to set/get an ErrorManager, update Formatter#formatMessage() to report 
errors via the ErrorManager and update Handler to pass errorManager to 
Formatter.

Testing:
     A couple of new regression tests have been created:
         test/java/util/logging/Test8137005.java - real case provided by 
users
         test/java/util/logging/NullErrorManagerTest.java - additional 
check to make sure no NPE showed if ErrorManager isn't set. Beside of 
this touched new API methods.

     Logging regression tests have been run:
         jdk/test/java/util/logging
         jdk/test/closed/java/util/logging
         jdk/test/sun/util/logging
     All tests passed passed.

JPRT: 
http://sthjprt.uk.oracle.com/archives/2015/11/2015-11-19-143523.gtee.dev/
failures in the job are known issues and not related to the fix.

Thanks,
Alexander






More information about the core-libs-dev mailing list