diff --git a/pom.xml b/pom.xml
index 1570179b..e946361e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.jenkins-ci.plugins
plugin
- 4.88
+ 5.5
@@ -33,8 +33,9 @@
5.2.1
-SNAPSHOT
jenkinsci/priority-sorter-plugin
- 2.452
- ${jenkins.baseline}.4
+
+ 2.479
+ ${jenkins.baseline}.1
Max
Low
false
diff --git a/src/main/java/jenkins/advancedqueue/JobGroup.java b/src/main/java/jenkins/advancedqueue/JobGroup.java
index 15202053..4213c278 100644
--- a/src/main/java/jenkins/advancedqueue/JobGroup.java
+++ b/src/main/java/jenkins/advancedqueue/JobGroup.java
@@ -167,8 +167,8 @@ public int getPriority() {
@Deprecated
@CheckForNull
public String getView() {
- if (jobGroupStrategy instanceof ViewBasedJobInclusionStrategy) {
- return ((ViewBasedJobInclusionStrategy) jobGroupStrategy).getViewName();
+ if (jobGroupStrategy instanceof ViewBasedJobInclusionStrategy strategy) {
+ return strategy.getViewName();
}
return null;
}
diff --git a/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java b/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java
index fd56e1e9..bd38e637 100644
--- a/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java
+++ b/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java
@@ -40,6 +40,7 @@
import hudson.security.ACL;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
+import jakarta.servlet.ServletException;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
@@ -50,7 +51,6 @@
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import javax.servlet.ServletException;
import jenkins.advancedqueue.jobinclusion.JobInclusionStrategy;
import jenkins.advancedqueue.priority.PriorityStrategy;
import jenkins.model.GlobalConfiguration;
@@ -62,8 +62,8 @@
import org.jenkins.ui.icon.IconSpec;
import org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution;
import org.kohsuke.stapler.QueryParameter;
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.StaplerResponse;
+import org.kohsuke.stapler.StaplerRequest2;
+import org.kohsuke.stapler.StaplerResponse2;
/**
* @author Magnus Sandberg
@@ -165,7 +165,7 @@ public ListBoxModel getPriorities() {
return items;
}
- public void doPriorityConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
+ public void doPriorityConfigSubmit(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException {
jobGroups = new LinkedList();
id2jobGroup = new HashMap();
//
@@ -271,8 +271,8 @@ public JobGroup getJobGroup(@NonNull PriorityConfigurationCallback priorityCallb
}
private boolean isJobInView(Job, ?> job, View view) {
- if (view instanceof ViewGroup) {
- return isJobInViewGroup(job, (ViewGroup) view);
+ if (view instanceof ViewGroup group) {
+ return isJobInViewGroup(job, group);
} else {
return view.contains((TopLevelItem) job);
}
diff --git a/src/main/java/jenkins/advancedqueue/PriorityConfigurationPlaceholderTaskHelper.java b/src/main/java/jenkins/advancedqueue/PriorityConfigurationPlaceholderTaskHelper.java
index 73f23a78..6ebc00a8 100644
--- a/src/main/java/jenkins/advancedqueue/PriorityConfigurationPlaceholderTaskHelper.java
+++ b/src/main/java/jenkins/advancedqueue/PriorityConfigurationPlaceholderTaskHelper.java
@@ -25,8 +25,7 @@ PriorityConfigurationCallback getPriority(
@NonNull ExecutorStepExecution.PlaceholderTask task,
@NonNull PriorityConfigurationCallback priorityCallback) {
Queue.Task ownerTask = task.getOwnerTask();
- if (ownerTask instanceof Job, ?>) {
- Job, ?> job = (Job, ?>) ownerTask;
+ if (ownerTask instanceof Job, ?> job) {
ItemInfo itemInfo = QueueItemCache.get().getItem(job.getName());
if (itemInfo != null) {
priorityCallback.setPrioritySelection(itemInfo.getPriority());
diff --git a/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/FolderPropertyLoader.java b/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/FolderPropertyLoader.java
index 501fc9ce..ef78c3d4 100644
--- a/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/FolderPropertyLoader.java
+++ b/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/FolderPropertyLoader.java
@@ -44,14 +44,12 @@ public static String getJobGroupName(DecisionLogger decisionLogger, Job, ?> jo
ItemGroup> parent = job.getParent();
decisionLogger.addDecisionLog(2, "Checking for Cloudbees Folder inclusion ...");
while (parent != null) {
- if (parent instanceof AbstractFolder) {
- AbstractFolder folder = (AbstractFolder) parent;
+ if (parent instanceof AbstractFolder> folder) {
decisionLogger.addDecisionLog(3, "Evaluating Folder [" + folder.getFullName() + "] ...");
DescribableList, AbstractFolderPropertyDescriptor> properties =
folder.getProperties();
for (AbstractFolderProperty> property : properties) {
- if (property instanceof JobInclusionFolderProperty) {
- JobInclusionFolderProperty incProperty = (JobInclusionFolderProperty) property;
+ if (property instanceof JobInclusionFolderProperty incProperty) {
if (incProperty.isUseJobGroup()) {
String name = incProperty.getJobGroupName();
decisionLogger.addDecisionLog(4, "JobGroup is enabled, with JobGroup [" + name + "] ...");
@@ -60,8 +58,8 @@ public static String getJobGroupName(DecisionLogger decisionLogger, Job, ?> jo
}
}
}
- if (parent instanceof TopLevelItem) {
- parent = ((TopLevelItem) parent).getParent();
+ if (parent instanceof TopLevelItem item) {
+ parent = item.getParent();
} else {
parent = null;
}
diff --git a/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/PropertyBasedJobInclusionStrategy.java b/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/PropertyBasedJobInclusionStrategy.java
index cb3c6088..e4456565 100644
--- a/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/PropertyBasedJobInclusionStrategy.java
+++ b/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/PropertyBasedJobInclusionStrategy.java
@@ -125,8 +125,8 @@ public static ListBoxModel getPropertyBasesJobGroups() {
ListBoxModel strategies = new ListBoxModel();
for (JobGroup jobGroup : jobGroups) {
JobInclusionStrategy inclusionStrategy = jobGroup.getJobGroupStrategy();
- if (inclusionStrategy instanceof PropertyBasedJobInclusionStrategy) {
- strategies.add(((PropertyBasedJobInclusionStrategy) inclusionStrategy).getName());
+ if (inclusionStrategy instanceof PropertyBasedJobInclusionStrategy strategy) {
+ strategies.add(strategy.getName());
}
}
return strategies;
diff --git a/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/ViewBasedJobInclusionStrategy.java b/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/ViewBasedJobInclusionStrategy.java
index dd2e07cc..ee5ea50c 100644
--- a/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/ViewBasedJobInclusionStrategy.java
+++ b/src/main/java/jenkins/advancedqueue/jobinclusion/strategy/ViewBasedJobInclusionStrategy.java
@@ -68,8 +68,8 @@ public ListBoxModel getListViewItems() {
private void addViews(String parent, ListBoxModel items, Collection views) {
for (View view : views) {
items.add(parent + view.getDisplayName(), parent + view.getViewName());
- if (view instanceof ViewGroup) {
- addViews(parent + view.getDisplayName() + "/", items, ((ViewGroup) view).getViews());
+ if (view instanceof ViewGroup group) {
+ addViews(parent + view.getDisplayName() + "/", items, group.getViews());
}
}
}
@@ -203,8 +203,8 @@ private boolean isJobInView(Job, ?> job, View view) {
return true;
}
// Then try to iterate over the ViewGroup (Nested View)
- if (view instanceof ViewGroup) {
- return isJobInViewGroup(job, (ViewGroup) view);
+ if (view instanceof ViewGroup group) {
+ return isJobInViewGroup(job, group);
}
return false;
}
diff --git a/src/main/java/jenkins/advancedqueue/priority/strategy/JobPropertyStrategy.java b/src/main/java/jenkins/advancedqueue/priority/strategy/JobPropertyStrategy.java
index 252b8a50..1bba27f7 100644
--- a/src/main/java/jenkins/advancedqueue/priority/strategy/JobPropertyStrategy.java
+++ b/src/main/java/jenkins/advancedqueue/priority/strategy/JobPropertyStrategy.java
@@ -51,8 +51,7 @@ public JobPropertyStrategy() {}
@CheckForNull
private Integer getPriorityInternal(Queue.Item item) {
- if (item != null && item.task instanceof Job, ?>) {
- Job, ?> job = (Job, ?>) item.task;
+ if (item != null && item.task instanceof Job, ?> job) {
PriorityJobProperty priorityProperty = job.getProperty(PriorityJobProperty.class);
if (priorityProperty != null && priorityProperty.getUseJobPriority()) {
return priorityProperty.priority;
diff --git a/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java b/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java
index 3ceef741..26dafb0b 100644
--- a/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java
+++ b/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java
@@ -41,7 +41,7 @@
import jenkins.advancedqueue.priority.PriorityStrategy;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
-import org.kohsuke.stapler.StaplerRequest;
+import org.kohsuke.stapler.StaplerRequest2;
/**
* @author Magnus Sandberg
@@ -55,7 +55,7 @@ public class PriorityJobProperty extends JobProperty> {
public final int priority;
@Override
- public JobProperty> reconfigure(StaplerRequest req, JSONObject form) throws FormException {
+ public JobProperty> reconfigure(StaplerRequest2 req, JSONObject form) throws FormException {
return super.reconfigure(req, form);
}
diff --git a/src/main/java/jenkins/advancedqueue/sorter/AdvancedQueueSorter.java b/src/main/java/jenkins/advancedqueue/sorter/AdvancedQueueSorter.java
index dfe810cf..c07d2ac4 100644
--- a/src/main/java/jenkins/advancedqueue/sorter/AdvancedQueueSorter.java
+++ b/src/main/java/jenkins/advancedqueue/sorter/AdvancedQueueSorter.java
@@ -92,19 +92,21 @@ public void sortNotWaitingItems(List extends Queue.NotWaitingItem> items) {
//
if (items.size() > 0 && LOGGER.isLoggable(Level.FINER)) {
StringBuilder queueStr = new StringBuilder(items.get(0).getClass().getName());
- queueStr.append(" Queue:\n"
- + "+----------------------------------------------------------------------+\n"
- + "| Item Id | Job Name | Priority | Weight |\n"
- + "+----------------------------------------------------------------------+\n");
+ queueStr.append(
+ """
+ Queue:
+ +----------------------------------------------------------------------+
+ | Item Id | Job Name | Priority | Weight |
+ +----------------------------------------------------------------------+
+ """);
for (Queue.NotWaitingItem item : items) {
ItemInfo itemInfo = QueueItemCache.get().getItem(item.getId());
String jobName = itemInfo.getJobName();
if (jobName.length() > 21) {
jobName = jobName.substring(0, 9) + "..." + jobName.substring(jobName.length() - 9);
}
- queueStr.append(String.format(
- "| %10d | %20s | %8d | %20.5f |%n",
- item.getId(), jobName, itemInfo.getPriority(), itemInfo.getWeight()));
+ queueStr.append("| %10d | %20s | %8d | %20.5f |%n"
+ .formatted(item.getId(), jobName, itemInfo.getPriority(), itemInfo.getWeight()));
}
queueStr.append("+----------------------------------------------------------------------+");
LOGGER.log(Level.FINER, queueStr.toString());
diff --git a/src/main/java/jenkins/advancedqueue/sorter/ItemInfo.java b/src/main/java/jenkins/advancedqueue/sorter/ItemInfo.java
index fdc3a7e4..fc8f5c02 100644
--- a/src/main/java/jenkins/advancedqueue/sorter/ItemInfo.java
+++ b/src/main/java/jenkins/advancedqueue/sorter/ItemInfo.java
@@ -87,7 +87,7 @@ public PriorityConfigurationCallback setPrioritySelection(
}
public PriorityConfigurationCallback addDecisionLog(int indent, String log) {
- this.decisionLog.add(String.format("%" + ((indent + 1) * 2) + "s%s", "", log));
+ this.decisionLog.add(("%" + ((indent + 1) * 2) + "s%s").formatted("", log));
return this;
}
@@ -162,8 +162,7 @@ public int compareTo(ItemInfo o) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof ItemInfo) {
- ItemInfo itemInfo = (ItemInfo) obj;
+ if (obj instanceof ItemInfo itemInfo) {
return compareTo(itemInfo) == 0;
}
return false;
@@ -190,9 +189,8 @@ public String toString() {
if (priorityStrategy != null) {
reason = priorityStrategy.getDescriptor().getDisplayName();
}
- return String.format(
- "Id: %s, JobName: %s, jobGroupId: %s, reason: %s, priority: %s, weight: %s, status: %s",
- itemId, jobName, jobGroupId, reason, priority, weight, itemStatus);
+ return "Id: %s, JobName: %s, jobGroupId: %s, reason: %s, priority: %s, weight: %s, status: %s"
+ .formatted(itemId, jobName, jobGroupId, reason, priority, weight, itemStatus);
}
public String getDescisionLog() {
diff --git a/src/main/java/jenkins/advancedqueue/sorter/StartedJobItemCache.java b/src/main/java/jenkins/advancedqueue/sorter/StartedJobItemCache.java
index 8ec891e1..3a8c10de 100644
--- a/src/main/java/jenkins/advancedqueue/sorter/StartedJobItemCache.java
+++ b/src/main/java/jenkins/advancedqueue/sorter/StartedJobItemCache.java
@@ -127,8 +127,8 @@ private void maintainCache() {
final PendingItem pi = it.next();
final Executable e = pi.workUnit.getExecutable();
- if (e instanceof Run) {
- startedItems.put(new StartedItem(pi.itemInfo.getJobName(), ((Run, ?>) e).getNumber()), pi.itemInfo);
+ if (e instanceof Run, ?> run) {
+ startedItems.put(new StartedItem(pi.itemInfo.getJobName(), run.getNumber()), pi.itemInfo);
it.remove();
}
}
diff --git a/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java b/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java
index 40c4aa6a..8246561e 100644
--- a/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java
+++ b/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java
@@ -25,8 +25,8 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import hudson.util.ListBoxModel;
+import jakarta.servlet.ServletException;
import java.io.IOException;
-import javax.servlet.ServletException;
import jenkins.advancedqueue.PrioritySorterConfiguration;
import jenkins.advancedqueue.sorter.SorterStrategy;
import jenkins.advancedqueue.sorter.SorterStrategyDescriptor;
diff --git a/src/test/java/jenkins/advancedqueue/sorter/strategy/FQStrategyTest.java b/src/test/java/jenkins/advancedqueue/sorter/strategy/FQStrategyTest.java
index 148c204a..05f72fd2 100644
--- a/src/test/java/jenkins/advancedqueue/sorter/strategy/FQStrategyTest.java
+++ b/src/test/java/jenkins/advancedqueue/sorter/strategy/FQStrategyTest.java
@@ -27,7 +27,7 @@ private void assertIncreasingWeight(float initialWeight) {
for (int i = 0; i < 10; ++i) {
float newWeight = new FQStrategy().getWeightToUse(1, previousWeight);
Assert.assertTrue(
- String.format("New weight %s should be greater than previous weight %s", newWeight, previousWeight),
+ "New weight %s should be greater than previous weight %s".formatted(newWeight, previousWeight),
newWeight > previousWeight);
previousWeight = newWeight;
}
diff --git a/src/test/java/jenkins/advancedqueue/test/SubmitTest.java b/src/test/java/jenkins/advancedqueue/test/SubmitTest.java
index 65c7b7ee..3009b095 100644
--- a/src/test/java/jenkins/advancedqueue/test/SubmitTest.java
+++ b/src/test/java/jenkins/advancedqueue/test/SubmitTest.java
@@ -6,10 +6,10 @@
import static org.mockito.Mockito.when;
import com.google.common.base.Charsets;
+import jakarta.servlet.ServletException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
-import javax.servlet.ServletException;
import jenkins.advancedqueue.JobGroup;
import jenkins.advancedqueue.PriorityConfiguration;
import jenkins.advancedqueue.jobinclusion.strategy.ViewBasedJobInclusionStrategy;
@@ -20,8 +20,8 @@
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;
import org.kohsuke.stapler.MockStaplerRequest;
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.StaplerResponse;
+import org.kohsuke.stapler.StaplerRequest2;
+import org.kohsuke.stapler.StaplerResponse2;
public class SubmitTest {
@@ -33,8 +33,8 @@ public class SubmitTest {
public void shouldGeneratePriorityConfigurationUsingDataBoundConstructor() throws IOException, ServletException {
PriorityConfiguration priorityConfiguration =
(PriorityConfiguration) j.jenkins.getDescriptor(PriorityConfiguration.class);
- StaplerResponse staplerResponse = mock(StaplerResponse.class);
- StaplerRequest staplerRequest = new MockStaplerRequest.MockStaplerRequestBuilder(
+ StaplerResponse2 staplerResponse = mock(StaplerResponse2.class);
+ StaplerRequest2 staplerRequest = new MockStaplerRequest.MockStaplerRequestBuilder(
j, "advanced-build-queue/priorityConfigSubmit")
.build();
diff --git a/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java b/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java
index b94c9926..7f7b323a 100644
--- a/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java
+++ b/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java
@@ -26,11 +26,11 @@
import static org.mockito.Mockito.mock;
import edu.umd.cs.findbugs.annotations.NonNull;
+import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
import org.jvnet.hudson.test.JenkinsRule;
public class MockStaplerRequest {
@@ -63,14 +63,14 @@ public MockStaplerRequestBuilder withAncestor(AncestorImpl ancestor) {
return this;
}
- public StaplerRequest build() throws AssertionError {
+ public StaplerRequest2 build() throws AssertionError {
HttpServletRequest rawRequest = mock(HttpServletRequest.class);
return new RequestImpl(stapler != null ? stapler : getStapler(), rawRequest, ancestors, tokens);
}
private Stapler getStapler() {
final Stapler stapler = new Stapler();
- stapler.setWebApp(new WebApp(r.jenkins.servletContext));
+ stapler.setWebApp(new WebApp(r.jenkins.getServletContext()));
return stapler;
}
}