Possible bug in PreferenceService#getByteArray [message #509097] |
Thu, 21 January 2010 11:34 |
Marcel Hoetter Messages: 28 Registered: July 2009 |
Junior Member |
|
|
Hello,
i found a possible bug in the org.eclipse.core.internal.preferences.PreferencesService#get ByteArray
method.
The following JUnit test fails:
@Test
public void putByteArray_DefaultScope() {
final byte[] testArray = new byte[] { 10, 13, 15, 20 };
DefaultScope defaultScope = new DefaultScope();
defaultScope.getNode(TEST_NODE_PATH).putByteArray(TEST_PREF_ KEY, testArray);
final byte[] returnArray = Platform.getPreferencesService().
getByteArray(TEST_NODE_PATH,TEST_PREF_KEY,new byte[] {}, null);
Assert.assertArrayEquals(testArray, returnArray);
}
I think the bug is in line 512 of PrefereceService, where a "Base64.decode" is missing.
The method should look like this:
public byte[] getByteArray(String qualifier, String key, byte[] defaultValue, IScopeContext[] scopes) {
String result =
get(EclipsePreferences.decodePath(key)[1], null, getNodes(qualifier, key, scopes));
return result == null ? defaultValue : Base64.decode(result.getBytes());
}
Would someone please verify and confirm this bug?
I will then open a bug report.
Thanks,
Marcel
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01622 seconds