Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48430

Provided config file is sometimes not complete

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Jenkins LTS 2.83.1
      Config File Provider Plugin 2.16.4
    • Similar Issues:

      Description

      Sometimes when I tried to parse JSON config file I encountered following exception:

      net.sf.json.JSONException: Found starting '{' but missing '}' at the end. at character 0 of null

      It turns out that returned file was not complete. I reproduced the issue this way:

      node {
        for (int i = 0; i < 40; i++) {
          configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) {
            readJSON(text: readFile(file: configfile))
          }
        }
      }

      Printing file content to console proves that it is readed to early. Adding file existance check helps:

      node {
        for (int i = 0; i < 40; i++) {
          configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) {
            if (fileExists(file: configfile)) {
              readJSON(text: readFile(file: configfile))
            } else {
              error("File '$configfile' not found")
            }
          }
        }
      }
      

        Attachments

          Issue Links

            Activity

            abeben Adam Beben created issue -
            abeben Adam Beben made changes -
            Field Original Value New Value
            Description Sometimes when I tried to parse JSON config file I encountered following exception:
            net.sf.json.JSONException: Found starting '\{' but missing '}' at the end. at character 0 of null
            It turns out that returned file was not complete. I reproduced the issue this way:
            {code:java}
            node('slave11') {
              for (int i = 0; i < 40; i++) {
                configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) {
                  readJSON(text: readFile(file: configfile))
                }
              }
            }{code}
            Printing file content to console proves that it is readed to early. Adding file existance check helps:
            {code:java}
            node('slave11') {
              for (int i = 0; i < 40; i++) {
                configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) {
                  if (fileExists(file: configfile)) {
                    readJSON(text: readFile(file: configfile))
                  } else {
                    error("File '$configfile' not found")
                  }
                }
              }
            }
            {code}
            Sometimes when I tried to parse JSON config file I encountered following exception:
            {code:java}
            net.sf.json.JSONException: Found starting '{' but missing '}' at the end. at character 0 of null{code}

             It turns out that returned file was not complete. I reproduced the issue this way:
            {code:java}
            node {
              for (int i = 0; i < 40; i++) {
                configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) {
                  readJSON(text: readFile(file: configfile))
                }
              }
            }{code}
            Printing file content to console proves that it is readed to early. Adding file existance check helps:
            {code:java}
            node {
              for (int i = 0; i < 40; i++) {
                configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) {
                  if (fileExists(file: configfile)) {
                    readJSON(text: readFile(file: configfile))
                  } else {
                    error("File '$configfile' not found")
                  }
                }
              }
            }
            {code}
            imod Dominik Bartholdi made changes -
            Link This issue is blocked by JENKINS-51750 [ JENKINS-51750 ]

              People

              • Assignee:
                domi Dominik Bartholdi
                Reporter:
                abeben Adam Beben
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: