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
6b3eede5
Commit
6b3eede5
authored
Oct 26, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.4.x' into 1.5.x
parents
97b68b3f
6a68c8f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
11 deletions
+41
-11
Handler.java
...ain/java/org/springframework/boot/loader/jar/Handler.java
+11
-11
HandlerTests.java
...ava/org/springframework/boot/loader/jar/HandlerTests.java
+30
-0
No files found.
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java
View file @
6b3eede5
...
...
@@ -198,23 +198,23 @@ public class Handler extends URLStreamHandler {
@Override
protected
boolean
sameFile
(
URL
u1
,
URL
u2
)
{
if
(!
u1
.
getProtocol
().
equals
(
"jar"
)
||
u2
.
getProtocol
().
equals
(
"jar"
))
{
return
super
.
sameFile
(
u1
,
u2
)
;
if
(!
u1
.
getProtocol
().
equals
(
"jar"
)
||
!
u2
.
getProtocol
().
equals
(
"jar"
))
{
return
false
;
}
int
separator1
=
u1
.
getFile
().
indexOf
(
SEPARATOR
);
int
separator2
=
u
1
.
getFile
().
indexOf
(
SEPARATOR
);
if
(
separator1
<
0
||
separator2
<
0
)
{
int
separator2
=
u
2
.
getFile
().
indexOf
(
SEPARATOR
);
if
(
separator1
==
-
1
||
separator2
==
-
1
)
{
return
super
.
sameFile
(
u1
,
u2
);
}
String
root
1
=
u1
.
getFile
().
substring
(
separator1
+
SEPARATOR
.
length
());
String
root
2
=
u2
.
getFile
().
substring
(
separator2
+
SEPARATOR
.
length
());
if
(!
root1
.
equals
(
root
2
))
{
return
super
.
sameFile
(
u1
,
u2
)
;
String
nested
1
=
u1
.
getFile
().
substring
(
separator1
+
SEPARATOR
.
length
());
String
nested
2
=
u2
.
getFile
().
substring
(
separator2
+
SEPARATOR
.
length
());
if
(!
nested1
.
equals
(
nested
2
))
{
return
false
;
}
String
nested
1
=
u1
.
getFile
().
substring
(
0
,
separator1
);
String
nested2
=
u1
.
getFile
().
substring
(
0
,
separator2
);
String
root
1
=
u1
.
getFile
().
substring
(
0
,
separator1
);
String
root2
=
u2
.
getFile
().
substring
(
0
,
separator2
);
try
{
return
super
.
sameFile
(
new
URL
(
nested1
),
new
URL
(
nested
2
));
return
super
.
sameFile
(
new
URL
(
root1
),
new
URL
(
root
2
));
}
catch
(
MalformedURLException
ex
)
{
// Continue
...
...
spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/HandlerTests.java
View file @
6b3eede5
...
...
@@ -89,6 +89,36 @@ public class HandlerTests {
.
isEqualTo
(
"jar:jar:file:/other.jar!/nested!/entry.txt"
);
}
@Test
public
void
sameFileReturnsFalseForUrlsWithDifferentProtocols
()
throws
MalformedURLException
{
assertThat
(
this
.
handler
.
sameFile
(
new
URL
(
"jar:file:foo.jar!/content.txt"
),
new
URL
(
"file:/foo.jar"
))).
isFalse
();
}
@Test
public
void
sameFileReturnsFalseForDifferentFileInSameJar
()
throws
MalformedURLException
{
assertThat
(
this
.
handler
.
sameFile
(
new
URL
(
"jar:file:foo.jar!/the/path/to/the/first/content.txt"
),
new
URL
(
"jar:file:/foo.jar!/content.txt"
))).
isFalse
();
}
@Test
public
void
sameFileReturnsFalseForSameFileInDifferentJars
()
throws
MalformedURLException
{
assertThat
(
this
.
handler
.
sameFile
(
new
URL
(
"jar:file:/the/path/to/the/first.jar!/content.txt"
),
new
URL
(
"jar:file:/second.jar!/content.txt"
))).
isFalse
();
}
@Test
public
void
sameFileReturnsTrueForSameFileInSameJar
()
throws
MalformedURLException
{
assertThat
(
this
.
handler
.
sameFile
(
new
URL
(
"jar:file:/the/path/to/the/first.jar!/content.txt"
),
new
URL
(
"jar:file:/the/path/to/the/first.jar!/content.txt"
))).
isTrue
();
}
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