Skip to content

Commit 7881329

Browse files
committed
Polishing
1 parent 58aa065 commit 7881329

File tree

12 files changed

+138
-125
lines changed

12 files changed

+138
-125
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -219,10 +219,12 @@ public Class<?>[] getParameterTypes() {
219219
@Override
220220
@Nullable
221221
public String[] getParameterNames() {
222-
if (this.parameterNames == null) {
223-
this.parameterNames = parameterNameDiscoverer.getParameterNames(getMethod());
222+
String[] parameterNames = this.parameterNames;
223+
if (parameterNames == null) {
224+
parameterNames = parameterNameDiscoverer.getParameterNames(getMethod());
225+
this.parameterNames = parameterNames;
224226
}
225-
return this.parameterNames;
227+
return parameterNames;
226228
}
227229

228230
@Override

spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -92,8 +92,7 @@ protected DirectFieldAccessor newNestedPropertyAccessor(Object object, String ne
9292
@Override
9393
protected NotWritablePropertyException createNotWritablePropertyException(String propertyName) {
9494
PropertyMatches matches = PropertyMatches.forField(propertyName, getRootClass());
95-
throw new NotWritablePropertyException(
96-
getRootClass(), getNestedPath() + propertyName,
95+
throw new NotWritablePropertyException(getRootClass(), getNestedPath() + propertyName,
9796
matches.buildErrorMessage(), matches.getPossibleMatches());
9897
}
9998

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -613,7 +613,7 @@ private class AutowiredFieldElement extends InjectionMetadata.InjectedElement {
613613

614614
private final boolean required;
615615

616-
private volatile boolean cached = false;
616+
private volatile boolean cached;
617617

618618
@Nullable
619619
private volatile Object cachedFieldValue;
@@ -644,21 +644,20 @@ protected void inject(Object bean, @Nullable String beanName, @Nullable Property
644644
}
645645
synchronized (this) {
646646
if (!this.cached) {
647+
Object cachedFieldValue = null;
647648
if (value != null || this.required) {
648-
this.cachedFieldValue = desc;
649+
cachedFieldValue = desc;
649650
registerDependentBeans(beanName, autowiredBeanNames);
650651
if (autowiredBeanNames.size() == 1) {
651652
String autowiredBeanName = autowiredBeanNames.iterator().next();
652653
if (beanFactory.containsBean(autowiredBeanName) &&
653654
beanFactory.isTypeMatch(autowiredBeanName, field.getType())) {
654-
this.cachedFieldValue = new ShortcutDependencyDescriptor(
655+
cachedFieldValue = new ShortcutDependencyDescriptor(
655656
desc, autowiredBeanName, field.getType());
656657
}
657658
}
658659
}
659-
else {
660-
this.cachedFieldValue = null;
661-
}
660+
this.cachedFieldValue = cachedFieldValue;
662661
this.cached = true;
663662
}
664663
}
@@ -678,7 +677,7 @@ private class AutowiredMethodElement extends InjectionMetadata.InjectedElement {
678677

679678
private final boolean required;
680679

681-
private volatile boolean cached = false;
680+
private volatile boolean cached;
682681

683682
@Nullable
684683
private volatile Object[] cachedMethodArguments;

spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
*/
7777
public class SpelReproTests extends AbstractExpressionTests {
7878

79-
8079
@Test
8180
public void NPE_SPR5661() {
8281
evaluate("joinThreeStrings('a',null,'c')", "anullc", String.class);

spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -16,9 +16,10 @@
1616

1717
package org.springframework.expression.spel.testresources;
1818

19-
///CLOVER:OFF
2019
public class Person {
20+
2121
private String privateName;
22+
2223
Company company;
2324

2425
public Person(String name) {
@@ -41,4 +42,5 @@ public void setName(String n) {
4142
public Company getCompany() {
4243
return company;
4344
}
45+
4446
}
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -19,19 +19,25 @@
1919
import java.util.List;
2020

2121
public class TestAddress{
22-
private String street;
23-
private List<String> crossStreets;
24-
25-
public String getStreet() {
26-
return street;
27-
}
28-
public void setStreet(String street) {
29-
this.street = street;
30-
}
31-
public List<String> getCrossStreets() {
32-
return crossStreets;
33-
}
34-
public void setCrossStreets(List<String> crossStreets) {
35-
this.crossStreets = crossStreets;
36-
}
22+
23+
private String street;
24+
25+
private List<String> crossStreets;
26+
27+
public String getStreet() {
28+
return street;
29+
}
30+
31+
public void setStreet(String street) {
32+
this.street = street;
3733
}
34+
35+
public List<String> getCrossStreets() {
36+
return crossStreets;
37+
}
38+
39+
public void setCrossStreets(List<String> crossStreets) {
40+
this.crossStreets = crossStreets;
41+
}
42+
43+
}
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -17,19 +17,25 @@
1717
package org.springframework.expression.spel.testresources;
1818

1919
public class TestPerson {
20-
private String name;
21-
private TestAddress address;
22-
23-
public String getName() {
24-
return name;
25-
}
26-
public void setName(String name) {
27-
this.name = name;
28-
}
29-
public TestAddress getAddress() {
30-
return address;
31-
}
32-
public void setAddress(TestAddress address) {
33-
this.address = address;
34-
}
20+
21+
private String name;
22+
23+
private TestAddress address;
24+
25+
public String getName() {
26+
return name;
27+
}
28+
29+
public void setName(String name) {
30+
this.name = name;
3531
}
32+
33+
public TestAddress getAddress() {
34+
return address;
35+
}
36+
37+
public void setAddress(TestAddress address) {
38+
this.address = address;
39+
}
40+
41+
}

spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -637,21 +637,23 @@ public String createCallString() {
637637
schemaNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
638638
}
639639

640-
String procedureNameToUse = this.metaDataProvider.procedureNameToUse(getProcedureName());
641640
if (isFunction() || isReturnValueRequired()) {
642-
callString = new StringBuilder().append("{? = call ").
643-
append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "").
644-
append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "").
645-
append(procedureNameToUse).append("(");
641+
callString = new StringBuilder("{? = call ");
646642
parameterCount = -1;
647643
}
648644
else {
649-
callString = new StringBuilder().append("{call ").
650-
append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "").
651-
append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "").
652-
append(procedureNameToUse).append("(");
645+
callString = new StringBuilder("{call ");
653646
}
654647

648+
if (StringUtils.hasLength(catalogNameToUse)) {
649+
callString.append(catalogNameToUse).append(".");
650+
}
651+
if (StringUtils.hasLength(schemaNameToUse)) {
652+
callString.append(schemaNameToUse).append(".");
653+
}
654+
callString.append(this.metaDataProvider.procedureNameToUse(getProcedureName()));
655+
callString.append("(");
656+
655657
for (SqlParameter parameter : this.callParameters) {
656658
if (!parameter.isResultsParameter()) {
657659
if (parameterCount > 0) {

spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class UriComponentsBuilderTests {
5353
void plain() throws URISyntaxException {
5454
UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
5555
UriComponents result = builder.scheme("https").host("example.com")
56-
.path("foo").queryParam("bar").fragment("baz")
57-
.build();
56+
.path("foo").queryParam("bar").fragment("baz").build();
57+
5858
assertThat(result.getScheme()).isEqualTo("https");
5959
assertThat(result.getHost()).isEqualTo("example.com");
6060
assertThat(result.getPath()).isEqualTo("foo");
@@ -91,10 +91,10 @@ void multipleFromSameBuilder() throws URISyntaxException {
9191
@Test
9292
void fromPath() throws URISyntaxException {
9393
UriComponents result = UriComponentsBuilder.fromPath("foo").queryParam("bar").fragment("baz").build();
94+
9495
assertThat(result.getPath()).isEqualTo("foo");
9596
assertThat(result.getQuery()).isEqualTo("bar");
9697
assertThat(result.getFragment()).isEqualTo("baz");
97-
9898
assertThat(result.toUriString()).as("Invalid result URI String").isEqualTo("foo?bar#baz");
9999

100100
URI expected = new URI("foo?bar#baz");
@@ -111,23 +111,23 @@ void fromPath() throws URISyntaxException {
111111
void fromHierarchicalUri() throws URISyntaxException {
112112
URI uri = new URI("https://example.com/foo?bar#baz");
113113
UriComponents result = UriComponentsBuilder.fromUri(uri).build();
114+
114115
assertThat(result.getScheme()).isEqualTo("https");
115116
assertThat(result.getHost()).isEqualTo("example.com");
116117
assertThat(result.getPath()).isEqualTo("/foo");
117118
assertThat(result.getQuery()).isEqualTo("bar");
118119
assertThat(result.getFragment()).isEqualTo("baz");
119-
120120
assertThat(result.toUri()).as("Invalid result URI").isEqualTo(uri);
121121
}
122122

123123
@Test
124124
void fromOpaqueUri() throws URISyntaxException {
125125
URI uri = new URI("mailto:[email protected]#baz");
126126
UriComponents result = UriComponentsBuilder.fromUri(uri).build();
127+
127128
assertThat(result.getScheme()).isEqualTo("mailto");
128129
assertThat(result.getSchemeSpecificPart()).isEqualTo("[email protected]");
129130
assertThat(result.getFragment()).isEqualTo("baz");
130-
131131
assertThat(result.toUri()).as("Invalid result URI").isEqualTo(uri);
132132
}
133133

@@ -606,7 +606,7 @@ void fromHttpRequestWithTrailingSlash() {
606606
assertThat(after.getPath()).isEqualTo("/foo/");
607607
}
608608

609-
@Test // gh-19890
609+
@Test // gh-19890
610610
void fromHttpRequestWithEmptyScheme() {
611611
HttpRequest request = new HttpRequest() {
612612
@Override
@@ -854,7 +854,7 @@ void queryParamWithoutValueWithoutEquals() {
854854
assertThat(uriComponents.getQueryParams().get("bar").get(0)).isNull();
855855
}
856856

857-
@Test // gh-24444
857+
@Test // gh-24444
858858
void opaqueUriDoesNotResetOnNullInput() throws URISyntaxException {
859859
URI uri = new URI("urn:ietf:wg:oauth:2.0:oob");
860860
UriComponents result = UriComponentsBuilder.fromUri(uri)
@@ -1114,7 +1114,7 @@ void fromHttpRequestForwardedHeaderWithProtoAndServerPort() {
11141114
assertThat(result.toUriString()).isEqualTo("https://example.com/rest/mobile/users/1");
11151115
}
11161116

1117-
@Test // gh-25737
1117+
@Test // gh-25737
11181118
void fromHttpRequestForwardedHeaderComma() {
11191119
MockHttpServletRequest request = new MockHttpServletRequest();
11201120
request.addHeader("Forwarded", "for=192.0.2.0,for=192.0.2.1;proto=https;host=192.0.2.3:9090");
@@ -1153,7 +1153,7 @@ void uriComponentsWithMergedQueryParams() {
11531153
assertThat(uri).isEqualTo("http://localhost:8081/{path}?sort={sort}&sort=another_value");
11541154
}
11551155

1156-
@Test // SPR-17630
1156+
@Test // SPR-17630
11571157
void toUriStringWithCurlyBraces() {
11581158
assertThat(UriComponentsBuilder.fromUriString("/path?q={asa}asa").toUriString()).isEqualTo("/path?q=%7Basa%7Dasa");
11591159
}

0 commit comments

Comments
 (0)