Queue (mainly) style consistency
Removal of null check, while annotation + ecosystem search proves it's never occurring
Small code style
Cleanup of tab vs spaces
@@ -358,7 +358,6 @@ public class Queue extends ResourceController implements Saveable {
}
public void setLoadBalancer(@NonNull LoadBalancer loadBalancer) {
- if(loadBalancer==null) throw new IllegalArgumentException();
this.loadBalancer = loadBalancer.sanitize();
}
@@ -818,9 +817,10 @@ public class Queue extends ResourceController implements Saveable {
}
private List<Item> checkPermissionsAndAddToList(List<Item> r, Item t) {
- if (t.task instanceof hudson.security.AccessControlled) {
- if (((hudson.security.AccessControlled)t.task).hasPermission(hudson.model.Item.READ)
- || ((hudson.security.AccessControlled) t.task).hasPermission(hudson.security.Permission.READ)) {
+ if (t.task instanceof AccessControlled) {
+ AccessControlled taskAC = (AccessControlled) t.task;
+ if (taskAC.hasPermission(hudson.model.Item.READ)
+ || taskAC.hasPermission(hudson.security.Permission.READ)) {
r.add(t);
}
}
@@ -858,7 +858,9 @@ public class Queue extends ResourceController implements Saveable {
private List<StubItem> filterDiscoverableItemListBasedOnPermissions(List<StubItem> r, Item t) {
if (t.task instanceof hudson.model.Item) {
- if (!((hudson.model.Item)t.task).hasPermission(hudson.model.Item.READ) && ((hudson.model.Item)t.task).hasPermission(hudson.model.Item.DISCOVER)) {
+ hudson.model.Item taskAsItem = (hudson.model.Item) t.task;
+ if (!taskAsItem.hasPermission(hudson.model.Item.READ)
+ && taskAsItem.hasPermission(hudson.model.Item.DISCOVER)) {
r.add(new StubItem(new StubTask(t.task)));
}
}
@@ -1779,19 +1781,13 @@ public class Queue extends ResourceController implements Saveable {
LOGGER.log(Level.FINEST, "Creating flyweight task {0} for computer {1}",
new Object[]{p.task.getFullDisplayName(), c.getName()});
}
- return new Runnable() {
- @Override public void run() {
+ return () -> {
c.startFlyWeightTask(new WorkUnitContext(p).createWorkUnit(p.task));
makePending(p);
- }
};
}
- private static Hash<Node> NODE_HASH = new Hash<Node>() {
- public String hash(Node node) {
- return node.getNodeName();
- }
- };
+ private final static Hash<Node> NODE_HASH = Node::getNodeName;
private boolean makePending(BuildableItem p) {
// LOGGER.info("Making "+p.task+" pending"); // REMOVE
@@ -2297,12 +2293,10 @@ public class Queue extends ResourceController implements Saveable {
}
public String getDisplayName() {
- // TODO Auto-generated method stub
return null;
}
public String getSearchUrl() {
- // TODO Auto-generated method stub
return null;
}
@@ -2399,7 +2393,7 @@ public class Queue extends ResourceController implements Saveable {
@ExportedBean(defaultVisibility = 999)
public static class StubTask {
- private String name;
+ private final String name;
public StubTask(@NonNull Queue.Task base) {
this.name = base.getName();
