Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-01-20 05:14:03 -0500
committerEike Stepper2013-01-20 05:14:03 -0500
commit74b30a4a03b75ac6c22d18f544ef7553d1775b21 (patch)
treec446c60954a90350c5ca7934d08e94c85fe227b9
parent95a338f8830387c8d67e8dc13b6d0be4cd76a0cb (diff)
downloadcdo-74b30a4a03b75ac6c22d18f544ef7553d1775b21.tar.gz
cdo-74b30a4a03b75ac6c22d18f544ef7553d1775b21.tar.xz
cdo-74b30a4a03b75ac6c22d18f544ef7553d1775b21.zip
[398593] BufferUtil accidentally uses Java 1.6 methods internally
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398593
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferUtil.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferUtil.java
index f4993d4960..0ef7905bad 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferUtil.java
@@ -52,8 +52,20 @@ public final class BufferUtil
return new byte[0];
}
- byte[] bytes = str.getBytes(CHARSET);
- String test = new String(bytes, CHARSET);
+ byte[] bytes;
+ String test;
+
+ try
+ {
+ bytes = str.getBytes(UTF8_CHAR_SET_NAME);
+ test = new String(bytes, UTF8_CHAR_SET_NAME);
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ // This should really not happen
+ throw WrappedException.wrap(ex);
+ }
+
if (!test.equals(str))
{
throw new IllegalArgumentException("String not encodable: " + str); //$NON-NLS-1$
@@ -75,7 +87,7 @@ public final class BufferUtil
catch (UnsupportedEncodingException ex)
{
// This should really not happen
- throw new RuntimeException(ex);
+ throw WrappedException.wrap(ex);
}
}
@@ -217,6 +229,14 @@ public final class BufferUtil
byte[] bytes = new byte[size];
byteBuffer.get(bytes);
- return new String(bytes, CHARSET);
+ try
+ {
+ return new String(bytes, UTF8_CHAR_SET_NAME);
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ // This should really not happen
+ throw WrappedException.wrap(ex);
+ }
}
}

Back to the top