Hi Arco,
Yes, I (finally) got back to this issue and found the bug. The CharsetDecoder is not thread-safe, and we were using instances of the class from multiple threads as your test case shows.
http://docs.oracle.com/javase/7/docs/api/java/nio/charset/CharsetEncoder.html
"Instances of this class are not safe for use by multiple concurrent threads."
The fix is straightforward and has been pushed to our internal source tree.
If you like, you can apply this patch to the source tree and test it yourself.
If it turns out that this is a performance issue with many threads accessing decimal fields, let us know. This would mean that we would need to create a new CharsetDecoder for each Session and pass it around, which would mean a lot of extra code.
Regards,
Craig
--- a/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java
@@ -1785,7 +1785,12 @@ public class Utility {
}
try {
// use basic decoding
- CharBuffer charBuffer = charsetDecoder.decode(digits);
+ //
http://docs.oracle.com/javase/7/docs/api/java/nio/charset/CharsetEncoder.html
+ // synchronize because "Instances of this class are not safe for use by multiple concurrent threads."
+ CharBuffer charBuffer;
+ synchronized(charsetDecoder) {
+ charBuffer = charsetDecoder.decode(digits);
+ }
string = charBuffer.toString();
return string;
} catch (CharacterCodingException e) {