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
47a56616
Commit
47a56616
authored
Apr 02, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
c9080647
ecfc8d73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
Restarter.java
.../org/springframework/boot/devtools/restart/Restarter.java
+32
-16
No files found.
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java
View file @
47a56616
...
...
@@ -330,17 +330,28 @@ public class Restarter {
private
void
cleanupKnownCaches
()
throws
Exception
{
// Whilst not strictly necessary it helps to cleanup soft reference caches
// early rather than waiting for memory limits to be reached
clear
(
ResolvableType
.
class
,
"cache"
);
clear
(
"org.springframework.core.SerializableTypeWrapper"
,
"cache"
);
ResolvableType
.
clearCache
();
cleanCachedIntrospectionResultsCache
();
ReflectionUtils
.
clearCache
();
clearAnnotationUtilsCache
();
if
(!
JavaVersion
.
getJavaVersion
().
isEqualOrNewerThan
(
JavaVersion
.
NINE
))
{
clear
(
"com.sun.naming.internal.ResourceManager"
,
"propertiesCache"
);
}
}
private
void
cleanCachedIntrospectionResultsCache
()
throws
Exception
{
clear
(
CachedIntrospectionResults
.
class
,
"acceptedClassLoaders"
);
clear
(
CachedIntrospectionResults
.
class
,
"strongClassCache"
);
clear
(
CachedIntrospectionResults
.
class
,
"softClassCache"
);
clear
(
ReflectionUtils
.
class
,
"declaredFieldsCache"
);
clear
(
ReflectionUtils
.
class
,
"declaredMethodsCache"
);
clear
(
AnnotationUtils
.
class
,
"findAnnotationCache"
);
clear
(
AnnotationUtils
.
class
,
"annotatedInterfaceCache"
);
if
(!
JavaVersion
.
getJavaVersion
().
isEqualOrNewerThan
(
JavaVersion
.
NINE
))
{
clear
(
"com.sun.naming.internal.ResourceManager"
,
"propertiesCache"
);
}
private
void
clearAnnotationUtilsCache
()
throws
Exception
{
try
{
AnnotationUtils
.
clearCache
();
}
catch
(
Throwable
ex
)
{
clear
(
AnnotationUtils
.
class
,
"findAnnotationCache"
);
clear
(
AnnotationUtils
.
class
,
"annotatedInterfaceCache"
);
}
}
...
...
@@ -354,14 +365,19 @@ public class Restarter {
}
private
void
clear
(
Class
<?>
type
,
String
fieldName
)
throws
Exception
{
Field
field
=
type
.
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
Object
instance
=
field
.
get
(
null
);
if
(
instance
instanceof
Set
)
{
((
Set
<?>)
instance
).
clear
();
}
if
(
instance
instanceof
Map
)
{
((
Map
<?,
?>)
instance
).
keySet
().
removeIf
(
this
::
isFromRestartClassLoader
);
try
{
Field
field
=
type
.
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
Object
instance
=
field
.
get
(
null
);
if
(
instance
instanceof
Set
)
{
((
Set
<?>)
instance
).
clear
();
}
if
(
instance
instanceof
Map
)
{
((
Map
<?,
?>)
instance
).
keySet
().
removeIf
(
this
::
isFromRestartClassLoader
);
}
}
catch
(
Exception
ex
)
{
this
.
logger
.
debug
(
"Unable to clear field "
+
type
+
" "
+
fieldName
,
ex
);
}
}
...
...
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