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
f892363c
Commit
f892363c
authored
Apr 04, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
3ec50418
155d5509
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
ChangeableUrls.java
...springframework/boot/devtools/restart/ChangeableUrls.java
+14
-3
ChangeableUrlsTests.java
...gframework/boot/devtools/restart/ChangeableUrlsTests.java
+13
-9
No files found.
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java
View file @
f892363c
...
...
@@ -104,7 +104,7 @@ final class ChangeableUrls implements Iterable<URL> {
return
Collections
.<
URL
>
emptyList
();
}
try
{
return
getUrlsFrom
ClassPathAttribute
(
url
,
jarFile
.
getManifest
()
);
return
getUrlsFrom
ManifestClassPathAttribute
(
jarFile
);
}
catch
(
IOException
ex
)
{
throw
new
IllegalStateException
(
...
...
@@ -126,7 +126,9 @@ final class ChangeableUrls implements Iterable<URL> {
return
null
;
}
private
static
List
<
URL
>
getUrlsFromClassPathAttribute
(
URL
base
,
Manifest
manifest
)
{
private
static
List
<
URL
>
getUrlsFromManifestClassPathAttribute
(
JarFile
jarFile
)
throws
IOException
{
Manifest
manifest
=
jarFile
.
getManifest
();
if
(
manifest
==
null
)
{
return
Collections
.<
URL
>
emptyList
();
}
...
...
@@ -137,9 +139,18 @@ final class ChangeableUrls implements Iterable<URL> {
}
String
[]
entries
=
StringUtils
.
delimitedListToStringArray
(
classPath
,
" "
);
List
<
URL
>
urls
=
new
ArrayList
<>(
entries
.
length
);
File
parent
=
new
File
(
jarFile
.
getName
()).
getParentFile
();
for
(
String
entry
:
entries
)
{
try
{
urls
.
add
(
new
URL
(
base
,
entry
));
File
referenced
=
new
File
(
parent
,
entry
);
if
(
referenced
.
exists
())
{
urls
.
add
(
referenced
.
toURI
().
toURL
());
}
else
{
System
.
err
.
println
(
"Ignoring Class-Path entry "
+
entry
+
" found in"
+
jarFile
.
getName
()
+
" as "
+
referenced
+
" does not exist"
);
}
}
catch
(
MalformedURLException
ex
)
{
throw
new
IllegalStateException
(
...
...
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java
View file @
f892363c
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -74,15 +74,19 @@ public class ChangeableUrlsTests {
@Test
public
void
urlsFromJarClassPathAreConsidered
()
throws
Exception
{
URL
projectCore
=
makeUrl
(
"project-core"
);
URL
projectWeb
=
makeUrl
(
"project-web"
);
File
relative
=
this
.
temporaryFolder
.
newFolder
();
File
jarWithClassPath
=
makeJarFileWithUrlsInManifestClassPath
(
"project-core/target/classes/"
,
"project-web/target/classes/"
,
"does-not-exist/target/classes"
,
relative
.
getName
()
+
"/"
);
new
File
(
jarWithClassPath
.
getParentFile
(),
"project-core/target/classes"
)
.
mkdirs
();
new
File
(
jarWithClassPath
.
getParentFile
(),
"project-web/target/classes"
).
mkdirs
();
ChangeableUrls
urls
=
ChangeableUrls
.
fromUrlClassLoader
(
new
URLClassLoader
(
new
URL
[]
{
makeJarFileWithUrlsInManifestClassPath
(
projectCore
,
projectWeb
,
relative
.
getName
()
+
"/"
),
makeJarFileWithNoManifest
()
}));
assertThat
(
urls
.
toList
()).
containsExactly
(
projectCore
,
projectWeb
,
jarWithClassPath
.
toURI
().
toURL
(),
makeJarFileWithNoManifest
()
}));
assertThat
(
urls
.
toList
()).
containsExactly
(
new
URL
(
jarWithClassPath
.
toURI
().
toURL
(),
"project-core/target/classes/"
),
new
URL
(
jarWithClassPath
.
toURI
().
toURL
(),
"project-web/target/classes/"
)
,
relative
.
toURI
().
toURL
());
}
...
...
@@ -95,7 +99,7 @@ public class ChangeableUrlsTests {
return
file
.
toURI
().
toURL
();
}
private
URL
makeJarFileWithUrlsInManifestClassPath
(
Object
...
urls
)
throws
Exception
{
private
File
makeJarFileWithUrlsInManifestClassPath
(
Object
...
urls
)
throws
Exception
{
File
classpathJar
=
this
.
temporaryFolder
.
newFile
(
"classpath.jar"
);
Manifest
manifest
=
new
Manifest
();
manifest
.
getMainAttributes
().
putValue
(
Attributes
.
Name
.
MANIFEST_VERSION
.
toString
(),
...
...
@@ -103,7 +107,7 @@ public class ChangeableUrlsTests {
manifest
.
getMainAttributes
().
putValue
(
Attributes
.
Name
.
CLASS_PATH
.
toString
(),
StringUtils
.
arrayToDelimitedString
(
urls
,
" "
));
new
JarOutputStream
(
new
FileOutputStream
(
classpathJar
),
manifest
).
close
();
return
classpathJar
.
toURI
().
toURL
()
;
return
classpathJar
;
}
private
URL
makeJarFileWithNoManifest
()
throws
Exception
{
...
...
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