Problem in Jira vm

Hello
I have custom field that extends AbstractMultiCFType in java

In getVelocityParameters method I’m saving selectedFields in list
by doing the following:

//This is saved as global paramaters in the class
    private HashMap<Integer, String> selectedAoList= new HashMap<>();

            Object value = issue.getCustomFieldValue(field);
for (Ao activeObject: (List<Ao>) value) {
                    selectedAoList.put(activeObject.getID(), activeObject.getName());
                }

In the edit vm I’m selecting the values chosen in a select html

<select class="select cf-select" multiple="multiple" id="$customField.id" name="$customField.id:selectedValues">
    #foreach ($ao in $aoList)
            #set($aoValue= "$ao.getName()")
            <option value="$ao.getID()" 
                #if ($selectedAoList.keySet().contains($ao.getID()))
                    SELECTED
                #end
            >
                $aoValue
            </option>
        #end
</select>

However randomly sometimes selected values are rendered (wrongly) according to selected value of different issue.
So when 2 users are editing simultaneously 2 different issues, selected values of the first issue may appear into the second issue’s selected value
Can you assist on the above

Your variable for selectedAoList is defined at the class level, move it into the method level. The class is instantiated ONCE and then the method is called by different users. By defining your list at the class level, you’ve introduced at least a race condition.

2 Likes