FlowNode.addOrReplaceAction breaks due to java.lang.UnsupportedOperationException

16 views
Skip to first unread message

Ullrich Hafner

unread,
Jan 8, 2021, 12:12:05 PM1/8/21
to Jenkins Developers
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.


Devin Nusbaum

unread,
Jan 8, 2021, 1:20:12 PM1/8/21
to Jenkins Developers
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

--
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 jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/DD7EB1C3-B0BE-4BC8-89AA-4A54DDB20980%40gmail.com.

Reply all
Reply to author
Forward
0 new messages