Bug 49412 - [PATCH] Useless messages for exception thrown in Image codec
Summary: [PATCH] Useless messages for exception thrown in Image codec
Status: RESOLVED FIXED
Alias: None
Product: XMLGraphicsCommons - Now in Jira
Classification: Unclassified
Component: image codecs (show other bugs)
Version: Trunk
Hardware: All All
: P2 normal (vote)
Target Milestone: --
Assignee: XML Graphics Project Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2010-06-09 05:55 UTC by Julien Aymé
Modified: 2010-06-13 12:37 UTC (History)
0 users



Attachments
The proposed patch (1.88 KB, application/octet-stream)
2010-06-09 05:55 UTC, Julien Aymé
Details
Resource bundle for English locale (403 bytes, text/plain)
2010-06-09 05:58 UTC, Julien Aymé
Details
Resource bundle for French locale (473 bytes, text/plain)
2010-06-09 05:59 UTC, Julien Aymé
Details
Patch for PNGDecodeParam class (1.14 KB, patch)
2010-06-09 06:01 UTC, Julien Aymé
Details | Diff
Patch for PNGEncodeParam class (12.77 KB, patch)
2010-06-09 06:03 UTC, Julien Aymé
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Aymé 2010-06-09 05:55:23 UTC
Created attachment 25557 [details]
The proposed patch

PropertyUtil references a non-existent resource bundle: "org.apache.xmlgraphics.image.codec.resources.Messages".

The PropertyUtil class is used to generated localized message for the exception thrown in image.codec subpackages, and since the resource is not supplied, the generated exceptions messages are all useless (e.g. "PNGEncodeParam0").

I propose to change the pattern of the message key, instead of using "classname + number", by using a "real" meaningful message, like "invalid value supplied".

I will attach shortly:
- A patch to PropertyUtil to be able to give arguments to the messages,
- an enhancement of the messages for some classes in image.codec,
- a resource bundle (for Locale "en" and "fr")
Comment 1 Julien Aymé 2010-06-09 05:57:15 UTC
Note that the issue 47175 is similar to this issue; but this one propose a better approach for solving the problem encountered.
Comment 2 Julien Aymé 2010-06-09 05:58:58 UTC
Created attachment 25558 [details]
Resource bundle for English locale
Comment 3 Julien Aymé 2010-06-09 05:59:22 UTC
Created attachment 25559 [details]
Resource bundle for French locale
Comment 4 Julien Aymé 2010-06-09 06:01:18 UTC
Created attachment 25560 [details]
Patch for PNGDecodeParam class

Adding path for PNGDecodeParam class using the new bundle.
It produces more explicit/understandable messages in the exceptions thrown.
Comment 5 Julien Aymé 2010-06-09 06:03:06 UTC
Created attachment 25561 [details]
Patch for PNGEncodeParam class

Adding path for PNGEncodeParam class using the new bundle.
It produces more explicit/understandable messages in the exceptions thrown.
Comment 6 Julien Aymé 2010-06-09 06:06:49 UTC
I intend to continue for other classes in the image.codec package,
so I would like to have some comments/feedback on the method I used to add localization for the codec package before changing the whole classes.

Any thoughts?
Julien
Comment 7 Jeremias Maerki 2010-06-13 12:37:13 UTC
Julien, thanks for looking into this. I've been wanting to do this for a long time, and with your ticket I actually had to. Turns out, the original message resources got lost along the way at some point and they didn't make the transition from Batik to XGC.

Apparently, the mistake happened here:
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/resources/org/apache/batik/ext/awt/image/codec/properties?r1=378233&r2=378232&pathrev=378233

In that light, your effort to start translating the messages is great but unnecessary, except if you want to refine the whole thing. The exception handling in these classes is certainly not a role model, for example. I'm closing this issue. Please re-open if you think it's not good enough and want to refine.

Messages restored:
http://svn.apache.org/viewvc?rev=954256&view=rev