Skip to content

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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

eva-mueller-coremedia
Copy link

@eva-mueller-coremedia eva-mueller-coremedia commented Jun 15, 2025

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

This makes no sense and cost only performance. It is definitely user (programer) failure.

and #619 highlights the if condition which has been introduced with #579.

@mPokornyETM responds to this in #619 (comment) with

When you remove the if statement, you will run into many side effects. You can trust me.
Anyway, I think it is user failure to call the function lock() with null or empty string.

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

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

  • The Jira / Github issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples).
    • The changelog generator for plugins uses the pull request title as the changelog entry.
    • Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during the upgrade.
  • There is automated testing

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There is at least one (1) approval for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically. See also release-drafter-labels.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • java code changes are tested by automated test.
    …thing.

@eva-mueller-coremedia eva-mueller-coremedia marked this pull request as ready for review June 15, 2025 12:48
@eva-mueller-coremedia eva-mueller-coremedia requested a review from a team as a code owner June 15, 2025 12:48
@mPokornyETM
Copy link
Contributor

@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.

@eva-mueller-coremedia
Copy link
Author

eva-mueller-coremedia commented Jun 16, 2025

@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.

Please check my comments.

Did you submit your review? Unfortunately, I do not see any comments

@eva-mueller-coremedia eva-mueller-coremedia marked this pull request as draft June 16, 2025 22:43
@eva-mueller-coremedia eva-mueller-coremedia force-pushed the re-allow-nothing branch 2 times, most recently from dd2e7e2 to 171c2a2 Compare June 17, 2025 06:16
@eva-mueller-coremedia eva-mueller-coremedia marked this pull request as ready for review June 17, 2025 06:40
@eva-mueller-coremedia
Copy link
Author

@mPokornyETM

Newly changes/improvements

  • Add configuration option to allow empty or null values - 565fd69
  • Improve trim spaces from label and resource name - 72a55ad

Unfortunately, I still cannot see your comments

@eva-mueller-coremedia
Copy link
Author

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?

@eva-mueller-coremedia eva-mueller-coremedia force-pushed the re-allow-nothing branch 2 times, most recently from 6e853d1 to d6ba2fa Compare June 24, 2025 14:57
Copy link
Contributor

@mPokornyETM mPokornyETM left a 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) {
Copy link
Contributor

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,

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.

@@ -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();
Copy link
Contributor

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?

Copy link
Author

@eva-mueller-coremedia eva-mueller-coremedia Jul 7, 2025

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

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.

@mPokornyETM mPokornyETM added bug java Pull requests that update Java code ui Features that may impact UI, pages made by the plugin or external UIs (BO, legacy, etc.) documentation test localization labels Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation java Pull requests that update Java code localization test ui Features that may impact UI, pages made by the plugin or external UIs (BO, legacy, etc.)
Projects
None yet
2 participants