Skip to content

Commit 47c3b1d

Browse files
committed
Merge pull request #17875 from lijunyzzZ
* pr/17875: Remove redundant code Closes gh-17875
2 parents 3a20b1d + d33ed84 commit 47c3b1d

File tree

9 files changed

+13
-15
lines changed

9 files changed

+13
-15
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public PropertySourcesPlaceholdersResolver(Iterable<PropertySource<?>> sources,
5353

5454
@Override
5555
public Object resolvePlaceholders(Object value) {
56-
if (value != null && value instanceof String) {
56+
if (value instanceof String) {
5757
return this.helper.replacePlaceholders((String) value, this::resolvePlaceholder);
5858
}
5959
return value;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public Origin getOrigin() {
204204
public static JsonPropertyValue get(PropertySource<?> propertySource) {
205205
for (String candidate : CANDIDATES) {
206206
Object value = propertySource.getProperty(candidate);
207-
if (value != null && value instanceof String && StringUtils.hasLength((String) value)) {
207+
if (value instanceof String && StringUtils.hasLength((String) value)) {
208208
return new JsonPropertyValue(propertySource, candidate, (String) value);
209209
}
210210
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/Origin.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ static Origin from(Object source) {
4444
return (Origin) source;
4545
}
4646
Origin origin = null;
47-
if (source != null && source instanceof OriginProvider) {
47+
if (source instanceof OriginProvider) {
4848
origin = ((OriginProvider) source).getOrigin();
4949
}
50-
if (origin == null && source != null && source instanceof Throwable) {
50+
if (origin == null && source instanceof Throwable) {
5151
return from(((Throwable) source).getCause());
5252
}
5353
return origin;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public boolean equals(Object obj) {
6464
if (obj == this) {
6565
return true;
6666
}
67-
if (obj != null && obj instanceof ApplicationPid) {
67+
if (obj instanceof ApplicationPid) {
6868
return ObjectUtils.nullSafeEquals(this.pid, ((ApplicationPid) obj).pid);
6969
}
7070
return false;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private void addErrorDetails(Map<String, Object> errorAttributes, WebRequest web
130130
Throwable error = getError(webRequest);
131131
if (error != null) {
132132
while (error instanceof ServletException && error.getCause() != null) {
133-
error = ((ServletException) error).getCause();
133+
error = error.getCause();
134134
}
135135
if (this.includeException) {
136136
errorAttributes.put("exception", error.getClass().getName());

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void contextWithClassLoader() {
155155
ClassLoader classLoader = new URLClassLoader(new URL[0], getClass().getClassLoader());
156156
application.resourceLoader(new DefaultResourceLoader(classLoader));
157157
this.context = application.run();
158-
assertThat(((SpyApplicationContext) this.context).getClassLoader()).isEqualTo(classLoader);
158+
assertThat(this.context.getClassLoader()).isEqualTo(classLoader);
159159
}
160160

161161
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ public void systemPropertyWins() {
303303

304304
@Test
305305
public void defaultPropertyAsFallback() {
306-
this.environment.getPropertySources().addLast(
307-
new MapPropertySource("defaultProperties", Collections.singletonMap("my.fallback", (Object) "foo")));
306+
this.environment.getPropertySources()
307+
.addLast(new MapPropertySource("defaultProperties", Collections.singletonMap("my.fallback", "foo")));
308308
this.initializer.postProcessEnvironment(this.environment, this.application);
309309
String property = this.environment.getProperty("my.fallback");
310310
assertThat(property).isEqualTo("foo");
@@ -313,7 +313,7 @@ public void defaultPropertyAsFallback() {
313313
@Test
314314
public void defaultPropertyAsFallbackDuringFileParsing() {
315315
this.environment.getPropertySources().addLast(new MapPropertySource("defaultProperties",
316-
Collections.singletonMap("spring.config.name", (Object) "testproperties")));
316+
Collections.singletonMap("spring.config.name", "testproperties")));
317317
this.initializer.postProcessEnvironment(this.environment, this.application);
318318
String property = this.environment.getProperty("the.property");
319319
assertThat(property).isEqualTo("frompropertiesfile");

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public void appendWhenElementNameMultiDotShouldThrowException() {
409409
@Test
410410
public void appendWhenElementNameIsNullShouldReturnName() {
411411
ConfigurationPropertyName name = ConfigurationPropertyName.of("foo");
412-
assertThat((Object) name.append((String) null)).isSameAs(name);
412+
assertThat((Object) name.append(null)).isSameAs(name);
413413
}
414414

415415
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,7 @@ public void compressionWithoutContentSizeHeader() throws Exception {
788788
this.webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(false, true), "/hello"));
789789
this.webServer.start();
790790
TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory();
791-
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip",
792-
(InputStreamFactory) inputStreamFactory);
791+
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip", inputStreamFactory);
793792
getResponse(getLocalUrl("/hello"), new HttpComponentsClientHttpRequestFactory(
794793
HttpClientBuilder.create().setContentDecoderRegistry(contentDecoderMap).build()));
795794
assertThat(inputStreamFactory.wasCompressionUsed()).isTrue();
@@ -993,8 +992,7 @@ private boolean doTestCompression(int contentSize, String[] mimeTypes, String[]
993992
HttpMethod method) throws Exception {
994993
String testContent = setUpFactoryForCompression(contentSize, mimeTypes, excludedUserAgents);
995994
TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory();
996-
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip",
997-
(InputStreamFactory) inputStreamFactory);
995+
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip", inputStreamFactory);
998996
String response = getResponse(getLocalUrl("/test.txt"), method,
999997
new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().setUserAgent("testUserAgent")
1000998
.setContentDecoderRegistry(contentDecoderMap).build()));

0 commit comments

Comments
 (0)