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
5b97981c
Commit
5b97981c
authored
Jun 21, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
9d194c2d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
44 deletions
+45
-44
HalBrowserMvcEndpoint.java
...work/boot/actuate/endpoint/mvc/HalBrowserMvcEndpoint.java
+4
-2
HalBrowserMvcEndpointManagementContextPathIntegrationTests.java
...wserMvcEndpointManagementContextPathIntegrationTests.java
+2
-1
HalBrowserMvcEndpointServerContextPathIntegrationTests.java
...lBrowserMvcEndpointServerContextPathIntegrationTests.java
+2
-2
IntegrationAutoConfiguration.java
...toconfigure/integration/IntegrationAutoConfiguration.java
+4
-2
SilentExitExceptionHandler.java
...ork/boot/devtools/restart/SilentExitExceptionHandler.java
+24
-27
SilentExitExceptionHandlerTests.java
...oot/devtools/restart/SilentExitExceptionHandlerTests.java
+2
-1
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+1
-1
SpringApplicationTests.java
...java/org/springframework/boot/SpringApplicationTests.java
+6
-8
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpoint.java
View file @
5b97981c
...
@@ -148,10 +148,12 @@ public class HalBrowserMvcEndpoint extends HalJsonMvcEndpoint
...
@@ -148,10 +148,12 @@ public class HalBrowserMvcEndpoint extends HalJsonMvcEndpoint
return
resource
;
return
resource
;
}
}
private
Resource
replaceInitialLink
(
String
contextPath
,
Resource
resource
)
throws
IOException
{
private
Resource
replaceInitialLink
(
String
contextPath
,
Resource
resource
)
throws
IOException
{
byte
[]
bytes
=
FileCopyUtils
.
copyToByteArray
(
resource
.
getInputStream
());
byte
[]
bytes
=
FileCopyUtils
.
copyToByteArray
(
resource
.
getInputStream
());
String
content
=
new
String
(
bytes
,
DEFAULT_CHARSET
);
String
content
=
new
String
(
bytes
,
DEFAULT_CHARSET
);
String
initial
=
contextPath
+
getManagementServletContext
().
getContextPath
()
+
getPath
();
String
initial
=
contextPath
+
getManagementServletContext
().
getContextPath
()
+
getPath
();
content
=
content
.
replace
(
"entryPoint: '/'"
,
"entryPoint: '"
+
initial
+
"'"
);
content
=
content
.
replace
(
"entryPoint: '/'"
,
"entryPoint: '"
+
initial
+
"'"
);
return
new
TransformedResource
(
resource
,
content
.
getBytes
(
DEFAULT_CHARSET
));
return
new
TransformedResource
(
resource
,
content
.
getBytes
(
DEFAULT_CHARSET
));
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointManagementContextPathIntegrationTests.java
View file @
5b97981c
...
@@ -92,7 +92,8 @@ public class HalBrowserMvcEndpointManagementContextPathIntegrationTests {
...
@@ -92,7 +92,8 @@ public class HalBrowserMvcEndpointManagementContextPathIntegrationTests {
@Test
@Test
public
void
actuatorBrowserHtml
()
throws
Exception
{
public
void
actuatorBrowserHtml
()
throws
Exception
{
this
.
mockMvc
.
perform
(
get
(
"/admin/browser.html"
).
accept
(
MediaType
.
APPLICATION_JSON
))
this
.
mockMvc
.
perform
(
get
(
"/admin/browser.html"
).
accept
(
MediaType
.
APPLICATION_JSON
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
containsString
(
"entryPoint: '/admin'"
)));
.
andExpect
(
content
().
string
(
containsString
(
"entryPoint: '/admin'"
)));
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java
View file @
5b97981c
...
@@ -90,8 +90,8 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
...
@@ -90,8 +90,8 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
this
.
port
+
"/spring/actuator/browser.html"
,
HttpMethod
.
GET
,
"http://localhost:"
+
this
.
port
+
"/spring/actuator/browser.html"
,
new
HttpEntity
<
Void
>(
null
,
headers
),
String
.
class
);
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
null
,
headers
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body: "
+
entity
.
getBody
(),
assertTrue
(
"Wrong body: "
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"entryPoint: '/spring/actuator'"
));
entity
.
getBody
().
contains
(
"entryPoint: '/spring/actuator'"
));
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java
View file @
5b97981c
...
@@ -64,7 +64,8 @@ public class IntegrationAutoConfiguration {
...
@@ -64,7 +64,8 @@ public class IntegrationAutoConfiguration {
@ConditionalOnClass
(
EnableIntegrationMBeanExport
.
class
)
@ConditionalOnClass
(
EnableIntegrationMBeanExport
.
class
)
@ConditionalOnMissingBean
(
value
=
IntegrationMBeanExporter
.
class
,
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnMissingBean
(
value
=
IntegrationMBeanExporter
.
class
,
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnProperty
(
prefix
=
"spring.jmx"
,
name
=
"enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
prefix
=
"spring.jmx"
,
name
=
"enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
protected
static
class
IntegrationJmxConfiguration
implements
EnvironmentAware
,
BeanFactoryAware
{
protected
static
class
IntegrationJmxConfiguration
implements
EnvironmentAware
,
BeanFactoryAware
{
private
BeanFactory
beanFactory
;
private
BeanFactory
beanFactory
;
...
@@ -81,7 +82,8 @@ public class IntegrationAutoConfiguration {
...
@@ -81,7 +82,8 @@ public class IntegrationAutoConfiguration {
@Override
@Override
public
void
setEnvironment
(
Environment
environment
)
{
public
void
setEnvironment
(
Environment
environment
)
{
this
.
propertyResolver
=
new
RelaxedPropertyResolver
(
environment
,
"spring.jmx."
);
this
.
propertyResolver
=
new
RelaxedPropertyResolver
(
environment
,
"spring.jmx."
);
}
}
@Bean
@Bean
...
...
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/SilentExitExceptionHandler.java
View file @
5b97981c
...
@@ -36,7 +36,7 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
...
@@ -36,7 +36,7 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
@Override
@Override
public
void
uncaughtException
(
Thread
thread
,
Throwable
exception
)
{
public
void
uncaughtException
(
Thread
thread
,
Throwable
exception
)
{
if
(
exception
instanceof
SilentExitException
)
{
if
(
exception
instanceof
SilentExitException
)
{
if
(
jvmWillExit
(
thread
))
{
if
(
isJvmExiting
(
thread
))
{
preventNonZeroExitCode
();
preventNonZeroExitCode
();
}
}
return
;
return
;
...
@@ -46,19 +46,7 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
...
@@ -46,19 +46,7 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
}
}
}
}
public
static
void
setup
(
Thread
thread
)
{
private
boolean
isJvmExiting
(
Thread
exceptionThread
)
{
UncaughtExceptionHandler
handler
=
thread
.
getUncaughtExceptionHandler
();
if
(!(
handler
instanceof
SilentExitExceptionHandler
))
{
handler
=
new
SilentExitExceptionHandler
(
handler
);
thread
.
setUncaughtExceptionHandler
(
handler
);
}
}
public
static
void
exitCurrentThread
()
{
throw
new
SilentExitException
();
}
private
boolean
jvmWillExit
(
Thread
exceptionThread
)
{
for
(
Thread
thread
:
getAllThreads
())
{
for
(
Thread
thread
:
getAllThreads
())
{
if
(
thread
!=
exceptionThread
&&
thread
.
isAlive
()
&&
!
thread
.
isDaemon
())
{
if
(
thread
!=
exceptionThread
&&
thread
.
isAlive
()
&&
!
thread
.
isDaemon
())
{
return
false
;
return
false
;
...
@@ -67,22 +55,15 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
...
@@ -67,22 +55,15 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
return
true
;
return
true
;
}
}
protected
void
preventNonZeroExitCode
()
{
System
.
exit
(
0
);
}
protected
Thread
[]
getAllThreads
()
{
protected
Thread
[]
getAllThreads
()
{
ThreadGroup
rootThreadGroup
=
getRootThreadGroup
();
ThreadGroup
rootThreadGroup
=
getRootThreadGroup
();
int
size
=
32
;
Thread
[]
threads
=
new
Thread
[
32
];
int
threadCount
;
int
count
=
rootThreadGroup
.
enumerate
(
threads
);
Thread
[]
threads
;
while
(
count
==
threads
.
length
)
{
do
{
threads
=
new
Thread
[
threads
.
length
*
2
];
size
*=
2
;
count
=
rootThreadGroup
.
enumerate
(
threads
);
threads
=
new
Thread
[
size
];
threadCount
=
rootThreadGroup
.
enumerate
(
threads
);
}
}
while
(
threadCount
==
threads
.
length
);
return
Arrays
.
copyOf
(
threads
,
count
);
return
Arrays
.
copyOf
(
threads
,
threadCount
);
}
}
private
ThreadGroup
getRootThreadGroup
()
{
private
ThreadGroup
getRootThreadGroup
()
{
...
@@ -93,6 +74,22 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
...
@@ -93,6 +74,22 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
return
candidate
;
return
candidate
;
}
}
protected
void
preventNonZeroExitCode
()
{
System
.
exit
(
0
);
}
public
static
void
setup
(
Thread
thread
)
{
UncaughtExceptionHandler
handler
=
thread
.
getUncaughtExceptionHandler
();
if
(!(
handler
instanceof
SilentExitExceptionHandler
))
{
handler
=
new
SilentExitExceptionHandler
(
handler
);
thread
.
setUncaughtExceptionHandler
(
handler
);
}
}
public
static
void
exitCurrentThread
()
{
throw
new
SilentExitException
();
}
private
static
class
SilentExitException
extends
RuntimeException
{
private
static
class
SilentExitException
extends
RuntimeException
{
}
}
...
...
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/SilentExitExceptionHandlerTests.java
View file @
5b97981c
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -30,6 +30,7 @@ import static org.junit.Assert.fail;
...
@@ -30,6 +30,7 @@ import static org.junit.Assert.fail;
* Tests for {@link SilentExitExceptionHandler}.
* Tests for {@link SilentExitExceptionHandler}.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
*/
*/
public
class
SilentExitExceptionHandlerTests
{
public
class
SilentExitExceptionHandlerTests
{
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
5b97981c
...
@@ -1972,7 +1972,7 @@ packaged as an executable archive), there are some limitations in the JSP suppor
...
@@ -1972,7 +1972,7 @@ packaged as an executable archive), there are some limitations in the JSP suppor
* Undertow does not support JSPs.
* Undertow does not support JSPs.
* Creating a custom `error.jsp` page won't override the default view for
* Creating a custom `error.jsp` page won't override the default view for
<<boot-features-error-handling,error handling>>.
<<boot-features-error-handling,error handling>>.
There is a {github-code}/spring-boot-samples/spring-boot-sample-web-jsp[JSP sample] so you
There is a {github-code}/spring-boot-samples/spring-boot-sample-web-jsp[JSP sample] so you
can see how to set things up.
can see how to set things up.
...
...
spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
View file @
5b97981c
...
@@ -397,10 +397,9 @@ public class SpringApplicationTests {
...
@@ -397,10 +397,9 @@ public class SpringApplicationTests {
application
.
setBeanNameGenerator
(
beanNameGenerator
);
application
.
setBeanNameGenerator
(
beanNameGenerator
);
this
.
context
=
application
.
run
();
this
.
context
=
application
.
run
();
verify
(
application
.
getLoader
()).
setBeanNameGenerator
(
beanNameGenerator
);
verify
(
application
.
getLoader
()).
setBeanNameGenerator
(
beanNameGenerator
);
assertThat
(
Object
actualGenerator
=
this
.
context
this
.
context
.
getBean
(
AnnotationConfigUtils
.
CONFIGURATION_BEAN_NAME_GENERATOR
);
.
getBean
(
AnnotationConfigUtils
.
CONFIGURATION_BEAN_NAME_GENERATOR
),
assertThat
(
actualGenerator
,
sameInstance
((
Object
)
beanNameGenerator
));
sameInstance
((
Object
)
beanNameGenerator
));
}
}
@Test
@Test
...
@@ -412,10 +411,9 @@ public class SpringApplicationTests {
...
@@ -412,10 +411,9 @@ public class SpringApplicationTests {
application
.
setBeanNameGenerator
(
beanNameGenerator
);
application
.
setBeanNameGenerator
(
beanNameGenerator
);
this
.
context
=
application
.
run
();
this
.
context
=
application
.
run
();
verify
(
application
.
getLoader
()).
setBeanNameGenerator
(
beanNameGenerator
);
verify
(
application
.
getLoader
()).
setBeanNameGenerator
(
beanNameGenerator
);
assertThat
(
Object
actualGenerator
=
this
.
context
this
.
context
.
getBean
(
AnnotationConfigUtils
.
CONFIGURATION_BEAN_NAME_GENERATOR
);
.
getBean
(
AnnotationConfigUtils
.
CONFIGURATION_BEAN_NAME_GENERATOR
),
assertThat
(
actualGenerator
,
sameInstance
((
Object
)
beanNameGenerator
));
sameInstance
((
Object
)
beanNameGenerator
));
}
}
@Test
@Test
...
...
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