From 71351de694e2e4fb690a9f6fd28ffdcb905148e2 Mon Sep 17 00:00:00 2001 From: igor-suhorukov Date: Tue, 13 Feb 2018 00:42:51 +0300 Subject: [PATCH] Remove redundant casts See gh-12011 --- .../actuate/elasticsearch/ElasticsearchHealthIndicator.java | 2 +- .../web/reactive/AbstractWebFluxEndpointHandlerMapping.java | 3 +-- .../boot/autoconfigure/condition/ConditionMessage.java | 2 +- .../boot/autoconfigure/flyway/FlywayAutoConfiguration.java | 3 +-- .../boot/autoconfigure/orm/jpa/DatabaseLookup.java | 2 +- .../main/java/org/springframework/boot/ansi/AnsiColors.java | 2 +- .../boot/jta/bitronix/PoolingDataSourceBean.java | 3 +-- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java index 9a1abf4509..84477e07b3 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java @@ -53,7 +53,7 @@ public class ElasticsearchHealthIndicator extends AbstractHealthIndicator { */ public ElasticsearchHealthIndicator(Client client, long responseTimeout, List indices) { - this(client, responseTimeout, (indices == null ? (String[]) null + this(client, responseTimeout, (indices == null ? null : indices.toArray(new String[indices.size()]))); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java index 00ffffd01e..8f1f2f7dcf 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java @@ -299,8 +299,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping @SuppressWarnings("unchecked") private Map getTemplateVariables(ServerWebExchange exchange) { - return (Map) exchange - .getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); + return exchange.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); } private Mono> handleResult(Publisher result, 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 e9919e4f53..86459edf46 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 @@ -359,7 +359,7 @@ public final class ConditionMessage { */ public ConditionMessage items(Style style, Object... items) { return items(style, - items == null ? (Collection) null : Arrays.asList(items)); + items == null ? null : Arrays.asList(items)); } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 1cdaff70ef..ba151099ee 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -265,8 +265,7 @@ public class FlywayAutoConfiguration { private DatabaseDriver getDatabaseDriver() { try { - String url = (String) JdbcUtils.extractDatabaseMetaData(this.dataSource, - "getURL"); + String url = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getURL"); return DatabaseDriver.fromJdbcUrl(url); } catch (MetaDataAccessException ex) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java index e31b7946d3..1347779224 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java @@ -69,7 +69,7 @@ final class DatabaseLookup { return Database.DEFAULT; } try { - String url = (String) JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); + String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); DatabaseDriver driver = DatabaseDriver.fromJdbcUrl(url); Database database = LOOKUP.get(driver); if (database != null) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java index d831e9dab1..6f6d7080c5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java @@ -94,7 +94,7 @@ public final class AnsiColors { private final double b; LabColor(Integer rgb) { - this(rgb == null ? (Color) null : new Color(rgb)); + this(rgb == null ? null : new Color(rgb)); } LabColor(Color color) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java index 21b192c99e..086b426a27 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java @@ -22,7 +22,6 @@ import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import java.util.logging.Logger; -import javax.sql.DataSource; import javax.sql.XAConnection; import javax.sql.XADataSource; @@ -111,7 +110,7 @@ public class PoolingDataSourceBean extends PoolingDataSource @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { try { - return ((DataSource) this).getParentLogger(); + return this.getParentLogger(); } catch (Exception ex) { // Work around https://jira.codehaus.org/browse/BTM-134