Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6857

JsonSlurper.parse with byte array throws stack overflow exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.2
    • 2.3.3
    • JSON
    • None
    • Patch

    Description

      A very simple example main shown below. Passing the same string into parseText works, parse with a byte array does not.

      The problem is line 111 of BaseJsonParser is recursively calling its self. rather than converting the byte array to a char array and then calling the parse method in JsonParserCharArray as all the other parse methods call.

       public static void main(String[] args) {
            String input = "{\"foo\":\"bar\", \"squiggles\":[{\"bob\":\"alice\"}]}";
            JsonSlurper slurper = new JsonSlurper();
            
            try {
               System.out.println("string parsing");
               slurper.parseText(input);
               System.out.println("byte parsing");
               slurper.parse(input.getBytes("utf-8"));
               System.out.println("done");
            } catch (Exception e) {
               e.printStackTrace();
            }
         }
      

      Will send pull request when I've got it building and tested.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            wselwood William Selwood
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: