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

PropertiesLauncher cannot load a resource in jar via URL #21575

Closed
jianshaow opened this issue May 26, 2020 · 3 comments
Closed

PropertiesLauncher cannot load a resource in jar via URL #21575

jianshaow opened this issue May 26, 2020 · 3 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@jianshaow
Copy link

Before, a spring boot application that used PropertiesLauncher (archived by spring boot maven plugin with ZIP layout) can load a resource via the url just like "jar:file:/var/lib/application.jar!/BOOT-INF/classes!/application.yml" returned by Application.class.getResource("/application.yml") .

Since upgrade to spring-boot v2.3.0, it doesn't work any more, dig in code, finding is:

In Launcher.java, The spring-boot url protocol handler is registered only if is exploded, and isExploded() return true by default.

	protected void launch(String[] args) throws Exception {
		if (!isExploded()) {
			JarFile.registerUrlProtocolHandler();
		}
		...
	}
	...
	protected boolean isExploded() {
		return true;
	}

and PropertiesLauncher inherit Launcher without overriding isExploded(), so the application fail to load in non-exploded mode.

Is that on purpose? Does not PropertiesLauncher support non-exploded mode in v2.3.0? Or maybe similar to ExecutableArchiveLauncher, PropertiesLauncher should override isExploded() and return true or false based on archive is exploded or not.

	@Override
	protected boolean isExploded() {
		return this.archive.isExploded();
	}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 26, 2020
@wilkinsona
Copy link
Member

@jianshaow Thanks for the report. I think this was an accidental change in behaviour. PropertiesLauncher should still support being run from an archive (non-exploded) in 2.3.

@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels May 26, 2020
@wilkinsona wilkinsona added this to the 2.3.1 milestone May 26, 2020
@philwebb philwebb changed the title PropertiesLauncher cannot load a resource in jar via URL since v2.3.0 PropertiesLauncher cannot load a resource in jar via URL Jun 6, 2020
@wilkinsona
Copy link
Member

loadResourceFromJarFile is failing on Windows as it appears to be leaving a file open, preventing it from being deleted.

@wilkinsona wilkinsona reopened this Jun 9, 2020
@philwebb philwebb self-assigned this Jun 11, 2020
philwebb added a commit that referenced this issue Jun 11, 2020
Refactor the internals of `PropertiesLauncher` so that opened jar files
are tracked and can be closed after a test completes.

See gh-21575
philwebb added a commit that referenced this issue Jun 11, 2020
Further attempt to fix Windows file issues.

See gh-21575
@philwebb
Copy link
Member

The Windows build is green again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants