-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate ConcurrentModificationException on plugin load (Jenkins sta…
…rtup) (#586)
- Loading branch information
1 parent
4e62e7f
commit a3dd45e
Showing
6 changed files
with
290 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import com.infradna.tool.bridge_method_injector.WithBridgeMethods; | ||
import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import edu.umd.cs.findbugs.annotations.Nullable; | ||
import groovy.lang.Binding; | ||
import hudson.Extension; | ||
import hudson.Util; | ||
|
@@ -130,7 +131,7 @@ public LockableResource(String name, String description, String labels, String r | |
} | ||
|
||
@DataBoundConstructor | ||
public LockableResource(String name) { | ||
public LockableResource(@CheckForNull String name) { | ||
this.name = Util.fixNull(name); | ||
// todo throw exception, when the name is empty | ||
// todo check if the name contains only valid characters (no spaces, new lines ...) | ||
|
@@ -185,7 +186,7 @@ public String getDescription() { | |
} | ||
|
||
@DataBoundSetter | ||
public void setDescription(String description) { | ||
public void setDescription(@Nullable String description) { | ||
this.description = Util.fixNull(description); | ||
} | ||
|
||
|
@@ -195,7 +196,7 @@ public String getNote() { | |
} | ||
|
||
@DataBoundSetter | ||
public void setNote(String note) { | ||
public void setNote(@Nullable String note) { | ||
this.note = Util.fixNull(note); | ||
} | ||
|
||
|
@@ -230,7 +231,8 @@ public String getLabels() { | |
*/ | ||
// @Deprecated can not be used, because of JCaC | ||
@DataBoundSetter | ||
public void setLabels(String labels) { | ||
public void setLabels(@Nullable String labels) { | ||
Check warning on line 234 in src/main/java/org/jenkins/plugins/lockableresources/LockableResource.java ci.jenkins.io / Java Compilercompiler:compile
|
||
labels = Util.fixNull(labels); | ||
// todo use label parser from Jenkins.Label to allow the same syntax | ||
this.labelsAsList = new ArrayList<>(); | ||
for (String label : labels.split("\\s+")) { | ||
|
@@ -258,7 +260,7 @@ public List<String> getLabelsAsList() { | |
* @return {@code true} if this resource contains the label. | ||
*/ | ||
@Exported | ||
public boolean hasLabel(String labelToFind) { | ||
public boolean hasLabel(@CheckForNull String labelToFind) { | ||
return this.labelsContain(labelToFind); | ||
} | ||
|
||
|
@@ -278,8 +280,9 @@ public boolean isValidLabel(String candidate, Map<String, Object> params) { | |
* https://www.jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#node-allocate-node). | ||
* Valid means that the resource contains the label or the Label-expression matched. | ||
*/ | ||
public boolean isValidLabel(String candidate) { | ||
if (candidate == null || candidate.isEmpty()) { | ||
public boolean isValidLabel(@Nullable String candidate) { | ||
candidate = Util.fixEmptyAndTrim(Util.fixNull(candidate)); | ||
if (candidate == null) { | ||
return false; | ||
} | ||
|
||
|
@@ -313,7 +316,7 @@ public List<LockableResourceProperty> getProperties() { | |
} | ||
|
||
@DataBoundSetter | ||
public void setProperties(List<LockableResourceProperty> properties) { | ||
public void setProperties(@Nullable List<LockableResourceProperty> properties) { | ||
this.properties = (properties == null ? new ArrayList<>() : properties); | ||
} | ||
|
||
|
@@ -359,7 +362,7 @@ public Date getReservedTimestamp() { | |
} | ||
|
||
@DataBoundSetter | ||
public void setReservedTimestamp(final Date reservedTimestamp) { | ||
public void setReservedTimestamp(@Nullable final Date reservedTimestamp) { | ||
this.reservedTimestamp = reservedTimestamp == null ? null : new Date(reservedTimestamp.getTime()); | ||
} | ||
|
||
|
@@ -495,7 +498,7 @@ public String getBuildName() { | |
else return null; | ||
} | ||
|
||
public void setBuild(Run<?, ?> lockedBy) { | ||
public void setBuild(@Nullable Run<?, ?> lockedBy) { | ||
this.build = lockedBy; | ||
if (lockedBy != null) { | ||
this.buildExternalizableId = lockedBy.getExternalizableId(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.