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

Confusing error message from GroovyScriptEngine

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.19, 3.0.15, 4.0.9
    • 4.0.10
    • GroovyScriptEngine
    • None

    Description

      When the GroovyScriptEngine can't find a file or receives a Malformed URL it writes out a message like this:

      groovy.util.ResourceException: Cannot open URL: file:/var/lib/jenkins/workspace/TheProject/web/src/main/webapp/WEB-INF/scripts/, DocumentETL.groovy
       

      The confusing part is the ", " inserted between the path and the filename.  The way it reads looks like there is an errant ", " in the full path sent to the URL.    No wonder it can't find it.  But, it turns out the exception processing logic is inserting that.   Here is the exert from the code:

      } catch (MalformedURLException e) {
          String message = "Malformed URL: " + root + ", " + resourceName;
          if (se == null) {
              se = new ResourceException(message);
          } else {
              se = new ResourceException(message, se);
          }
      } catch (IOException e1) {
          String message = "Cannot open URL: " + root + ", " + resourceName;
          groovyScriptConn = null;
          if (se == null) {
              se = new ResourceException(message);
          } else {
              se = new ResourceException(message, se);
          }
      }

      This will cause people to go searching for some errant command-space throughout their code while debugging issues like this because we are normally conditioned to see the full path that the system is attempting to load.  The phrase before insinuates the full URL is next.  As opposed to a segmented version of it.  The will cause people to overlook what is really the error because it's such an aberrant message.

      Using the `scriptUrl` in the message would make more sense when IOException was thrown: 

      String message = "Cannot open URL: " + scriptUrl;
      

      For the malformed exception it might be tricky to reconstruct the full URL, but it should be made more clear like:

      String message = "Malformed URL: with context=" + root + " and spec=" + resourceName + " because " + e.getMessage();

      Some way to delimit the parts of the URL if you can't create the full context.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              chubbard Charlie Hubbard
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: