Uploaded image for project: 'Grouper'
  1. Grouper
  2. GRP-1433

json in REST input disallows whitespace at end

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.1.0, 2.2.0, 2.3.0
    • 2.4.0, 2.3.0.patch
    • WS
    • None

    Description

      When setting the POST json string for a REST request, the json format checker allows whitespace anywhere except at the end of the string. If the last character is not a closing brace, it throws error "Error unparsing string with converter: edu.internet2.middleware.grouper.ws.rest.json.DefaultJsonConverter...".

      This sounds like a trivial issue, but it actually does make for confusing behavior when using something like SoapUI to develop. The stacktrace includes the input string, but with no quotes around it there is no indication whether or not final whitespace is even there. One must be careful when setting up the SoapUI request, making sure to delete any carriage return that might be there after the closing brace.

      Fix:

      diff --git a/grouper/src/grouper/edu/internet2/middleware/grouper/util/GrouperUtil.java b/grouper/src/grouper/edu/internet2/middleware/grouper/util/GrouperUtil.java
      index eb8d254..c2e4a48 100644
      --- a/grouper/src/grouper/edu/internet2/middleware/grouper/util/GrouperUtil.java
      +++ b/grouper/src/grouper/edu/internet2/middleware/grouper/util/GrouperUtil.java
      @@ -1715,12 +1715,12 @@ public class GrouperUtil {
          * \{\s*         open bracket and optional space
          * \"([^"]+)\"   quote, simple name of class, quote
          * \s*:\s*       optional space, colon, optional space
      -   * \{(.*)}$      open bracket, the class info, close bracket, end of string
      +   * \{(.*)}\s*$      open bracket, the class info, close bracket, optional space, end of string
          *
          *
          * </pre>
          */
      -  private static Pattern jsonPattern = Pattern.compile("^\\s*\\{\\s*\\\"([^\"]+)\\\"\\s*:\\s*(.*)}$", Pattern.DOTALL);
      +  private static Pattern jsonPattern = Pattern.compile("^\\s*\\{\\s*\\\"([^\"]+)\\\"\\s*:\\s*(.*)}\\s*$", Pattern.DOTALL);
       
         /**
          * convert an object from json.  note this works well if there are no collections, just real types, arrays, etc.
       
      
      

      Attachments

        Activity

          People

            chris.hyzer@at.internet2.edu Chris Hyzer (upenn.edu)
            chad.redman@at.internet2.edu Chad Redman (unc.edu)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Smart Checklist