Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d1a48733
Commit
d1a48733
authored
Apr 06, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
6b13acfc
7f3d4adf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
JarURLConnection.java
...org/springframework/boot/loader/jar/JarURLConnection.java
+11
-1
JarFileTests.java
...ava/org/springframework/boot/loader/jar/JarFileTests.java
+11
-1
No files found.
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java
View file @
d1a48733
...
...
@@ -59,6 +59,8 @@ class JarURLConnection extends java.net.JarURLConnection {
private
static
final
JarEntryName
EMPTY_JAR_ENTRY_NAME
=
new
JarEntryName
(
""
);
private
static
final
String
FILE_COLON_DOUBLE_SLASH
=
"file://"
;
private
static
ThreadLocal
<
Boolean
>
useFastExceptions
=
new
ThreadLocal
<
Boolean
>();
private
final
JarFile
jarFile
;
...
...
@@ -73,7 +75,8 @@ class JarURLConnection extends java.net.JarURLConnection {
// What we pass to super is ultimately ignored
super
(
EMPTY_JAR_URL
);
this
.
url
=
url
;
String
spec
=
url
.
getFile
().
substring
(
jarFile
.
getUrl
().
getFile
().
length
());
String
spec
=
getNormalizedFile
(
url
)
.
substring
(
jarFile
.
getUrl
().
getFile
().
length
());
int
separator
;
while
((
separator
=
spec
.
indexOf
(
SEPARATOR
))
>
0
)
{
jarFile
=
getNestedJarFile
(
jarFile
,
spec
.
substring
(
0
,
separator
));
...
...
@@ -83,6 +86,13 @@ class JarURLConnection extends java.net.JarURLConnection {
this
.
jarEntryName
=
getJarEntryName
(
spec
);
}
private
String
getNormalizedFile
(
URL
url
)
{
if
(!
url
.
getFile
().
startsWith
(
FILE_COLON_DOUBLE_SLASH
))
{
return
url
.
getFile
();
}
return
"file:"
+
url
.
getFile
().
substring
(
FILE_COLON_DOUBLE_SLASH
.
length
());
}
private
JarFile
getNestedJarFile
(
JarFile
jarFile
,
String
name
)
throws
IOException
{
JarEntry
jarEntry
=
jarFile
.
getJarEntry
(
name
);
if
(
jarEntry
==
null
)
{
...
...
spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java
View file @
d1a48733
...
...
@@ -313,8 +313,18 @@ public class JarFileTests {
@Test
public
void
createNonNestedUrlFromString
()
throws
Exception
{
nonNestedJarFileFromString
(
"jar:file:"
+
this
.
rootJarFile
.
getAbsolutePath
()
+
"!/2.dat"
);
}
@Test
public
void
createNonNestedUrlFromStringWithDoubleSlash
()
throws
Exception
{
nonNestedJarFileFromString
(
"jar:file://"
+
this
.
rootJarFile
.
getAbsolutePath
()
+
"!/2.dat"
);
}
private
void
nonNestedJarFileFromString
(
String
spec
)
throws
Exception
{
JarFile
.
registerUrlProtocolHandler
();
String
spec
=
"jar:"
+
this
.
rootJarFile
.
toURI
()
+
"!/2.dat"
;
URL
url
=
new
URL
(
spec
);
assertThat
(
url
.
toString
()).
isEqualTo
(
spec
);
InputStream
inputStream
=
url
.
openStream
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment