Skip to content

Removes commons lang usage#693

Open
alecharp wants to merge 8 commits into
jenkinsci:masterfrom
alecharp:chore/remove-commons-lang-usage
Open

Removes commons lang usage#693
alecharp wants to merge 8 commits into
jenkinsci:masterfrom
alecharp:chore/remove-commons-lang-usage

Conversation

@alecharp

Copy link
Copy Markdown
Member

Superseed #691.

This removes entirely any usage of commons lang.
The API plugin is still a transitive dependency coming from ionicons-api and configuration-as-code dependencies. Excluding it from the latter is breaking the build.

Testing done

I ran mvn verify locally.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Comment thread src/main/java/hudson/plugins/active_directory/ActiveDirectoryDomain.java Outdated
protected UserDetails authenticate2(String username, String password) throws AuthenticationException {
// Check if the password length is less than 14 characters
if(FIPS140.useCompliantAlgorithms() && StringUtils.length(password) < 14) {
if(FIPS140.useCompliantAlgorithms() && password.length() < 14) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

null check?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think it can be null based on the call stack.

alecharp and others added 2 commits January 20, 2026 11:04
Thanks @mawinter69

Co-Authored-By: Markus Winter <m.winter@sap.com>
Thanks @mawinter69

Co-Authored-By: Markus Winter <m.winter@sap.com>
@alecharp

alecharp commented Jan 23, 2026

Copy link
Copy Markdown
Member Author

e7374e3 from #677

Closes #677

@alecharp
alecharp requested a review from mawinter69 January 23, 2026 09:58
@gbhat618

Copy link
Copy Markdown

just checked the build - failed test seems to be a flaky (?) build on windows has already passed.
the merge conflict is a one-liner easy one..

Perhaps @alecharp could resolve this merge conflict, there by causing a new commit - thus kicking off a new build.

If all good, maybe we can merge this PR. (I am looking to the commons-lang2 removal)

Comment thread src/main/java/hudson/plugins/active_directory/ActiveDirectoryDomain.java Outdated
Comment thread src/main/java/hudson/plugins/active_directory/ActiveDirectoryDomain.java Outdated
alecharp and others added 2 commits July 21, 2026 18:48
Co-authored-by: James Nord <jtnord@users.noreply.github.com>
Co-authored-by: Markus Winter <m.winter@sap.com>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

spotbugs failing the build here,

Redundant nullcheck of bindName, which is known to be non-null in hudson.plugins.active_directory.ActiveDirectoryDomain$DescriptorImpl.doValidateTest(String, String, String, String, String, TlsConfiguration, GroupLookupStrategy, boolean, boolean, boolean)

- Add null check for bindPassword before .length() in FIPS check
- Remove redundant null check on bindName in doValidateTest (already
  guarded by early return for null/blank bindName)
- Remove now-unused IOException import
this.name = name;
// Gives exception if Password is set lees than 14 chars long in FIPS mode.
if(FIPS140.useCompliantAlgorithms() && StringUtils.length(bindPassword) < 14) {
if(FIPS140.useCompliantAlgorithms() && (bindName == null || bindPassword == null || bindPassword.length() < 14)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if(FIPS140.useCompliantAlgorithms() && (bindName == null || bindPassword == null || bindPassword.length() < 14)) {
if(FIPS140.useCompliantAlgorithms() && (bindPassword == null || bindPassword.length() < 14)) {

I contemplated about keeping the bindName == null check and making it part of the IllegalArgumentException but instead of combining it with the password check perhaps better to put another check for it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

given that bindName is only then used with fixEmpty(bindName) in this constructor code (other methods have appropriate checks), there is no need to introduce the null check again.

the fixEmpty honors null, doesn't result in NPE.

Safe to accept the suggestion removing bindName == null in here.


String bindPassword_ = Secret.toString(bindPassword);
if(FIPS140.useCompliantAlgorithms() && StringUtils.length(bindPassword_) < 14) {
if(FIPS140.useCompliantAlgorithms() && bindPassword_.length() < 14) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if(FIPS140.useCompliantAlgorithms() && bindPassword_.length() < 14) {
if(FIPS140.useCompliantAlgorithms() && (bindPassword_ == null || bindPassword_.length() < 14)) {

returns 0 if null https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#length(java.lang.CharSequence).

@RequirePOST
public FormValidation doCheckBindPassword(@QueryParameter String bindPassword) {
if(FIPS140.useCompliantAlgorithms() && StringUtils.length(bindPassword) < 14) {
if(FIPS140.useCompliantAlgorithms() && bindPassword.length() < 14) {

@gbhat618 gbhat618 Jul 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if(FIPS140.useCompliantAlgorithms() && bindPassword.length() < 14) {
if(FIPS140.useCompliantAlgorithms() && (bindPassword == null || bindPassword.length() < 14)) {

null check required.

} catch (Exception e) {
return FormValidation.error(e, e.getMessage());
}
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this was a dead else block, when bindName == null the code wouldn't have reached here, instead returned at L354.

@gbhat618 gbhat618 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm with 2 minor comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants