roc230 / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

MemcacheClient with SerializingTranscoder isn't thread safe #315

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version 2.11.2

net.spy.memcached.MemcachedClient.incr(String key, int by, long def, int exp)

sometimes produces this error, when it calls in serveral threads from the 
single volatile MemcachedClient instance. 

java.lang.StringIndexOutOfBoundsException String index out of range
java.lang.String.charAt(String.java:658)
java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715)
java.util.regex.Pattern$Curly.match0(Pattern.java:4148)
java.util.regex.Pattern$Curly.match(Pattern.java:4132)
java.util.regex.Pattern$Ques.match(Pattern.java:4079)
java.util.regex.Pattern$Begin.match(Pattern.java:3472)
java.util.regex.Matcher.match(Matcher.java:1221)
java.util.regex.Matcher.matches(Matcher.java:559)
net.spy.memcached.util.StringUtils.isJsonObject(StringUtils.java:113)
net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder
.java:134)
net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:305)
net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:334)
net.spy.memcached.MemcachedClient.mutateWithDefault(MemcachedClient.java:1955)
net.spy.memcached.MemcachedClient.incr(MemcachedClient.java:1902)

The method net.spy.memcached.util.StringUtils.isJsonObject isn't thread safe, 
because it uses the single instance of java.util.regex.Matcher, which isn't 
thread safe.

Original issue reported on code.google.com by igorbun...@issart.com on 15 Dec 2014 at 11:59