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
fce17ca6
Commit
fce17ca6
authored
Nov 18, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
0072a939
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
39 deletions
+46
-39
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+2
-2
ClassLoaderFilesResourcePatternResolver.java
...ools/restart/ClassLoaderFilesResourcePatternResolver.java
+33
-33
Restarter.java
.../org/springframework/boot/devtools/restart/Restarter.java
+6
-2
ClassLoaderFileURLStreamHandler.java
.../restart/classloader/ClassLoaderFileURLStreamHandler.java
+1
-0
DevToolsIntegrationTests.java
...amework/boot/devtools/tests/DevToolsIntegrationTests.java
+4
-2
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
fce17ca6
...
...
@@ -964,8 +964,8 @@ public class ServerProperties
private
boolean
renameOnRotate
;
/**
* Set request attributes for IP address, Hostname, protocol and port used
*
for
the request.
* Set request attributes for IP address, Hostname, protocol and port used
for
* the request.
*/
private
boolean
requestAttributesEnabled
;
...
...
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolver.java
View file @
fce17ca6
...
...
@@ -21,12 +21,8 @@ import java.io.InputStream;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.springframework.boot.devtools.restart.classloader.ClassLoaderFile
;
import
org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kind
;
...
...
@@ -48,9 +44,8 @@ import org.springframework.util.AntPathMatcher;
*/
final
class
ClassLoaderFilesResourcePatternResolver
implements
ResourcePatternResolver
{
private
static
final
Set
<
String
>
LOCATION_PATTERN_PREFIXES
=
Collections
.
unmodifiableSet
(
new
HashSet
<
String
>(
Arrays
.
asList
(
CLASSPATH_ALL_URL_PREFIX
,
CLASSPATH_URL_PREFIX
)));
private
static
final
String
[]
LOCATION_PATTERN_PREFIXES
=
{
CLASSPATH_ALL_URL_PREFIX
,
CLASSPATH_URL_PREFIX
};
private
final
ResourcePatternResolver
delegate
=
new
PathMatchingResourcePatternResolver
();
...
...
@@ -62,26 +57,26 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
this
.
classLoaderFiles
=
classLoaderFiles
;
}
@Override
public
ClassLoader
getClassLoader
()
{
return
this
.
delegate
.
getClassLoader
();
}
@Override
public
Resource
getResource
(
String
location
)
{
Resource
candidate
=
this
.
delegate
.
getResource
(
location
);
if
(
is
ExcludedResource
(
candidate
))
{
if
(
is
Deleted
(
candidate
))
{
return
new
DeletedClassLoaderFileResource
(
location
);
}
return
candidate
;
}
@Override
public
ClassLoader
getClassLoader
()
{
return
this
.
delegate
.
getClassLoader
();
}
@Override
public
Resource
[]
getResources
(
String
locationPattern
)
throws
IOException
{
List
<
Resource
>
resources
=
new
ArrayList
<
Resource
>();
Resource
[]
candidates
=
this
.
delegate
.
getResources
(
locationPattern
);
for
(
Resource
candidate
:
candidates
)
{
if
(!
is
ExcludedResource
(
candidate
))
{
if
(!
is
Deleted
(
candidate
))
{
resources
.
add
(
candidate
);
}
}
...
...
@@ -89,38 +84,43 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
return
resources
.
toArray
(
new
Resource
[
resources
.
size
()]);
}
private
String
trimLocationPattern
(
String
locationPattern
)
{
for
(
String
prefix
:
LOCATION_PATTERN_PREFIXES
)
{
if
(
locationPattern
.
startsWith
(
prefix
))
{
return
locationPattern
.
substring
(
prefix
.
length
());
}
}
return
locationPattern
;
}
private
List
<
Resource
>
getAdditionalResources
(
String
locationPattern
)
throws
MalformedURLException
{
List
<
Resource
>
additionalResources
=
new
ArrayList
<
Resource
>();
String
trimmedLocationPattern
=
trimLocationPattern
(
locationPattern
);
for
(
SourceFolder
sourceFolder
:
this
.
classLoaderFiles
.
getSourceFolders
())
{
for
(
Entry
<
String
,
ClassLoaderFile
>
entry
:
sourceFolder
.
getFilesEntrySet
())
{
if
(
entry
.
getValue
().
getKind
()
==
Kind
.
ADDED
&&
this
.
antPathMatcher
.
match
(
trimmedLocationPattern
,
entry
.
getKey
()))
{
additionalResources
.
add
(
new
UrlResource
(
new
URL
(
"reloaded"
,
null
,
-
1
,
"/"
+
entry
.
getKey
(),
new
ClassLoaderFileURLStreamHandler
(
entry
.
getValue
()))));
String
name
=
entry
.
getKey
();
ClassLoaderFile
file
=
entry
.
getValue
();
if
(
file
.
getKind
()
==
Kind
.
ADDED
&&
this
.
antPathMatcher
.
match
(
trimmedLocationPattern
,
name
))
{
URL
url
=
new
URL
(
"reloaded"
,
null
,
-
1
,
"/"
+
name
,
new
ClassLoaderFileURLStreamHandler
(
file
));
UrlResource
resource
=
new
UrlResource
(
url
);
additionalResources
.
add
(
resource
);
}
}
}
return
additionalResources
;
}
private
boolean
isExcludedResource
(
Resource
resource
)
{
private
String
trimLocationPattern
(
String
pattern
)
{
for
(
String
prefix
:
LOCATION_PATTERN_PREFIXES
)
{
if
(
pattern
.
startsWith
(
prefix
))
{
return
pattern
.
substring
(
prefix
.
length
());
}
}
return
pattern
;
}
private
boolean
isDeleted
(
Resource
resource
)
{
for
(
SourceFolder
sourceFolder
:
this
.
classLoaderFiles
.
getSourceFolders
())
{
for
(
Entry
<
String
,
ClassLoaderFile
>
entry
:
sourceFolder
.
getFilesEntrySet
())
{
try
{
if
(
entry
.
getValue
().
getKind
()
==
Kind
.
DELETED
&&
resource
.
exists
()
&&
resource
.
getURI
().
toString
().
endsWith
(
entry
.
getKey
()))
{
String
name
=
entry
.
getKey
();
ClassLoaderFile
file
=
entry
.
getValue
();
if
(
file
.
getKind
()
==
Kind
.
DELETED
&&
resource
.
exists
()
&&
resource
.
getURI
().
toString
().
endsWith
(
name
))
{
return
true
;
}
}
...
...
@@ -136,8 +136,6 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
/**
* A {@link Resource} that represents a {@link ClassLoaderFile} that has been
* {@link Kind#DELETED deleted}.
*
* @author Andy Wilkinson
*/
private
final
class
DeletedClassLoaderFileResource
extends
AbstractResource
{
...
...
@@ -161,5 +159,7 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
public
InputStream
getInputStream
()
throws
IOException
{
throw
new
IOException
(
this
.
name
+
" has been deleted"
);
}
}
}
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java
View file @
fce17ca6
...
...
@@ -420,12 +420,16 @@ public class Restarter {
return
;
}
if
(
applicationContext
instanceof
GenericApplicationContext
)
{
((
GenericApplicationContext
)
applicationContext
).
setResourceLoader
(
new
ClassLoaderFilesResourcePatternResolver
(
this
.
classLoaderFiles
));
prepare
((
GenericApplicationContext
)
applicationContext
);
}
this
.
rootContext
=
applicationContext
;
}
private
void
prepare
(
GenericApplicationContext
applicationContext
)
{
applicationContext
.
setResourceLoader
(
new
ClassLoaderFilesResourcePatternResolver
(
this
.
classLoaderFiles
));
}
private
LeakSafeThread
getLeakSafeThread
()
{
try
{
return
this
.
leakSafeThreads
.
takeFirst
();
...
...
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFileURLStreamHandler.java
View file @
fce17ca6
...
...
@@ -27,6 +27,7 @@ import java.net.URLStreamHandler;
* {@link URLStreamHandler} for the contents of a {@link ClassLoaderFile}.
*
* @author Phillip Webb
* @since 1.5.0
*/
public
class
ClassLoaderFileURLStreamHandler
extends
URLStreamHandler
{
...
...
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java
View file @
fce17ca6
...
...
@@ -146,8 +146,8 @@ public class DevToolsIntegrationTests {
}
Thread
.
sleep
(
100
);
}
int
port
=
Integer
.
valueOf
(
FileCopyUtils
.
copyToString
(
new
FileReader
(
this
.
serverPortFile
)
));
FileReader
portReader
=
new
FileReader
(
this
.
serverPortFile
);
int
port
=
Integer
.
valueOf
(
FileCopyUtils
.
copyToString
(
portReader
));
this
.
serverPortFile
.
delete
();
return
port
;
}
...
...
@@ -187,5 +187,7 @@ public class DevToolsIntegrationTests {
}
builder
.
make
().
saveIn
(
this
.
classesDirectory
);
}
}
}
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