Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 122993 - [metatype service] AttributeDefinitionImpl attempts to localize option values
Summary: [metatype service] AttributeDefinitionImpl attempts to localize option values
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: 3.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 trivial (vote)
Target Milestone: 3.7 M3   Edit
Assignee: John Ross CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-06 21:30 EST by Dieter Wimberger CLA
Modified: 2010-10-11 14:59 EDT (History)
2 users (show)

See Also:


Attachments
proposed patch (1.01 KB, patch)
2010-06-04 22:25 EDT, Bryan Hunt CLA
tjwatson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dieter Wimberger CLA 2006-01-06 21:30:45 EST
The AttributeDefinitionImpl class will attempt to localize the option value if prefixed with a %.
I don't think that the localization mechanism should attempt to localize any attribute value (an option value is basically a possible attribute value), so I think this is a bug.

There are two hypothetic cases in which the implementation will cause troubles, altering the attributes value:
1. there is no translation for the value in the resource bundles, but the % as first character will be removed
2. there is a translation for the value in the resource bundle (i.e. the value matches another localized attribute name) and the value will be translated to the localization of that attribute name.

I agree that the probability is low that a value will be prefixed with a % AND that it matches
some other localized name, but I think that this should be fixed.

The code causing this problem is in the getOptionValues() method: 
returnedValues[i] = getLocalized(valueKey);
which should probably read:
returnedValues[i] = valueKey;

Regards,
Dieter
Comment 1 Pascal Rapicault CLA 2006-04-05 11:35:50 EDT
Dieter, there are no such class in equinox. Could you please give the fully qualified name of the class?
Comment 2 Dieter Wimberger CLA 2006-04-05 12:16:23 EDT
Pascal,

The fully qualified name of this class is:
org.eclipse.equinox.metatype.AttributeDefinitionImpl

Sorry that I did not specify the actual bundle. Probably each bundle implementation should be a component by itself.

Regards,
Dieter
Comment 3 Thomas Watson CLA 2006-04-10 11:06:46 EDT
Jennifer please investigate.  If you think a fix should be included in 3.2 please provide a patch for review.
Comment 4 Bryan Hunt CLA 2010-06-04 22:25:30 EDT
Created attachment 171191 [details]
proposed patch

If I read the spec correctly, option values should not be translated.  The proposed patch returns the option values untranslated.
Comment 5 Bryan Hunt CLA 2010-06-04 22:26:46 EDT
Tom, are there any unit tests for metatype?  I couldn't find any in CVS.
Comment 6 Thomas Watson CLA 2010-06-07 09:17:26 EDT
(In reply to comment #5)
> Tom, are there any unit tests for metatype?  I couldn't find any in CVS.

No, we have been using the OSGi CT to test.  We need more tests in Equinox for this.
Comment 7 Thomas Watson CLA 2010-10-07 08:30:41 EDT
John, here is another meta-type bug to investigate.
Comment 8 John Ross CLA 2010-10-08 01:11:47 EDT
(In reply to comment #7)
> John, here is another meta-type bug to investigate.

Option values should not be localized. These are meant for computer, not human, consumption. Any modification could, and probably would, result in unrecognizable input to the target system.

I don't see any necessary or desired changes to the current patch.
Comment 9 Thomas Watson CLA 2010-10-08 08:25:24 EDT
Thanks I will review and release for M3.
Comment 10 Thomas Watson CLA 2010-10-11 14:59:34 EDT
Patch released.  This is quite obvious and I am surprised it has not really been much of an issue for folks.

Thanks Brian and John.