From 7424f48803453774f058e293e060b04e9afd5ca0 Mon Sep 17 00:00:00 2001 From: igor-suhorukov Date: Sat, 22 Dec 2018 00:22:28 +0300 Subject: [PATCH 1/2] Replace redundant call to class isInstance() with instanceof See gh-15554 --- .../autoconfigure/web/server/OnManagementPortCondition.java | 2 +- .../boot/autoconfigure/condition/ConditionMessage.java | 2 +- .../autoconfigure/hateoas/HypermediaAutoConfigurationTests.java | 2 +- .../boot/logging/logback/LogbackLoggingSystem.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java index 1b441f7020..952284360c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java @@ -68,7 +68,7 @@ class OnManagementPortCondition extends SpringBootCondition { context.getClassLoader())) { return false; } - return WebApplicationContext.class.isInstance(resourceLoader); + return resourceLoader instanceof WebApplicationContext; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java index 8fee3038ba..681a38a53d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java @@ -61,7 +61,7 @@ public final class ConditionMessage { @Override public boolean equals(Object obj) { - if (obj == null || !ConditionMessage.class.isInstance(obj)) { + if (!(obj instanceof ConditionMessage)) { return false; } if (obj == this) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java index 270c3993d9..3122b1a9cc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java @@ -70,7 +70,7 @@ public class HypermediaAutoConfigurationTests { LinkDiscoverers discoverers = this.context.getBean(LinkDiscoverers.class); assertThat(discoverers).isNotNull(); LinkDiscoverer discoverer = discoverers.getLinkDiscovererFor(MediaTypes.HAL_JSON); - assertThat(HalLinkDiscoverer.class.isInstance(discoverer)).isTrue(); + assertThat(discoverer instanceof HalLinkDiscoverer).isTrue(); } @Test diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index edb78c4142..a6bd448af3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -198,7 +198,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { } java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger(""); Handler[] handlers = rootLogger.getHandlers(); - return handlers.length == 1 && SLF4JBridgeHandler.class.isInstance(handlers[0]); + return handlers.length == 1 && handlers[0] instanceof SLF4JBridgeHandler; } private void addLevelChangePropagator(LoggerContext loggerContext) { From fd12e696b02c1262bbdbe81d166bfee355df569a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sun, 23 Dec 2018 15:51:39 +0100 Subject: [PATCH 2/2] Polish "Replace redundant call to class isInstance() with instanceof" Closes gh-15554 --- .../autoconfigure/web/server/OnManagementPortCondition.java | 2 +- .../autoconfigure/hateoas/HypermediaAutoConfigurationTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java index 952284360c..c332a27028 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/OnManagementPortCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java index 3122b1a9cc..703d3cfbac 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationTests.java @@ -70,7 +70,7 @@ public class HypermediaAutoConfigurationTests { LinkDiscoverers discoverers = this.context.getBean(LinkDiscoverers.class); assertThat(discoverers).isNotNull(); LinkDiscoverer discoverer = discoverers.getLinkDiscovererFor(MediaTypes.HAL_JSON); - assertThat(discoverer instanceof HalLinkDiscoverer).isTrue(); + assertThat(discoverer).isInstanceOf(HalLinkDiscoverer.class); } @Test