8153666: Optimize Formatter.formatMessage
Jason Mehrens
jason_mehrens at hotmail.com
Wed Jun 8 14:31:41 UTC 2016
Hi Daniel,
Thanks for taking this on. Looks good.
This might be a new issue altogether but, if record.getMessage returns null a NPE can be generated during 'catalog.getString' (per RB.handleGetObject contract) or 'java.text.MessageFormat.format' (undocumented)
It is handled by the catch clause so it is harmless in terms of correctness. The most common form of this abuse I've seen in the wild is
'logger.log(SEVERE, null, (Throwable) ioe);
So if it not worth explicitly checking for null maybe we should add a comment explaining the intent that NPE could be generated and is trapped.
For sure having tests for null message with and without a resource bundle would be a good idea.
Thanks,
Jason
From: core-libs-dev <core-libs-dev-bounces at openjdk.java.net> on behalf of Daniel Fuchs <daniel.fuchs at oracle.com>
Sent: Wednesday, June 8, 2016 8:46 AM
To: core-libs-dev
Subject: RFR: 8153666: Optimize Formatter.formatMessage
Hi,
Please find below a patch for a small optimization
in Formatter.formatMessage.
This patch also removed the synchronized keyword which
was there for historical reasons - but which has
become needless.
More background available at:
https://bugs.openjdk.java.net/browse/JDK-8153666
(thanks Martin!)
and
http://stackoverflow.com/questions/36433146/why-is-the-formatmessage-method-in-java-util-logging-formatter-synchronized
(thanks Jason!)
bug:
8153666: Optimize Formatter.formatMessage
https://bugs.openjdk.java.net/browse/JDK-8153666
patch:
http://cr.openjdk.java.net/~dfuchs/webrev_8153666/webrev.00
best regards, and thanks to all who provided suggestions and
archeological background!
-- daniel
More information about the core-libs-dev
mailing list