Skip to content

Commit 5b97981

Browse files
committed
Polish
1 parent 9d194c2 commit 5b97981

File tree

8 files changed

+45
-44
lines changed

8 files changed

+45
-44
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpoint.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ public Resource transform(HttpServletRequest request, Resource resource,
148148
return resource;
149149
}
150150

151-
private Resource replaceInitialLink(String contextPath, Resource resource) throws IOException {
151+
private Resource replaceInitialLink(String contextPath, Resource resource)
152+
throws IOException {
152153
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
153154
String content = new String(bytes, DEFAULT_CHARSET);
154-
String initial = contextPath + getManagementServletContext().getContextPath() + getPath();
155+
String initial = contextPath + getManagementServletContext().getContextPath()
156+
+ getPath();
155157
content = content.replace("entryPoint: '/'", "entryPoint: '" + initial + "'");
156158
return new TransformedResource(resource, content.getBytes(DEFAULT_CHARSET));
157159
}

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointManagementContextPathIntegrationTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public void actuatorHomeHtml() throws Exception {
9292

9393
@Test
9494
public void actuatorBrowserHtml() throws Exception {
95-
this.mockMvc.perform(get("/admin/browser.html").accept(MediaType.APPLICATION_JSON))
95+
this.mockMvc
96+
.perform(get("/admin/browser.html").accept(MediaType.APPLICATION_JSON))
9697
.andExpect(status().isOk())
9798
.andExpect(content().string(containsString("entryPoint: '/admin'")));
9899
}

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public void actuatorBrowserEntryPoint() throws Exception {
9090
HttpHeaders headers = new HttpHeaders();
9191
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
9292
ResponseEntity<String> entity = new TestRestTemplate().exchange(
93-
"http://localhost:" + this.port + "/spring/actuator/browser.html", HttpMethod.GET,
94-
new HttpEntity<Void>(null, headers), String.class);
93+
"http://localhost:" + this.port + "/spring/actuator/browser.html",
94+
HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
9595
assertEquals(HttpStatus.OK, entity.getStatusCode());
9696
assertTrue("Wrong body: " + entity.getBody(),
9797
entity.getBody().contains("entryPoint: '/spring/actuator'"));

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ protected static class IntegrationConfiguration {
6464
@ConditionalOnClass(EnableIntegrationMBeanExport.class)
6565
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
6666
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
67-
protected static class IntegrationJmxConfiguration implements EnvironmentAware, BeanFactoryAware {
67+
protected static class IntegrationJmxConfiguration
68+
implements EnvironmentAware, BeanFactoryAware {
6869

6970
private BeanFactory beanFactory;
7071

@@ -81,7 +82,8 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
8182

8283
@Override
8384
public void setEnvironment(Environment environment) {
84-
this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.jmx.");
85+
this.propertyResolver = new RelaxedPropertyResolver(environment,
86+
"spring.jmx.");
8587
}
8688

8789
@Bean

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/SilentExitExceptionHandler.java

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
3636
@Override
3737
public void uncaughtException(Thread thread, Throwable exception) {
3838
if (exception instanceof SilentExitException) {
39-
if (jvmWillExit(thread)) {
39+
if (isJvmExiting(thread)) {
4040
preventNonZeroExitCode();
4141
}
4242
return;
@@ -46,19 +46,7 @@ public void uncaughtException(Thread thread, Throwable exception) {
4646
}
4747
}
4848

49-
public static void setup(Thread thread) {
50-
UncaughtExceptionHandler handler = thread.getUncaughtExceptionHandler();
51-
if (!(handler instanceof SilentExitExceptionHandler)) {
52-
handler = new SilentExitExceptionHandler(handler);
53-
thread.setUncaughtExceptionHandler(handler);
54-
}
55-
}
56-
57-
public static void exitCurrentThread() {
58-
throw new SilentExitException();
59-
}
60-
61-
private boolean jvmWillExit(Thread exceptionThread) {
49+
private boolean isJvmExiting(Thread exceptionThread) {
6250
for (Thread thread : getAllThreads()) {
6351
if (thread != exceptionThread && thread.isAlive() && !thread.isDaemon()) {
6452
return false;
@@ -67,22 +55,15 @@ private boolean jvmWillExit(Thread exceptionThread) {
6755
return true;
6856
}
6957

70-
protected void preventNonZeroExitCode() {
71-
System.exit(0);
72-
}
73-
7458
protected Thread[] getAllThreads() {
7559
ThreadGroup rootThreadGroup = getRootThreadGroup();
76-
int size = 32;
77-
int threadCount;
78-
Thread[] threads;
79-
do {
80-
size *= 2;
81-
threads = new Thread[size];
82-
threadCount = rootThreadGroup.enumerate(threads);
60+
Thread[] threads = new Thread[32];
61+
int count = rootThreadGroup.enumerate(threads);
62+
while (count == threads.length) {
63+
threads = new Thread[threads.length * 2];
64+
count = rootThreadGroup.enumerate(threads);
8365
}
84-
while (threadCount == threads.length);
85-
return Arrays.copyOf(threads, threadCount);
66+
return Arrays.copyOf(threads, count);
8667
}
8768

8869
private ThreadGroup getRootThreadGroup() {
@@ -93,6 +74,22 @@ private ThreadGroup getRootThreadGroup() {
9374
return candidate;
9475
}
9576

77+
protected void preventNonZeroExitCode() {
78+
System.exit(0);
79+
}
80+
81+
public static void setup(Thread thread) {
82+
UncaughtExceptionHandler handler = thread.getUncaughtExceptionHandler();
83+
if (!(handler instanceof SilentExitExceptionHandler)) {
84+
handler = new SilentExitExceptionHandler(handler);
85+
thread.setUncaughtExceptionHandler(handler);
86+
}
87+
}
88+
89+
public static void exitCurrentThread() {
90+
throw new SilentExitException();
91+
}
92+
9693
private static class SilentExitException extends RuntimeException {
9794

9895
}

spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/SilentExitExceptionHandlerTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
* Tests for {@link SilentExitExceptionHandler}.
3131
*
3232
* @author Phillip Webb
33+
* @author Andy Wilkinson
3334
*/
3435
public class SilentExitExceptionHandlerTests {
3536

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ packaged as an executable archive), there are some limitations in the JSP suppor
19721972
* Undertow does not support JSPs.
19731973

19741974
* Creating a custom `error.jsp` page won't override the default view for
1975-
<<boot-features-error-handling,error handling>>.
1975+
<<boot-features-error-handling,error handling>>.
19761976

19771977
There is a {github-code}/spring-boot-samples/spring-boot-sample-web-jsp[JSP sample] so you
19781978
can see how to set things up.

spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,9 @@ public void customBeanNameGenerator() throws Exception {
397397
application.setBeanNameGenerator(beanNameGenerator);
398398
this.context = application.run();
399399
verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
400-
assertThat(
401-
this.context
402-
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR),
403-
sameInstance((Object) beanNameGenerator));
400+
Object actualGenerator = this.context
401+
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
402+
assertThat(actualGenerator, sameInstance((Object) beanNameGenerator));
404403
}
405404

406405
@Test
@@ -412,10 +411,9 @@ public void customBeanNameGeneratorWithNonWebApplication() throws Exception {
412411
application.setBeanNameGenerator(beanNameGenerator);
413412
this.context = application.run();
414413
verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
415-
assertThat(
416-
this.context
417-
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR),
418-
sameInstance((Object) beanNameGenerator));
414+
Object actualGenerator = this.context
415+
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
416+
assertThat(actualGenerator, sameInstance((Object) beanNameGenerator));
419417
}
420418

421419
@Test

0 commit comments

Comments
 (0)