mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Add caching to JarFile.getUrl()
Fixes gh-1178
This commit is contained in:
parent
200cd535c2
commit
35b26b52f2
@ -84,6 +84,8 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
|
||||
|
||||
private SoftReference<Manifest> manifest;
|
||||
|
||||
private URL url;
|
||||
|
||||
/**
|
||||
* Create a new {@link JarFile} backed by the specified file.
|
||||
* @param file the root jar file
|
||||
@ -417,9 +419,12 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public URL getUrl() throws MalformedURLException {
|
||||
Handler handler = new Handler(this);
|
||||
String file = this.rootFile.getFile().toURI() + this.pathFromRoot + "!/";
|
||||
return new URL("jar", "", -1, file, handler);
|
||||
if (this.url == null) {
|
||||
Handler handler = new Handler(this);
|
||||
String file = this.rootFile.getFile().toURI() + this.pathFromRoot + "!/";
|
||||
this.url = new URL("jar", "", -1, file, handler);
|
||||
}
|
||||
return this.url;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user