diff --git a/changelog.html b/changelog.html
index 5ad81553a4bfa0e1f939697919adfb22a606a999..4134fc6440c84c56fc76f3c1709ef3bf7f241c80 100644
--- a/changelog.html
+++ b/changelog.html
@@ -55,6 +55,9 @@ Upcoming changes
+ -
+ Queue didn't always leave a trail for cancelled items properly
+ (issue 25314)
-
JNA update for deprecated JNA-POSIX library.
(issue 24527)
diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java
index da478515f448c5758468882688c68fbbb8342ec6..3b7247d5f9a9f73a27825aeb99b2aea463a35a9f 100644
--- a/core/src/main/java/hudson/model/Queue.java
+++ b/core/src/main/java/hudson/model/Queue.java
@@ -658,12 +658,7 @@ public class Queue extends ResourceController implements Saveable {
public synchronized boolean cancel(Item item) {
LOGGER.log(Level.FINE, "Cancelling {0} item#{1}", new Object[] {item.task, item.id});
- boolean r = item.cancel(this);
-
- LeftItem li = new LeftItem(item);
- li.enter(this);
-
- return r;
+ return item.cancel(this);
}
/**
@@ -1588,10 +1583,17 @@ public class Queue extends ResourceController implements Saveable {
/**
* Cancels this item, which updates {@link #future} to notify the listener, and
* also leaves the queue.
+ *
+ * @return true
+ * if the item was successfully cancelled.
*/
/*package*/ boolean cancel(Queue q) {
boolean r = leave(q);
- if (r) future.setAsCancelled();
+ if (r) {
+ future.setAsCancelled();
+ LeftItem li = new LeftItem(this);
+ li.enter(q);
+ }
return r;
}