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

There seems to be a section of wrong logic in org.springframework.boot.loader.jar.Handler#captureJarContextUrl #31838

Closed
aoyvx opened this issue Jul 22, 2022 · 6 comments
Assignees
Labels
status: superseded An issue that has been superseded by another

Comments

@aoyvx
Copy link
Contributor

aoyvx commented Jul 22, 2022

Looking at the following code, handlers will never be null.

static void captureJarContextUrl() {
if (canResetCachedUrlHandlers()) {
String handlers = System.getProperty(PROTOCOL_HANDLER, "");
try {
System.clearProperty(PROTOCOL_HANDLER);
try {
resetCachedUrlHandlers();
jarContextUrl = new URL("jar:file:context.jar!/");
URLConnection connection = jarContextUrl.openConnection();
if (connection instanceof JarURLConnection) {
jarContextUrl = null;
}
}
catch (Exception ex) {
}
}
finally {
if (handlers == null) {
System.clearProperty(PROTOCOL_HANDLER);
}
else {
System.setProperty(PROTOCOL_HANDLER, handlers);
}
}
resetCachedUrlHandlers();
}
}

Therefore, whether the branch handlers==null can be deleted.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 22, 2022
@aoyvx
Copy link
Contributor Author

aoyvx commented Jul 22, 2022

If this behavior does not meet expectations, please assign the issue to me.

@philwebb
Copy link
Member

Good spot @aoyvx, I think we should be calling String handlers = System.getProperty(PROTOCOL_HANDLER); without the default value. I'll assign the issue to you. Thanks!

@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 26, 2022
@philwebb philwebb added this to the 2.6.x milestone Jul 26, 2022
@philwebb
Copy link
Member

Closing in favor of PR #31870. Thanks @aoyvx!

@philwebb philwebb added status: superseded An issue that has been superseded by another and removed type: bug A general bug labels Jul 26, 2022
@philwebb philwebb removed this from the 2.6.x milestone Jul 26, 2022
@aoyvx

This comment was marked as off-topic.

@snicoll

This comment was marked as resolved.

@aoyvx

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants