-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Conversation
This reverts commit aeef4c1.
core/src/test/java/jenkins/org/apache/commons/validator/routines/DomainValidatorTest.java
Outdated
Show resolved
Hide resolved
Request @NotMyFault @Vlatombe @MarkEWaite @jglick for review and close the PR |
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.
looks ok, one question though
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.
Looks good so far, thanks for taking on the issue :)
core/src/main/java/jenkins/security/ResourceDomainConfiguration.java
Outdated
Show resolved
Hide resolved
local master branch to task
/label needs-more-reviews |
/label java |
@jtnord any feedback on the above changes made. |
@jtnord I have made changes based on the review. Re-request to have a look and ready PR for merge. |
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.
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.
dismissing previous approvaals as the code has moved on so much. (not asking for a review at this stage as it is not ready) |
@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. |
See JENKINS-72028.
Testing done
Proposed changelog entries
Proposed upgrade guidelines
N/A
Submitter checklist
Desired reviewers
@mention
Before the changes are marked as
ready-for-merge
:Maintainer checklist