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
1fbd43bd
Commit
1fbd43bd
authored
Apr 15, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tolerate jar files with no manifest in ChangeableUrls
Closes gh-5704
parent
a2f482b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
ChangeableUrls.java
...springframework/boot/devtools/restart/ChangeableUrls.java
+15
-11
ChangeableUrlsTests.java
...gframework/boot/devtools/restart/ChangeableUrlsTests.java
+8
-1
No files found.
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java
View file @
1fbd43bd
...
@@ -119,19 +119,23 @@ final class ChangeableUrls implements Iterable<URL> {
...
@@ -119,19 +119,23 @@ final class ChangeableUrls implements Iterable<URL> {
}
}
private
static
List
<
URL
>
getUrlsFromClassPathAttribute
(
URL
base
,
Manifest
manifest
)
{
private
static
List
<
URL
>
getUrlsFromClassPathAttribute
(
URL
base
,
Manifest
manifest
)
{
List
<
URL
>
urls
=
new
ArrayList
<
URL
>();
if
(
manifest
==
null
)
{
return
Collections
.<
URL
>
emptyList
();
}
String
classPathAttribute
=
manifest
.
getMainAttributes
()
String
classPathAttribute
=
manifest
.
getMainAttributes
()
.
getValue
(
Attributes
.
Name
.
CLASS_PATH
);
.
getValue
(
Attributes
.
Name
.
CLASS_PATH
);
if
(
StringUtils
.
hasText
(
classPathAttribute
))
{
if
(!
StringUtils
.
hasText
(
classPathAttribute
))
{
for
(
String
entry
:
StringUtils
.
delimitedListToStringArray
(
classPathAttribute
,
return
Collections
.<
URL
>
emptyList
();
" "
))
{
}
try
{
List
<
URL
>
urls
=
new
ArrayList
<
URL
>();
urls
.
add
(
new
URL
(
base
,
entry
));
for
(
String
entry
:
StringUtils
.
delimitedListToStringArray
(
classPathAttribute
,
}
" "
))
{
catch
(
MalformedURLException
ex
)
{
try
{
throw
new
IllegalStateException
(
urls
.
add
(
new
URL
(
base
,
entry
));
"Class-Path attribute contains malformed URL"
,
ex
);
}
}
catch
(
MalformedURLException
ex
)
{
throw
new
IllegalStateException
(
"Class-Path attribute contains malformed URL"
,
ex
);
}
}
}
}
return
urls
;
return
urls
;
...
...
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java
View file @
1fbd43bd
...
@@ -24,6 +24,7 @@ import java.net.URLClassLoader;
...
@@ -24,6 +24,7 @@ import java.net.URLClassLoader;
import
java.util.jar.Attributes
;
import
java.util.jar.Attributes
;
import
java.util.jar.JarOutputStream
;
import
java.util.jar.JarOutputStream
;
import
java.util.jar.Manifest
;
import
java.util.jar.Manifest
;
import
java.util.zip.ZipOutputStream
;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -80,7 +81,7 @@ public class ChangeableUrlsTests {
...
@@ -80,7 +81,7 @@ public class ChangeableUrlsTests {
File
relative
=
this
.
temporaryFolder
.
newFolder
();
File
relative
=
this
.
temporaryFolder
.
newFolder
();
ChangeableUrls
urls
=
ChangeableUrls
.
fromUrlClassLoader
(
new
URLClassLoader
(
ChangeableUrls
urls
=
ChangeableUrls
.
fromUrlClassLoader
(
new
URLClassLoader
(
new
URL
[]
{
makeJarFileWithUrlsInManifestClassPath
(
projectCore
,
new
URL
[]
{
makeJarFileWithUrlsInManifestClassPath
(
projectCore
,
projectWeb
,
relative
.
getName
()
+
"/"
)
}));
projectWeb
,
relative
.
getName
()
+
"/"
)
,
makeJarFileWithNoManifest
()
}));
assertThat
(
urls
.
toList
(),
assertThat
(
urls
.
toList
(),
contains
(
projectCore
,
projectWeb
,
relative
.
toURI
().
toURL
()));
contains
(
projectCore
,
projectWeb
,
relative
.
toURI
().
toURL
()));
}
}
...
@@ -105,4 +106,10 @@ public class ChangeableUrlsTests {
...
@@ -105,4 +106,10 @@ public class ChangeableUrlsTests {
return
classpathJar
.
toURI
().
toURL
();
return
classpathJar
.
toURI
().
toURL
();
}
}
private
URL
makeJarFileWithNoManifest
()
throws
Exception
{
File
classpathJar
=
this
.
temporaryFolder
.
newFile
(
"no-manifest.jar"
);
new
ZipOutputStream
(
new
FileOutputStream
(
classpathJar
)).
close
();
return
classpathJar
.
toURI
().
toURL
();
}
}
}
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