Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-4220

Manual Execution of Script Job Throws StackOverflowError

    Details

    • Type: Bug
    • Status: Done
    • Priority: Low
    • Resolution: Done
    • Affects Version/s: 5.6.14, 5.8.0, 6.3.0
    • Fix Version/s: 6.16.0
    • Component/s: Jobs
    • Labels:
    • Sprint:
      SR4J Sprint 89, SR4J Sprint 90
    • Critical Points:
      1.8

      Description

      The problem happens when the script has JQL searcher API in it:

      JIRA 7

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.issue.search.SearchProvider
      import com.atlassian.jira.jql.parser.JqlQueryParser
      import com.atlassian.jira.web.bean.PagerFilter
      
      def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
      def searchProvider = ComponentAccessor.getComponent(SearchProvider)
      def issueManager = ComponentAccessor.getIssueManager()
      def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
      
      // edit this query to suit
      def query = jqlQueryParser.parseQuery("project = AA")
      
      def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
      
      log.warn("Total issues: ${results.total}")
      
      results.getIssues().each { documentIssue ->
          log.warn(documentIssue.key)
      
          // if you need a mutable issue you can do:
          def issue = issueManager.getIssueObject(documentIssue.id)
      
          // do something to the issue...
          log.warn(issue.summary)
      }
      

      JIRA 8

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.jql.parser.JqlQueryParser
      import com.atlassian.jira.issue.search.SearchProvider
      import com.atlassian.jira.web.bean.PagerFilter
      import com.atlassian.jira.issue.search.SearchQuery
      import com.atlassian.jira.bc.issue.search.SearchService
      
      //FOr JIRA 8
      
      def searchService = ComponentAccessor.getComponent(SearchService.class)
      def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
      def issueManager = ComponentAccessor.getIssueManager()
      def user = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
      
      def query = jqlQueryParser.parseQuery("project = 'AA'")
      
      def searchQuery = SearchQuery.create(query,user)
      
      def results = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
      
      results.getResults().each {issue ->
          def issue_res = issueManager.getIssueObject(issue.id)
      
          log.warn (issue_res)
      }
      

      Steps to reproduce it

      1. Go to Jobs > add "custom scheduled job" and manually run the script above.
      2. Get StackOverflowError in the log:
        com.onresolve.scriptrunner.canned.jira.jobs.JiraCustomScheduledJob/preview [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: null
        java.lang.StackOverflowError
        	at java.lang.Exception.<init>(Exception.java:54)
        	at java.lang.RuntimeException.<init>(RuntimeException.java:51)
        	at groovy.lang.GroovyRuntimeException.<init>(GroovyRuntimeException.java:51)
        	at org.codehaus.groovy.runtime.InvokerInvocationException.<init>(InvokerInvocationException.java:33)
        	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:105)
        	at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)
        	at groovy.lang.PropertyValue.getValue(PropertyValue.java:42)
        	at org.codehaus.groovy.runtime.DefaultGroovyMethods.getProperties(DefaultGroovyMethods.java:474)
        	at groovy.json.JsonOutput.getObjectProperties(JsonOutput.java:338)
        	at groovy.json.JsonOutput.writeObject(JsonOutput.java:331)
        	at groovy.json.JsonOutput.writeIterator(JsonOutput.java:486)
        

      The problem doesn't happen when the job automated run or run in the script console.

        Attachments

          Activity

            People

            Assignee:
            twozniak Tomasz Wozniak
            Reporter:
            jloong John Chin Loong
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: