From b8706c47d637c76ff9a7c4d92c81bb5f35b4dc64 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Sun, 7 Jan 2018 10:19:08 +0900 Subject: [PATCH] Use instance equality for Class Closes gh-11534 --- .../boot/autoconfigure/AutoConfigurationImportSelector.java | 4 ++-- .../filter/TypeExcludeFiltersContextCustomizer.java | 4 ++-- .../properties/PropertyMappingContextCustomizer.java | 4 ++-- .../TypeExcludeFiltersContextCustomizerFactoryTests.java | 4 ++-- .../boot/test/autoconfigure/json/app/ExampleBasicObject.java | 4 ++-- .../boot/test/autoconfigure/json/app/ExampleCustomObject.java | 4 ++-- .../boot/test/context/ImportsContextCustomizer.java | 4 ++-- .../springframework/boot/test/util/TestPropertyValues.java | 4 ++-- .../org/springframework/boot/context/TypeExcludeFilter.java | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java index 74731736ce..8b1ebe1ef0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.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. @@ -108,7 +108,7 @@ public class AutoConfigurationImportSelector } protected boolean isEnabled(AnnotationMetadata metadata) { - if (getClass().equals(AutoConfigurationImportSelector.class)) { + if (getClass() == AutoConfigurationImportSelector.class) { return getEnvironment().getProperty( EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY, Boolean.class, true); diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java index fc2e9e25fb..a3df07bf13 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.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. @@ -80,7 +80,7 @@ class TypeExcludeFiltersContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - return (obj != null && getClass().equals(obj.getClass()) && this.filters + return (obj != null && getClass() == obj.getClass() && this.filters .equals(((TypeExcludeFiltersContextCustomizer) obj).filters)); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java index dd98f974bc..cce4c141b7 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.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. @@ -62,7 +62,7 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - return (obj != null && getClass().equals(obj.getClass()) && this.propertySource + return (obj != null && getClass() == obj.getClass() && this.propertySource .equals(((PropertyMappingContextCustomizer) obj).propertySource)); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java index b114e0b92b..a375465fce 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.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. @@ -125,7 +125,7 @@ public class TypeExcludeFiltersContextCustomizerFactoryTests { @Override public boolean equals(Object obj) { - return obj.getClass().equals(getClass()); + return obj.getClass() == getClass(); } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java index 74b27023d9..8d99d71ea4 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.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. @@ -40,7 +40,7 @@ public class ExampleBasicObject { @Override public boolean equals(Object obj) { - if (obj != null && obj.getClass().equals(getClass())) { + if (obj != null && obj.getClass() == getClass()) { return this.value.equals(((ExampleBasicObject) obj).value); } return false; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java index f25b04c02f..3376f45e5f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.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. @@ -36,7 +36,7 @@ public class ExampleCustomObject { @Override public boolean equals(Object obj) { - if (obj != null && obj.getClass().equals(getClass())) { + if (obj != null && obj.getClass() == getClass()) { return this.value.equals(((ExampleCustomObject) obj).value); } return false; diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index a5c241e0ee..6fc78d9c00 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.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. @@ -346,7 +346,7 @@ class ImportsContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - return (obj != null && getClass().equals(obj.getClass()) + return (obj != null && getClass() == obj.getClass() && this.key.equals(((ContextCustomizerKey) obj).key)); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index 2034bda497..b3cd764a85 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.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. @@ -144,7 +144,7 @@ public final class TestPropertyValues { private void addToSources(MutablePropertySources sources, Type type, String name) { if (sources.contains(name)) { PropertySource propertySource = sources.get(name); - if (propertySource.getClass().equals(type.getSourceClass())) { + if (propertySource.getClass() == type.getSourceClass()) { ((Map) propertySource.getSource()) .putAll(this.properties); return; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/TypeExcludeFilter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/TypeExcludeFilter.java index 53853058f8..987bd372cf 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/TypeExcludeFilter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/TypeExcludeFilter.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. @@ -60,7 +60,7 @@ public class TypeExcludeFilter implements TypeFilter, BeanFactoryAware { public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { if (this.beanFactory instanceof ListableBeanFactory - && getClass().equals(TypeExcludeFilter.class)) { + && getClass() == TypeExcludeFilter.class) { Collection delegates = ((ListableBeanFactory) this.beanFactory) .getBeansOfType(TypeExcludeFilter.class).values(); for (TypeExcludeFilter delegate : delegates) {