Skip to content

Commit d117a6b

Browse files
author
Phillip Webb
committed
Polish
1 parent 71c2c69 commit d117a6b

File tree

15 files changed

+66
-22
lines changed

15 files changed

+66
-22
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/BasicErrorController.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,17 @@ public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
7676
String trace = request.getParameter("trace");
7777
Map<String, Object> extracted = extract(attributes,
7878
trace != null && !"false".equals(trace.toLowerCase()), true);
79-
HttpStatus statusCode;
79+
HttpStatus statusCode = getStatus((Integer) extracted.get("status"));
80+
return new ResponseEntity<Map<String, Object>>(extracted, statusCode);
81+
}
82+
83+
private HttpStatus getStatus(Integer value) {
8084
try {
81-
statusCode = HttpStatus.valueOf((Integer) extracted.get("status"));
85+
return HttpStatus.valueOf(value);
8286
}
83-
catch (Exception e) {
84-
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
87+
catch (Exception ex) {
88+
return HttpStatus.INTERNAL_SERVER_ERROR;
8589
}
86-
return new ResponseEntity<Map<String, Object>>(extracted, statusCode);
8790
}
8891

8992
@Override

spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.springframework.test.context.ActiveProfiles;
3333
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3434
import org.springframework.test.context.web.WebAppConfiguration;
35-
import org.springframework.web.client.RestTemplate;
3635

3736
import static org.junit.Assert.assertEquals;
3837

@@ -61,8 +60,8 @@ public class ManagementPortSampleActuatorApplicationTests {
6160
@Test
6261
public void testHome() throws Exception {
6362
@SuppressWarnings("rawtypes")
64-
ResponseEntity<Map> entity = getRestTemplate("user", getPassword()).getForEntity(
65-
"http://localhost:" + this.port, Map.class);
63+
ResponseEntity<Map> entity = RestTemplates.get("user", getPassword())
64+
.getForEntity("http://localhost:" + this.port, Map.class);
6665
assertEquals(HttpStatus.OK, entity.getStatusCode());
6766
@SuppressWarnings("unchecked")
6867
Map<String, Object> body = entity.getBody();
@@ -73,14 +72,14 @@ public void testHome() throws Exception {
7372
public void testMetrics() throws Exception {
7473
testHome(); // makes sure some requests have been made
7574
@SuppressWarnings("rawtypes")
76-
ResponseEntity<Map> entity = getRestTemplate().getForEntity(
75+
ResponseEntity<Map> entity = RestTemplates.get().getForEntity(
7776
"http://localhost:" + this.managementPort + "/metrics", Map.class);
7877
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
7978
}
8079

8180
@Test
8281
public void testHealth() throws Exception {
83-
ResponseEntity<String> entity = getRestTemplate().getForEntity(
82+
ResponseEntity<String> entity = RestTemplates.get().getForEntity(
8483
"http://localhost:" + this.managementPort + "/health", String.class);
8584
assertEquals(HttpStatus.OK, entity.getStatusCode());
8685
assertEquals("ok", entity.getBody());
@@ -89,7 +88,7 @@ public void testHealth() throws Exception {
8988
@Test
9089
public void testErrorPage() throws Exception {
9190
@SuppressWarnings("rawtypes")
92-
ResponseEntity<Map> entity = getRestTemplate().getForEntity(
91+
ResponseEntity<Map> entity = RestTemplates.get().getForEntity(
9392
"http://localhost:" + this.managementPort + "/error", Map.class);
9493
assertEquals(HttpStatus.OK, entity.getStatusCode());
9594
@SuppressWarnings("unchecked")
@@ -101,12 +100,4 @@ private String getPassword() {
101100
return this.security.getUser().getPassword();
102101
}
103102

104-
private RestTemplate getRestTemplate() {
105-
return RestTemplates.get();
106-
}
107-
108-
private RestTemplate getRestTemplate(final String username, final String password) {
109-
return RestTemplates.get(username, password);
110-
}
111-
112103
}

spring-boot-starters/spring-boot-starter-actuator/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>org.springframework.boot</groupId>

spring-boot/src/main/java/org/springframework/boot/Banner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ public static void write(PrintStream printStream) {
6363
FAINT, version));
6464
printStream.println();
6565
}
66+
6667
}

spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,13 @@ public ClassExcludeFilter(Object... sources) {
301301
protected boolean matchClassName(String className) {
302302
return this.classNames.contains(className);
303303
}
304+
304305
}
305306

306307
protected interface GroovyBeanDefinitionSource {
308+
307309
Closure<?> getBeans();
310+
308311
}
309312

310313
}

spring-boot/src/main/java/org/springframework/boot/ansi/AnsiElement.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,31 @@
2424
public interface AnsiElement {
2525

2626
public static final AnsiElement NORMAL = new DefaultAnsiElement("0");
27+
2728
public static final AnsiElement BOLD = new DefaultAnsiElement("1");
29+
2830
public static final AnsiElement FAINT = new DefaultAnsiElement("2");
31+
2932
public static final AnsiElement ITALIC = new DefaultAnsiElement("3");
33+
3034
public static final AnsiElement UNDERLINE = new DefaultAnsiElement("4");
3135

3236
public static final AnsiElement BLACK = new DefaultAnsiElement("30");
37+
3338
public static final AnsiElement RED = new DefaultAnsiElement("31");
39+
3440
public static final AnsiElement GREEN = new DefaultAnsiElement("32");
41+
3542
public static final AnsiElement YELLOW = new DefaultAnsiElement("33");
43+
3644
public static final AnsiElement BLUE = new DefaultAnsiElement("34");
45+
3746
public static final AnsiElement MAGENTA = new DefaultAnsiElement("35");
47+
3848
public static final AnsiElement CYAN = new DefaultAnsiElement("36");
49+
3950
public static final AnsiElement WHITE = new DefaultAnsiElement("37");
51+
4052
public static final AnsiElement DEFAULT = new DefaultAnsiElement("39");
4153

4254
/**
@@ -60,6 +72,7 @@ public DefaultAnsiElement(String code) {
6072
public String toString() {
6173
return this.code;
6274
}
75+
6376
}
6477

6578
}

spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public String apply(String value) {
9090
};
9191

9292
public abstract String apply(String value);
93+
9394
}
9495

9596
static enum Manipulation {
@@ -157,5 +158,7 @@ public String apply(String value) {
157158
};
158159

159160
public abstract String apply(String value);
161+
160162
}
163+
161164
}

spring-boot/src/main/java/org/springframework/boot/bind/YamlJavaBeanPropertyConstructor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2013 the original author or authors.
2+
* Copyright 2012-2014 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.
@@ -89,5 +89,6 @@ protected Property getProperty(Class<?> type, String name)
8989
Property property = (forType == null ? null : forType.get(name));
9090
return (property == null ? super.getProperty(type, name) : property);
9191
}
92+
9293
}
9394
}

spring-boot/src/main/java/org/springframework/boot/builder/ParentContextApplicationContextInitializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
7575
(ConfigurableApplicationContext) context));
7676
}
7777
}
78+
7879
}
7980

8081
public static class ParentContextAvailableEvent extends ApplicationEvent {

spring-boot/src/main/java/org/springframework/boot/context/FileEncodingApplicationListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
7575
}
7676
}
7777
}
78+
7879
};

0 commit comments

Comments
 (0)