Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Possible bug in PreferenceService#getByteArray
Possible bug in PreferenceService#getByteArray [message #509097] Thu, 21 January 2010 06:34 Go to next message
Marcel Hoetter is currently offline 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
Re: Possible bug in PreferenceService#getByteArray [message #509170 is a reply to message #509097] Thu, 21 January 2010 10:08 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas Watson
Messages: 418
Registered: July 2009
Senior Member
Yes that looks like a real bug. Please open a bug report against RT->Equinox->Compendium

Thanks! Good Catch!

Tom.
Re: Possible bug in PreferenceService#getByteArray [message #509182 is a reply to message #509170] Thu, 21 January 2010 10:29 Go to previous messageGo to next message
Marcel Hoetter is currently offline Marcel Hoetter
Messages: 28
Registered: July 2009
Junior Member
Thomas Watson schrieb:
> Yes that looks like a real bug. Please open a bug report against
> RT->Equinox->Compendium
>
> Thanks! Good Catch!
>
> Tom.
>
done. :)
Re: Possible bug in PreferenceService#getByteArray [message #509183 is a reply to message #509182] Thu, 21 January 2010 10:31 Go to previous message
Marcel Hoetter is currently offline Marcel Hoetter
Messages: 28
Registered: July 2009
Junior Member
Marcel Hoetter schrieb:
> done. :)
Link: https://bugs.eclipse.org/bugs/show_bug.cgi?id=300385
Previous Topic:Where's the best place to put code that shutdowns Ehcache CacheManager ?
Next Topic:How to let run Equinox on a debian server in the background / deploy Equinox?
Goto Forum:
  


Current Time: Sun Apr 20 04:25:54 EDT 2014

Powered by FUDForum. Page generated in 0.14137 seconds