FlowNode.addOrReplaceAction breaks due to java.lang.UnsupportedOperationException

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FlowNode.addOrReplaceAction breaks due to java.lang.UnsupportedOperationException

Ulli Hafner
Hi, 

I’m currently struggling with an exception in core that is caused by the following code [1] in my plugin. I am setting the result of a pipeline step if the quality gate fails:

flowNode.addOrReplaceAction(new WarningAction(result).withMessage(message));

This call sometimes fails in core with:

java.lang.UnsupportedOperationException
	at java.util.concurrent.CopyOnWriteArrayList$COWIterator.remove(CopyOnWriteArrayList.java:1182)
	at java.util.AbstractCollection.removeAll(AbstractCollection.java:376)
	at hudson.model.Actionable.addOrReplaceAction(Actionable.java:209)
	at io.jenkins.plugins.analysis.core.util.PipelineResultHandler.setResult(PipelineResultHandler.java:34)

Is this a bug in core or am I using the API in a not supported way? (This exception rarely occurs, however, at least 2 different people reported that problem recently[2]). The affected code is in core for quite some years now so I wonder why nobody has been hit by that problem before.


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/DD7EB1C3-B0BE-4BC8-89AA-4A54DDB20980%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: FlowNode.addOrReplaceAction breaks due to java.lang.UnsupportedOperationException

Devin Nusbaum
I think the problem is the implementation of FlowNode.getActions in workflow-api. The returned list probably needs to override the inherited implementation of `Collection.removeAll` for `Actionable.addOrReplaceAction` to work correctly.

From a quick read I think the existing code only has issues if there is already an action of the same type that needs to be replaced, which could explain why the issue is infrequent.

Devin

On Jan 8, 2021, at 12:11, Ullrich Hafner <[hidden email]> wrote:

Hi, 

I’m currently struggling with an exception in core that is caused by the following code [1] in my plugin. I am setting the result of a pipeline step if the quality gate fails:

flowNode.addOrReplaceAction(new WarningAction(result).withMessage(message));

This call sometimes fails in core with:

java.lang.UnsupportedOperationException
	at java.util.concurrent.CopyOnWriteArrayList$COWIterator.remove(CopyOnWriteArrayList.java:1182)
	at java.util.AbstractCollection.removeAll(AbstractCollection.java:376)
	at hudson.model.Actionable.addOrReplaceAction(Actionable.java:209)
	at io.jenkins.plugins.analysis.core.util.PipelineResultHandler.setResult(PipelineResultHandler.java:34)

Is this a bug in core or am I using the API in a not supported way? (This exception rarely occurs, however, at least 2 different people reported that problem recently[2]). The affected code is in core for quite some years now so I wonder why nobody has been hit by that problem before.



--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/DD7EB1C3-B0BE-4BC8-89AA-4A54DDB20980%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/64BFB279-E37D-4946-A1E9-9AE689161C8C%40cloudbees.com.