-
Notifications
You must be signed in to change notification settings - Fork 193
Re-allow null / empty values for step params and always trim label and resource name #788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Re-allow null / empty values for step params and always trim label and resource name #788
Conversation
@eva-mueller-coremedia thx for contributing. Basically I am fine with the changes. Please check my comments. One more hint. Maybe we can allow this scenario with some property like 'allowEmpty' : true. |
Hi @mPokornyETM - sure, I can try to add this config property.
Did you submit your review? Unfortunately, I do not see any comments |
dd2e7e2
to
171c2a2
Compare
Hi @mPokornyETM - please consider this comment as friendly nudge. Would be great to get a review. Are you still on your own on this project? |
6e853d1
to
d6ba2fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -55,62 +55,74 @@ public boolean start() throws Exception { | |||
List<LockableResource> available = null; | |||
LinkedHashMap<String, List<LockableResourceProperty>> lockedResources = new LinkedHashMap<>(); | |||
LockableResourcesManager lrm = LockableResourcesManager.get(); | |||
synchronized (lrm.syncResources) { | |||
synchronized (LockableResourcesManager.syncResources) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you has changed to static call? I amn wondering, that this is not syntax failure,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I learned that accessing static members in Java by instance reference is considered as bad practice since static fields and methods belong to the class, not an instance. I.e., static fields or methods should be accessed via the class name.
src/main/java/org/jenkins/plugins/lockableresources/LockStepExecution.java
Show resolved
Hide resolved
src/main/java/org/jenkins/plugins/lockableresources/LockStepExecution.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jenkins/plugins/lockableresources/LockStepExecution.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jenkins/plugins/lockableresources/LockStepResource.java
Outdated
Show resolved
Hide resolved
@@ -57,18 +57,18 @@ | |||
public class LockableResourcesManager extends GlobalConfiguration { | |||
|
|||
/** Object to synchronized operations over LRM */ | |||
public static final transient Object syncResources = new Object(); | |||
public static final Object syncResources = new Object(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you change it to static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not change this to static
, I removed the transient
modifier since the transient
modifier is redundant for a static
field. Only instance fields are serialized.
@@ -364,7 +363,7 @@ private String getStack() { | |||
/** Checks if given resource exist. */ | |||
@NonNull | |||
@Restricted(NoExternalUse.class) | |||
public boolean resourceExist(@CheckForNull String resourceName) { | |||
public Boolean resourceExist(@CheckForNull String resourceName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because primitive type members like boolean
cannot be annotated with - for example - @NonNull
.
src/main/java/org/jenkins/plugins/lockableresources/LockableResourcesManager.java
Show resolved
Hide resolved
regex '[A-Z][A-Za-z\d]*Test(s|Case)?|Test[A-Z][A-Za-z\d]*|IT(.*)|(.*)IT(Case)?'
to provide a hint in case of an endless loop
since class 'LockedResourcesBuildAction' is not serializable
instead of build parameter since there is no control over the identity, visibility, or lifecycle of that object.
with the same value in case of a NPE.
d6ba2fa
to
85120a3
Compare
85120a3
to
3ecfe27
Compare
First of all, thank you for this great plugin.
This PR mainly aims to solve #615 and #619 by re-allowing empty resp.
null
values for the lock step.A breaking change has been introduced with #579 stateing
and #619 highlights the
if
condition which has been introduced with #579.@mPokornyETM responds to this in #619 (comment) with
See #619
Preamble
Feel free to reject this PR if you want to stick with failing on empty resp.
null
values for the lock step.I see the point to treat empty resp.
null
values as error but also understand that such a breaking change in a huge ecosystem of Jenkins pipelines is hard to handle. So PR can be some kind of smooth transition.If you reject & close this PR, it would be great if you could also close #619 and #615 with some kind of explanation. Thank you.
What has been done
null
values for the lock step (9b234ec)maven-surefire-plugin v3.5.3
executes them (https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#includes)This PR solves
Empty ressource is not allowed anymore
Fixes #619
Use of [] for extra to not lock is not working anymore with 1232.v512d6c434eb_d release
Fixes #615
Trim spaces from resource name, otherwise it will stuck
Fixes #612
Testing done
I added an additional test class
LockStepNothingTest.java
to verify that the changes work and extended some tests to ensure that trimming (#612) works as well.Submitter checklist
Maintainer checklist
Before the changes are marked as
ready-for-merge
:upgrade-guide-needed
label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).…thing.