Skip to content

Commit

Permalink
Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunyzzZ authored and snicoll committed Aug 17, 2019
1 parent 3a20b1d commit d33ed84
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public PropertySourcesPlaceholdersResolver(Iterable<PropertySource<?>> sources,

@Override
public Object resolvePlaceholders(Object value) {
if (value != null && value instanceof String) {
if (value instanceof String) {
return this.helper.replacePlaceholders((String) value, this::resolvePlaceholder);
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public Origin getOrigin() {
public static JsonPropertyValue get(PropertySource<?> propertySource) {
for (String candidate : CANDIDATES) {
Object value = propertySource.getProperty(candidate);
if (value != null && value instanceof String && StringUtils.hasLength((String) value)) {
if (value instanceof String && StringUtils.hasLength((String) value)) {
return new JsonPropertyValue(propertySource, candidate, (String) value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ static Origin from(Object source) {
return (Origin) source;
}
Origin origin = null;
if (source != null && source instanceof OriginProvider) {
if (source instanceof OriginProvider) {
origin = ((OriginProvider) source).getOrigin();
}
if (origin == null && source != null && source instanceof Throwable) {
if (origin == null && source instanceof Throwable) {
return from(((Throwable) source).getCause());
}
return origin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj instanceof ApplicationPid) {
if (obj instanceof ApplicationPid) {
return ObjectUtils.nullSafeEquals(this.pid, ((ApplicationPid) obj).pid);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void addErrorDetails(Map<String, Object> errorAttributes, WebRequest web
Throwable error = getError(webRequest);
if (error != null) {
while (error instanceof ServletException && error.getCause() != null) {
error = ((ServletException) error).getCause();
error = error.getCause();
}
if (this.includeException) {
errorAttributes.put("exception", error.getClass().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void contextWithClassLoader() {
ClassLoader classLoader = new URLClassLoader(new URL[0], getClass().getClassLoader());
application.resourceLoader(new DefaultResourceLoader(classLoader));
this.context = application.run();
assertThat(((SpyApplicationContext) this.context).getClassLoader()).isEqualTo(classLoader);
assertThat(this.context.getClassLoader()).isEqualTo(classLoader);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ public void systemPropertyWins() {

@Test
public void defaultPropertyAsFallback() {
this.environment.getPropertySources().addLast(
new MapPropertySource("defaultProperties", Collections.singletonMap("my.fallback", (Object) "foo")));
this.environment.getPropertySources()
.addLast(new MapPropertySource("defaultProperties", Collections.singletonMap("my.fallback", "foo")));
this.initializer.postProcessEnvironment(this.environment, this.application);
String property = this.environment.getProperty("my.fallback");
assertThat(property).isEqualTo("foo");
Expand All @@ -313,7 +313,7 @@ public void defaultPropertyAsFallback() {
@Test
public void defaultPropertyAsFallbackDuringFileParsing() {
this.environment.getPropertySources().addLast(new MapPropertySource("defaultProperties",
Collections.singletonMap("spring.config.name", (Object) "testproperties")));
Collections.singletonMap("spring.config.name", "testproperties")));
this.initializer.postProcessEnvironment(this.environment, this.application);
String property = this.environment.getProperty("the.property");
assertThat(property).isEqualTo("frompropertiesfile");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public void appendWhenElementNameMultiDotShouldThrowException() {
@Test
public void appendWhenElementNameIsNullShouldReturnName() {
ConfigurationPropertyName name = ConfigurationPropertyName.of("foo");
assertThat((Object) name.append((String) null)).isSameAs(name);
assertThat((Object) name.append(null)).isSameAs(name);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,7 @@ public void compressionWithoutContentSizeHeader() throws Exception {
this.webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(false, true), "/hello"));
this.webServer.start();
TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory();
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip",
(InputStreamFactory) inputStreamFactory);
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip", inputStreamFactory);
getResponse(getLocalUrl("/hello"), new HttpComponentsClientHttpRequestFactory(
HttpClientBuilder.create().setContentDecoderRegistry(contentDecoderMap).build()));
assertThat(inputStreamFactory.wasCompressionUsed()).isTrue();
Expand Down Expand Up @@ -993,8 +992,7 @@ private boolean doTestCompression(int contentSize, String[] mimeTypes, String[]
HttpMethod method) throws Exception {
String testContent = setUpFactoryForCompression(contentSize, mimeTypes, excludedUserAgents);
TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory();
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip",
(InputStreamFactory) inputStreamFactory);
Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip", inputStreamFactory);
String response = getResponse(getLocalUrl("/test.txt"), method,
new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().setUserAgent("testUserAgent")
.setContentDecoderRegistry(contentDecoderMap).build()));
Expand Down

0 comments on commit d33ed84

Please sign in to comment.