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
7d59b788
Commit
7d59b788
authored
Jun 17, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of jar files with + chars in their path
Closes gh-17208
parent
4894affb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
Handler.java
...ain/java/org/springframework/boot/loader/jar/Handler.java
+2
-3
HandlerTests.java
...ava/org/springframework/boot/loader/jar/HandlerTests.java
+28
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java
View file @
7d59b788
...
...
@@ -20,9 +20,9 @@ import java.io.File;
import
java.io.IOException
;
import
java.lang.ref.SoftReference
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLDecoder
;
import
java.net.URLStreamHandler
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -302,8 +302,7 @@ public class Handler extends URLStreamHandler {
if
(!
name
.
startsWith
(
FILE_PROTOCOL
))
{
throw
new
IllegalStateException
(
"Not a file URL"
);
}
String
path
=
name
.
substring
(
FILE_PROTOCOL
.
length
());
File
file
=
new
File
(
URLDecoder
.
decode
(
path
,
"UTF-8"
));
File
file
=
new
File
(
URI
.
create
(
name
));
Map
<
File
,
JarFile
>
cache
=
rootFileCache
.
get
();
JarFile
result
=
(
cache
!=
null
)
?
cache
.
get
(
file
)
:
null
;
if
(
result
==
null
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/HandlerTests.java
View file @
7d59b788
...
...
@@ -167,6 +167,34 @@ public class HandlerTests {
assertThat
(
jdkConnection
).
isNotInstanceOf
(
JarURLConnection
.
class
);
}
@Test
public
void
whenJarHasAPlusInItsPathConnectionJarFileMatchesOriginalJarFile
()
throws
Exception
{
File
testJar
=
this
.
temporaryFolder
.
newFile
(
"t+e+s+t.jar"
);
TestJarCreator
.
createTestJar
(
testJar
);
URL
url
=
new
URL
(
null
,
"jar:"
+
testJar
.
toURI
().
toURL
()
+
"!/nested.jar!/3.dat"
,
this
.
handler
);
JarURLConnection
connection
=
(
JarURLConnection
)
url
.
openConnection
();
try
{
assertThat
(
connection
.
getJarFile
().
getRootJarFile
().
getFile
()).
isEqualTo
(
testJar
);
}
finally
{
connection
.
getJarFile
().
close
();
}
}
@Test
public
void
whenJarHasASpaceInItsPathConnectionJarFileMatchesOriginalJarFile
()
throws
Exception
{
File
testJar
=
this
.
temporaryFolder
.
newFile
(
"t e s t.jar"
);
TestJarCreator
.
createTestJar
(
testJar
);
URL
url
=
new
URL
(
null
,
"jar:"
+
testJar
.
toURI
().
toURL
()
+
"!/nested.jar!/3.dat"
,
this
.
handler
);
JarURLConnection
connection
=
(
JarURLConnection
)
url
.
openConnection
();
try
{
assertThat
(
connection
.
getJarFile
().
getRootJarFile
().
getFile
()).
isEqualTo
(
testJar
);
}
finally
{
connection
.
getJarFile
().
close
();
}
}
private
void
assertStandardAndCustomHandlerUrlsAreEqual
(
String
context
,
String
spec
)
throws
MalformedURLException
{
URL
standardUrl
=
new
URL
(
new
URL
(
"jar:"
+
context
),
spec
);
URL
customHandlerUrl
=
new
URL
(
new
URL
(
"jar"
,
null
,
-
1
,
context
,
this
.
handler
),
spec
);
...
...
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