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

+8-5
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

+5-14
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

+2-1
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

+1
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

+3
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

+13
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

+3
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

+2-1
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

+1
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

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

spring-boot/src/main/java/org/springframework/boot/context/embedded/EmbeddedServletContainer.java

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void stop() throws EmbeddedServletContainerException {
4848
public int getPort() {
4949
return 0;
5050
}
51+
5152
};
5253

5354
/**

spring-boot/src/main/java/org/springframework/boot/env/EnumerableCompositePropertySource.java

+1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ public void add(PropertySource<?> source) {
7575
getSource().add(source);
7676
this.names = null;
7777
}
78+
7879
}

spring-boot/src/main/java/org/springframework/boot/env/PropertiesPropertySourceLoader.java

+1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ public PropertySource<?> load(String name, Resource resource, String profile)
4848
}
4949
return null;
5050
}
51+
5152
}

spring-boot/src/main/java/org/springframework/boot/test/Base64.java

+2-1
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.
@@ -640,4 +640,5 @@ class InvalidBase64CharacterException extends IllegalArgumentException {
640640
InvalidBase64CharacterException(String message) {
641641
super(message);
642642
}
643+
643644
}

spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java

+22
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,11 @@ public Map<String, Object> getInfo() {
487487
public void setInfo(Map<String, Object> nested) {
488488
this.info = nested;
489489
}
490+
490491
}
491492

492493
public static class TargetWithNestedMap {
494+
493495
private Map<String, Object> nested;
494496

495497
public Map<String, Object> getNested() {
@@ -499,9 +501,11 @@ public Map<String, Object> getNested() {
499501
public void setNested(Map<String, Object> nested) {
500502
this.nested = nested;
501503
}
504+
502505
}
503506

504507
public static class TargetWithNestedMapOfString {
508+
505509
private Map<String, String> nested;
506510

507511
public Map<String, String> getNested() {
@@ -511,9 +515,11 @@ public Map<String, String> getNested() {
511515
public void setNested(Map<String, String> nested) {
512516
this.nested = nested;
513517
}
518+
514519
}
515520

516521
public static class TargetWithNestedMapOfListOfString {
522+
517523
private Map<String, List<String>> nested;
518524

519525
public Map<String, List<String>> getNested() {
@@ -523,9 +529,11 @@ public Map<String, List<String>> getNested() {
523529
public void setNested(Map<String, List<String>> nested) {
524530
this.nested = nested;
525531
}
532+
526533
}
527534

528535
public static class TargetWithNestedMapOfListOfBean {
536+
529537
private Map<String, List<VanillaTarget>> nested;
530538

531539
public Map<String, List<VanillaTarget>> getNested() {
@@ -535,9 +543,11 @@ public Map<String, List<VanillaTarget>> getNested() {
535543
public void setNested(Map<String, List<VanillaTarget>> nested) {
536544
this.nested = nested;
537545
}
546+
538547
}
539548

540549
public static class TargetWithNestedMapOfBean {
550+
541551
private Map<String, VanillaTarget> nested;
542552

543553
public Map<String, VanillaTarget> getNested() {
@@ -547,9 +557,11 @@ public Map<String, VanillaTarget> getNested() {
547557
public void setNested(Map<String, VanillaTarget> nested) {
548558
this.nested = nested;
549559
}
560+
550561
}
551562

552563
public static class TargetWithNestedList {
564+
553565
private List<String> nested;
554566

555567
public List<String> getNested() {
@@ -559,33 +571,41 @@ public List<String> getNested() {
559571
public void setNested(List<String> nested) {
560572
this.nested = nested;
561573
}
574+
562575
}
563576

564577
public static class TargetWithReadOnlyNestedList {
578+
565579
private final List<String> nested = new ArrayList<String>();
566580

567581
public List<String> getNested() {
568582
return this.nested;
569583
}
584+
570585
}
571586

572587
public static class TargetWithReadOnlyDoubleNestedList {
588+
573589
TargetWithReadOnlyNestedList bean = new TargetWithReadOnlyNestedList();
574590

575591
public TargetWithReadOnlyNestedList getBean() {
576592
return this.bean;
577593
}
594+
578595
}
579596

580597
public static class TargetWithReadOnlyNestedCollection {
598+
581599
private final Collection<String> nested = new ArrayList<String>();
582600

583601
public Collection<String> getNested() {
584602
return this.nested;
585603
}
604+
586605
}
587606

588607
public static class TargetWithNestedSet {
608+
589609
private Set<String> nested = new LinkedHashSet<String>();
590610

591611
public Set<String> getNested() {
@@ -595,6 +615,7 @@ public Set<String> getNested() {
595615
public void setNested(Set<String> nested) {
596616
this.nested = nested;
597617
}
618+
598619
}
599620

600621
public static class TargetWithNestedObject {
@@ -650,6 +671,7 @@ public String getFooBaz() {
650671
public void setFooBaz(String fooBaz) {
651672
this.fooBaz = fooBaz;
652673
}
674+
653675
}
654676

655677
public static class ValidatedTarget {

0 commit comments

Comments
 (0)