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
c7148800
Commit
c7148800
authored
Nov 23, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
2f57e188
655ab987
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-1
Handler.java
...ain/java/org/springframework/boot/loader/jar/Handler.java
+33
-1
HandlerTests.java
...ava/org/springframework/boot/loader/jar/HandlerTests.java
+17
-0
No files found.
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java
View file @
c7148800
...
...
@@ -196,6 +196,30 @@ public class Handler extends URLStreamHandler {
setURL
(
context
,
JAR_PROTOCOL
,
null
,
-
1
,
null
,
null
,
file
,
null
,
null
);
}
@Override
protected
int
hashCode
(
URL
u
)
{
int
result
=
0
;
String
protocol
=
u
.
getProtocol
();
if
(
protocol
!=
null
)
{
result
+=
protocol
.
hashCode
();
}
String
file
=
u
.
getFile
();
int
separatorIndex
=
file
.
indexOf
(
SEPARATOR
);
if
(
separatorIndex
==
-
1
)
{
return
result
+
file
.
hashCode
();
}
String
fileWithoutEntry
=
file
.
substring
(
0
,
separatorIndex
);
try
{
result
+=
new
URL
(
fileWithoutEntry
).
hashCode
();
}
catch
(
MalformedURLException
ex
)
{
result
+=
fileWithoutEntry
.
hashCode
();
}
String
entry
=
canonicalize
(
file
.
substring
(
separatorIndex
+
2
));
result
+=
entry
.
hashCode
();
return
result
;
}
@Override
protected
boolean
sameFile
(
URL
u1
,
URL
u2
)
{
if
(!
u1
.
getProtocol
().
equals
(
"jar"
)
||
!
u2
.
getProtocol
().
equals
(
"jar"
))
{
...
...
@@ -209,7 +233,11 @@ public class Handler extends URLStreamHandler {
String
nested1
=
u1
.
getFile
().
substring
(
separator1
+
SEPARATOR
.
length
());
String
nested2
=
u2
.
getFile
().
substring
(
separator2
+
SEPARATOR
.
length
());
if
(!
nested1
.
equals
(
nested2
))
{
return
false
;
String
canonical1
=
canonicalize
(
nested1
);
String
canonical2
=
canonicalize
(
nested2
);
if
(!
canonical1
.
equals
(
canonical2
))
{
return
false
;
}
}
String
root1
=
u1
.
getFile
().
substring
(
0
,
separator1
);
String
root2
=
u2
.
getFile
().
substring
(
0
,
separator2
);
...
...
@@ -222,6 +250,10 @@ public class Handler extends URLStreamHandler {
return
super
.
sameFile
(
u1
,
u2
);
}
private
String
canonicalize
(
String
path
)
{
return
path
.
replace
(
SEPARATOR
,
"/"
);
}
public
JarFile
getRootJarFileFromUrl
(
URL
url
)
throws
IOException
{
String
spec
=
url
.
getFile
();
int
separatorIndex
=
spec
.
indexOf
(
SEPARATOR
);
...
...
spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/HandlerTests.java
View file @
c7148800
...
...
@@ -119,6 +119,23 @@ public class HandlerTests {
new
URL
(
"jar:file:/the/path/to/the/first.jar!/content.txt"
))).
isTrue
();
}
@Test
public
void
sameFileReturnsTrueForUrlsThatReferenceSameFileViaNestedArchiveAndFromRootOfJar
()
throws
MalformedURLException
{
assertThat
(
this
.
handler
.
sameFile
(
new
URL
(
"jar:file:/test.jar!/BOOT-INF/classes!/foo.txt"
),
new
URL
(
"jar:file:/test.jar!/BOOT-INF/classes/foo.txt"
))).
isTrue
();
}
@Test
public
void
hashcodesAreEqualForUrlsThatReferenceSameFileViaNestedArchiveAndFromRootOfJar
()
throws
MalformedURLException
{
assertThat
(
this
.
handler
.
hashCode
(
new
URL
(
"jar:file:/test.jar!/BOOT-INF/classes!/foo.txt"
)))
.
isEqualTo
(
this
.
handler
.
hashCode
(
new
URL
(
"jar:file:/test.jar!/BOOT-INF/classes/foo.txt"
)));
}
private
URL
createUrl
(
String
file
)
throws
MalformedURLException
{
return
new
URL
(
"jar"
,
null
,
-
1
,
file
,
this
.
handler
);
}
...
...
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