Skip to content
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

[JENKINS-72028] deprecated URL instantiation applied #8515

Closed
wants to merge 32 commits into from

Conversation

abhishekmaity
Copy link
Contributor

@abhishekmaity abhishekmaity commented Sep 21, 2023

See JENKINS-72028.

Testing done

Proposed changelog entries

  • Entry 1: Issue, human-readable text

Proposed upgrade guidelines

N/A

Submitter checklist

Desired reviewers

@mention

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

Maintainer checklist

@abhishekmaity abhishekmaity changed the title JENKINS-72028 - deprecated URL instantiation applied [JENKINS-72028] deprecated URL instantiation applied Sep 21, 2023
@Vlatombe Vlatombe added the skip-changelog Should not be shown in the changelog label Sep 22, 2023
@abhishekmaity
Copy link
Contributor Author

abhishekmaity commented Sep 24, 2023

Request @NotMyFault @Vlatombe @MarkEWaite @jglick for review and close the PR

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

looks ok, one question though

core/src/main/java/hudson/Functions.java Outdated Show resolved Hide resolved
@timja timja requested a review from a team September 25, 2023 08:03
Copy link
Member

@NotMyFault NotMyFault left a comment

Choose a reason for hiding this comment

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

Looks good so far, thanks for taking on the issue :)

jtnord
jtnord previously requested changes Sep 25, 2023
core/src/main/java/hudson/PluginManager.java Outdated Show resolved Hide resolved
@timja timja dismissed jtnord’s stale review September 26, 2023 07:30

needs another look

@abhishekmaity
Copy link
Contributor Author

abhishekmaity commented Sep 28, 2023

/label needs-more-reviews

@comment-ops-bot comment-ops-bot bot added the needs-more-reviews Complex change, which would benefit from more eyes label Sep 28, 2023
@abhishekmaity
Copy link
Contributor Author

/label java

@comment-ops-bot comment-ops-bot bot added the java Pull requests that update Java code label Sep 28, 2023
@abhishekmaity
Copy link
Contributor Author

@jtnord any feedback on the above changes made.

cli/src/main/java/hudson/cli/SSHCLI.java Show resolved Hide resolved
cli/src/main/java/hudson/cli/SSHCLI.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/FilePath.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/Functions.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/Functions.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/PluginManager.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/TcpSlaveAgentListener.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/TcpSlaveAgentListener.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/model/UpdateCenter.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/model/UpdateCenter.java Outdated Show resolved Hide resolved
@abhishekmaity
Copy link
Contributor Author

@jtnord I have made changes based on the review. Re-request to have a look and ready PR for merge.

@abhishekmaity abhishekmaity requested a review from jtnord October 3, 2023 19:06
Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

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

There are many similar issues throughout the PR, I have been commenting on occurrences of the types of issue but not all the issues but this has seemingly caused confusion thinking they where only the issues.

So.


unless you are explicitly redacting/hiding information (which is not the case in this PR)

Do not write code like:

try {
  // something
catch (SomeException e) {
  throw new SomeException(....)
}

as it makes the code worse - especially when the code inside the try block is long and the exception could have been thrown on any one of a number of lines.

rather just keep the code as

// something

non internal code (ie anything protected or public) can not have its method signature changed. This includes adding a new Exception type to the declared throws that is not a subclass of an existing declared one.

e.g. if the method was

public void doSomething(String url) throws MalformedURLException {
 // something
 }

then you can not change it to

public void doSomething(String url) throws MalformedURLException, URISyntaxException {
 // something
 }

in this case and so that callers can react the same way to an "invalid URL" you should probably change the code so that it looks like

public void doSomething(String url) throws MalformedURLException {
  try {
    // something
  } catch (URISyntaxException e) {
    MalformedURLException mex = new MalformedURLException(e.getMessage());
    mex.initCause(e);
    throw mex;
  }
 }

Internal code can have its method changed without breaking plugins.

However if you change the signature to throw a URISyntaxException you need to ensure that every caller that calls the method handles a URISyntaxException in exactly the same way as if it had caught a MalformedURLException (if it has special handling for this);

As MalformedURLException is an IOException this may not be obvious.

You could handle the URISyntaxException differently, but this would need a case by case analysis and would generally only be applicable if the code was catching an IOException, but even in this case the code needs to take appropriate action.

@jtnord jtnord requested review from NotMyFault and timja October 4, 2023 09:56
@jtnord
Copy link
Member

jtnord commented Oct 4, 2023

dismissing previous approvaals as the code has moved on so much. (not asking for a review at this stage as it is not ready)

@abhishekmaity
Copy link
Contributor Author

abhishekmaity commented Oct 4, 2023

@jtnord @NotMyFault @timja I am closing this PR and will open a new PR a fresh based on the observation. Many thanks @jtnord for taking out time and highlighting the issues. Instead of a single PR, I am thinking to do the task via smaller PRs.

@abhishekmaity abhishekmaity deleted the task-1 branch October 4, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Pull requests that update Java code needs-more-reviews Complex change, which would benefit from more eyes skip-changelog Should not be shown in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants