Skip to content

Cleanup redundant null checks and fix encoding inconsistencies in core#26023

Closed
shbhmexe wants to merge 3 commits intojenkinsci:masterfrom
shbhmexe:fix/cleanup-redundant-checks-and-encoding
Closed

Cleanup redundant null checks and fix encoding inconsistencies in core#26023
shbhmexe wants to merge 3 commits intojenkinsci:masterfrom
shbhmexe:fix/cleanup-redundant-checks-and-encoding

Conversation

@shbhmexe
Copy link
Contributor

@shbhmexe shbhmexe commented Jan 1, 2026

Fixes (no issue, minor improvement)

Testing done

  • Automated tests: Ran TextFileTest in jenkins-core to ensure head() and fastTail() correctly handle UTF-8 data and remain compatible with existing test cases.
  • Logical verification: Confirmed that URL.openConnection() in Java is guaranteed to return a URLConnection or throw an IOException, making the removed null checks redundant as per JDK specification.
  • Code cleanup: Removed old TODOs and standardized encoding to UTF-8 across the TextFile utility.

Screenshots (UI changes only)

N/A

Proposed changelog entries

  • Cleanup redundant null checks and standardize encoding to UTF-8 in TextFile and validation utilities.

Proposed changelog category

/label internal

Proposed upgrade guidelines

N/A

Submitter checklist

  • The 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). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of Content Security Policy Plugin. In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@jenkinsci/core-pr-reviewers

- Remove redundant null checks for URLConnection as URL.openConnection() never returns null.
- Align TextFile.head() and TextFile.fastTail() to use UTF-8 consistently with the rest of the class.

Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
@daniel-beck
Copy link
Member

What's with the pointless line break changes? This PR should not change hundreds of lines.

@NotMyFault
Copy link
Member

While this is technically correct, your reasoning is flawed.

Logical verification: Confirmed that URL.openConnection() in Java is guaranteed to return a URLConnection or throw an IOException, making the removed null checks redundant as per JDK specification.

The code removed calls ProxyConfiguration#open as written one line above the if clause.

@MarkEWaite
Copy link
Contributor

Closing this pull request because the submitter has not responded in two weeks to requests for changes. The code does not compile, it includes unnecessary changes, and seems to assume that the reviewers will perform lots of extra work on behalf of the submitter.

@MarkEWaite MarkEWaite closed this Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants