Details
-
Bug
-
Resolution: Fixed
-
Blocker
-
2.11.0, 2.11.1, 2.11.2
-
None
-
Security Level: Public
-
None
Description
I found a multi-threading issue introduced in SPY-127. I added my comments already into this link but pasting it here as well.
-------
The non-thread safe code has to do with "decimalMatcher.reset(s).matches()".
When one thread is in the "matches", and then a second thread calls reset, I get a runtime exception..
java.lang.StringIndexOutOfBoundsException: String index out of range: 4
at java.lang.String.charAt(String.java:658)
at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715)
at java.util.regex.Pattern$Curly.match0(Pattern.java:4158)
at java.util.regex.Pattern$Curly.match(Pattern.java:4132)
at java.util.regex.Pattern$Ques.match(Pattern.java:4079)
at java.util.regex.Pattern$Begin.match(Pattern.java:3472)
at java.util.regex.Matcher.match(Matcher.java:1221)
at java.util.regex.Matcher.matches(Matcher.java:559)
at net.spy.memcached.util.StringUtils.isJsonObject(StringUtils.java:113)
at net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder.java:134)
at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:305)
at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:929)
at com.couchbase.client.CouchbaseClient.set(CouchbaseClient.java:1266)
at com.example.Test$1.run(Test.java:124)
at java.lang.Thread.run(Thread.java:724)
To reproduce, just create for example 10 threads that each loop 100K times calling set("anykey","123456789"). i.e. 1M set operations distributed between 10 threads.
I encountered this because I have a very fast counter keeping track of my position in a set of objects.