-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Windows Server 2016
Jenkins: 2.204.5
Pipeline: 2.6
I'm attempting to make use of the native Java priority queue in a pipeline job by defining the following custom class
import java.lang.Comparable class PriorityClosure implements Comparable<PriorityClosure> { int priority Closure closure int compareTo(PriorityClosure o) { priority <=> o?.priority } PriorityClosure(priority, closure) { this.priority = priority this.closure = closure } }
and then attempting to run the following function
import java.util.PriorityQueue def someFunction() { def testQueue = new PriorityQueue<PriorityClosure>() for (int i = 0; i < 23; i++) { int staticIteratorReference = i testQueue.add(new PriorityClosure( staticIteratorReference, { println "this is a test" } )) } println "Test Queue is: ${testQueue}" }
I would expect to get a priority queue with all of my stuff in it, but instead, checking the output console, I receive the following:
[2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.564Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.580Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.580Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.580Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ [2020-03-30T23:13:51.580Z] expected to call java.util.PriorityQueue.add but wound up catching PriorityClosure.compareTo; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
and then a Queue that looks like this
[2020-03-30T23:13:51.580Z] [Pipeline] echo[2020-03-30T23:13:51.580Z] Test Queue is: [PriorityClosure@5ae890da, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
I realise that using the native PriorityQueue inside of a Jenkins job may be an incredibly niche use case. My attempts to google what exactly is going wrong here as well as this error has returned a net 0 results. Another weird thing I've noticed is that the first add seems to work fine. One item gets added to the PriorityQueue and every add after that suffers from the catching PriorityClosure.compareTo error.
Does anyone know what's going on here? I'm currently assuming this is a bug, but I realise this could also be a me problem.
I've done some digging, and I think this is related to:
https://issues.jenkins-ci.org/browse/JENKINS-44924
But I'm not entirely sure.