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


COMMENTS

author: Andreas Short
date: 2014-05-05 15:12:02.916000000

Patch Set 2: Code-Review+2

Automatically re-added by Gerrit trivial rebase detection script.

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

Patch Set 2: Verified+1 Code-Review+2

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