Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Stackloop exception while running SIL script

Sajitha September 19, 2018

customfieldId=10400 is SIL field and the code snippet is as follows:

//Get linked Issues

function Issue_check(string IssueSummary)
{
    number temp_flag=0;
for(string Issue in Issuelist){
    string[] fields = getIssueFields(Issue);
    if ((fields["issueType"] eq "Bug") && (fields["summary"] eq IssueSummary))
    {
        temp_flag=1;
    }
    }
    
return temp_flag;
}
if(LogDefect eq "Yes")
{
    for(number i=0;i<size(Singular_Questions);i++)
    {
        if(Singular_Questions[i] eq "No")
        {
        flag=Issue_check(IssueSummary1[i]);
        
        if(flag==1)
        {
          
        }
        else if(flag==0)
        {
            //count=RaiseDefect(IssueSummary1[i],Description_1[i]);
            
        }
        }
		
    }
//Setting the Log Defect to No
%key%.customfield_10200= "No";
}

return size(Issuelist);

 

Following  is the Exception thrown in jira log file:

com.keplerrominfo.jira.plugins.keplercf.silscriptcf.StackLoopException: Stack loop detected forparameters [customfieldId=10400, issueKey=STP-517] in stack: [[customfieldId=10400, issueKey=STP-517]]
at com.keplerrominfo.jira.plugins.keplercf.silscriptcf.SilScriptCFType.handleStackLoop(SilScriptCFType.java:157)
at com.keplerrominfo.jira.plugins.keplercf.silscriptcf.SilScriptCFType.getValueFromIssue(SilScriptCFType.java:118)
at com.atlassian.jira.issue.fields.ImmutableCustomField.getValue(ImmutableCustomField.java:350)
at com.keplerrominfo.jira.plugins.keplercf.silscriptcf.SilScriptCustomFieldIndexer.addDocumentFields(SilScriptCustomFieldIndexer.java:66)
at com.keplerrominfo.jira.plugins.keplercf.silscriptcf.SilScriptCustomFieldIndexer.addDocumentFieldsSearchable(SilScriptCustomFieldIndexer.java:53)
at com.atlassian.jira.issue.index.indexers.impl.AbstractCustomFieldIndexer.addIndex(AbstractCustomFieldIndexer.java:40)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory$Builder.add(DefaultIssueDocumentFactory.java:90)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory$Builder.addAll(DefaultIssueDocumentFactory.java:81)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory.apply(DefaultIssueDocumentFactory.java:51)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory.apply(DefaultIssueDocumentFactory.java:31)

 

The SIL field functionality is working as expected but its throwing exception in log file.

Can someone please suggest where exactly the code went wrong?

 

1 answer

1 accepted

1 vote
Answer accepted
Radu Dumitriu
Contributor
September 19, 2018

This usually happen when you have a field that has a script that changes something in the issue, then again some other CF must be re-evaluated, and this in turn triggers the re-evaluation of the script in the first SIL CF. makes sense ?

We detect such stuff (we're preventing an infinite loop here...) and just let you know that is not ok to do something like this, otherwise Atlassian will blame us for your code :)

Sajitha September 20, 2018

Thank you Radu . I understood its throwing an infinite loop exception .

The script is for autodefect logging and here in my script I am just checking whether the Log defect radio button is set to yes or not.

if(LogDefect eq "Yes")
{
    for(number i=0;i<size(Singular_Questions);i++)
    {
        if(Singular_Questions[i] eq "No")
        {
        flag=Issue_check(IssueSummary1[i]);
        
        if(flag==1)
        {
          
        }
        else if(flag==0)
        {
            //count=RaiseDefect(IssueSummary1[i],Description_1[i]);
            
        }
        }
  
    }
//Setting the Log Defect to No
%key%.customfield_10200= "No";
}   

 Thats the part which shows exception according to my understanding. I am unable to identify an infinite loop running in an if condition. Please Suggest.

Radu Dumitriu
Contributor
September 20, 2018

What's on customfield_10400 ? I think that one may hold the answer ....

Edit: ah, sorry. this above is the 10400. Look for the re-evaluations in those functions, maybe some issues also request the same value from the current one. BTW support is https://jira.cprime.io/

Sajitha September 24, 2018

Thanks Radu.....Found out that 

%key%.customfield_10200= "No";

Assigning the value to custom filed was throwing error.

customfield_10200 is a Radio button which has two options Yes and No.

Can you please let me know how to assign an option value to Radiobutton.

Radu Dumitriu
Contributor
September 24, 2018

Well. makes sense. You need to postpone that update, for example schedule that update with https://confluence.cprime.io/display/SIL/runJobIn ...

 

Notice: Spoilers ahead.

................................................

Another option would be the stuff I'm working on right now, which is called persistent variables. Basically, you will have the possibility to store issue-localized information by writing:

{code}

persistent string flag = "N";

//..... logic here switching the above flag from "N" to "Y"

{code}

Basically, the first time the interpreter will encounter the variable 'flag', it will initialize it and store it into the database. Each subsequent time you will access it, it will get the value from the database, and not the one from the script. This will allow you to get rid of such customfields like the one that you are using for flag flip above, effectively solving your problem more elegantly that you would expect :)

At this point, I'm sure you are sending your love to us, but if you want to test it as soon as it is ready, please create a ticket on the support portal, I will give you a snapshot hopefully this week.

Sajitha September 27, 2018

Thanks for the suggestion. But we cant go ahead with the first one.

As I have mentioned before this script is for autodefect logging and once inside the script we create a defect and then we capture all the raised defects in a string array. At the end of the script , linking the defect in the String Array one by one to current key(Story)

for(string linkdefect in Defectlist){
    
linkIssue(linkdefect,key, "Blocks");   
} 

Even this part is throwing the same Stack loop exception  which was raised while assigning value to a radio button.

%key%.customfield_10200= "No";

  

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events