DESCRIPTION

SPY-168: isJSONObject should handle null or empty input values.

Motivation
----------
Before this change, the isJSONObject was suspect to NPEs and possibly also
regex match failings on empty strings, although that does not seem to be the
case on Java 1.7+.

Modifications
-------------
Specific null and empty checks have been added to make the method more robust.

Result
------
NPEs are not raised anymore and also empty strings are checked much quicker. Test
cases have been added to verify functionality.

Side note: An exception like this was reported on empty strings, but could not be
verified with Java 1.7 onward. It is suspected that this changeset also fixes
the issue given the input type and code process:

Original Exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Stack trace:
java.lang.String.charAt(String.java:658)
java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715)
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:109)
net.spy.memcached.transcoders.SerializingTranscoder.encode(Seriali
...

Change-Id: Icaca2f3fef658cdb2c376b6b4dba12ae0327f240
Reviewed-on: http://review.couchbase.org/36695
Reviewed-by: Andreas Short xxx@xxx.xxx
Reviewed-by: Natasha Sullivan xxx@xxx.xxx
Tested-by: Natasha Sullivan xxx@xxx.xxx


COMMENTS

author: Natasha Sullivan
date: 2014-05-05 15:12:05.870000000

Change has been successfully cherry-picked as 386a843c57e9b61629e2d07887a0bf0eab37ad43

-------------------------------------
