-
Notifications
You must be signed in to change notification settings - Fork 100
performance problem in Loader.reportUnexpectedChildElement #286
Comments
Reported by pkorros |
Was assigned to jaxb-issues |
kohsuke said: |
pkorros said: When the unmarshal method is called with an InputStream (and I guess many other This is very important because, unmarshaling a jaxb object over an input stream A good solution would be not to compute the message and location at all when |
pkorros said: |
kohsuke said: |
Marked as fixed on Tuesday, July 10th 2007, 3:27:03 am |
This issue was imported from java.net JIRA JAXB-286 |
By profiling my application I found out a performance problem in the unmarshal
code. My test code parses a document 10 times.
The Unmarshaller.unmarshal(File) calls take 1484 ms while 1000 of them are spent
in the Loader.reportUnexpectedChildElement.
This is because the error message is formatted (MessageFormat.format) even
thought it will never be used because the error messages are not reported to the
user. Also you use the static call to MessageFormat.format that creates the
MessageFormat in every call.
By caching the MessageFormat object (using the code sample below) the
performance is much better (600ms).
private final ThreadLocal format = new ThreadLocal();
public String format( Object... args )
{ if( format.get() == null ) format.set(new MessageFormat(rb.getString(name()))); return format.get().format( args ); }
but it could be even better if you could avoid the message construction if there
is no error handler registered (the default option).
Environment
Operating System: All
Platform: All
Affected Versions
[2.0.4]
The text was updated successfully, but these errors were encountered: