Skip to content

Commit

Permalink
Merge branch 'master' into perf-optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
mPokornyETM committed Jan 17, 2024
2 parents 474b98d + 860f651 commit aff7649
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.model.AutoCompletionCandidates;
import hudson.model.Item;
Expand Down Expand Up @@ -32,24 +33,32 @@ public class LockStep extends Step implements Serializable {
private static final long serialVersionUID = -953609907239674360L;

@CheckForNull
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public String resource = null;

@CheckForNull
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public String label = null;

@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public int quantity = 0;

/** name of environment variable to store locked resources in */
@CheckForNull
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public String variable = null;

@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public boolean inversePrecedence = false;

@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public String resourceSelectStrategy = ResourceSelectStrategy.SEQUENTIAL.name();

@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public boolean skipIfLocked = false;

@CheckForNull
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public List<LockStepResource> extra = null;

// it should be LockStep() - without params. But keeping this for backward compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.Util;
import hudson.model.AbstractDescribableImpl;
Expand All @@ -28,8 +29,10 @@ public class LockStepResource extends AbstractDescribableImpl<LockStepResource>
public String resource = null;

@CheckForNull
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public String label = null;

@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility.")
public int quantity = 0;

LockStepResource(@Nullable String resource, @Nullable String label, int quantity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,13 @@ public AutoCompletionCandidates doAutoCompleteLabelName(

value = Util.fixEmptyAndTrim(value);

if (value != null) {
for (String l : LockableResourcesManager.get().getAllLabels()) if (l.startsWith(value)) c.add(l);
if (value == null) {
return c;
}
for (String l : LockableResourcesManager.get().getAllLabels()) {
if (l.startsWith(value)) {
c.add(l);
}
}

return c;
Expand All @@ -287,10 +292,13 @@ public static AutoCompletionCandidates doAutoCompleteResourceNames(

value = Util.fixEmptyAndTrim(value);

if (value != null) {
List<String> allNames = LockableResourcesManager.get().getAllResourcesNames();
for (String name : allNames) {
if (name.startsWith(value)) c.add(name);
if (value == null) {
return c;
}
List<String> allNames = LockableResourcesManager.get().getAllResourcesNames();
for (String name : allNames) {
if (name.startsWith(value)) {
c.add(name);
}
}

Expand Down

0 comments on commit aff7649

Please sign in to comment.