Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7113

Spring Groovy Beans cannot be debugged, because information about source file is lost during bean instantiation

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      GroovyScriptFactory class is stipping off file information while script class is instantiated:

      this.scriptClass = getGroovyClassLoader().parseClass(scriptSource.getScriptAsString(), scriptSource.suggestedClassName());

      This is a big problem because this code cannot be debugged after this!!!
      However File information can usually be extracted at least from "file:" locations(not sure about classpath

      My proposition is something like this:

      File scriptFile = null;
      if(scriptSource instanceof ResourceScriptSource) {
      Resource resource = ((ResourceScriptSource)scriptSource).getResource();
      if(resource instanceof UrlResource)

      { scriptFile = ((UrlResource)resource).getFile(); }

      }

      //
      if(scriptFile != null)

      { this.scriptClass = getGroovyClassLoader().parseClass(scriptFile); }

      else {
      this.scriptClass = getGroovyClassLoader().parseClass(scriptSource.getScriptAsString(), scriptSource.suggestedClassName());
      }

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              vladlv Vladislavs Korehovs
              Last updater:
              Juergen Hoeller
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 35 weeks, 4 days ago