From ffc577b499eaebe08a680cc7ad58c4e986bd71b4 Mon Sep 17 00:00:00 2001 From: EruDev Date: Thu, 27 Aug 2020 17:13:58 +0800 Subject: [PATCH 1/2] Simplify code See gh-23111 --- .../filter/AnnotationCustomizableTypeExcludeFilter.java | 5 +---- .../web/servlet/WebDriverContextCustomizerFactory.java | 5 +---- .../boot/gradle/tasks/buildinfo/BuildInfoProperties.java | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java index d9670c1ce0..1e4c7aeffe 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java @@ -61,10 +61,7 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud metadataReaderFactory)) { return true; } - if (isUseDefaultFilters() && defaultInclude(metadataReader, metadataReaderFactory)) { - return true; - } - return false; + return isUseDefaultFilters() && defaultInclude(metadataReader, metadataReaderFactory); } protected boolean defaultInclude(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java index 2c2daad574..e0b0b1d52c 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java @@ -53,10 +53,7 @@ class WebDriverContextCustomizerFactory implements ContextCustomizerFactory { if (obj == this) { return true; } - if (obj == null || obj.getClass() != getClass()) { - return false; - } - return true; + return obj != null && obj.getClass() == getClass(); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java index 2a72555295..94270c1212 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java @@ -56,7 +56,7 @@ public class BuildInfoProperties implements Serializable { this.version = project.getObjects().property(String.class); this.version.set(project.provider(() -> project.getVersion().toString())); this.name = project.getObjects().property(String.class); - this.name.set(project.provider(() -> project.getName())); + this.name.set(project.provider(project::getName)); } /** From 5a86162ff30433b8f54851842e0432a479719fd5 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 1 Sep 2020 10:06:17 +0200 Subject: [PATCH 2/2] Polish "Simplify code" See gh-23111 --- .../filter/AnnotationCustomizableTypeExcludeFilter.java | 2 +- .../web/servlet/WebDriverContextCustomizerFactory.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java index 1e4c7aeffe..94640ff18f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java index e0b0b1d52c..2c2daad574 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java @@ -53,7 +53,10 @@ class WebDriverContextCustomizerFactory implements ContextCustomizerFactory { if (obj == this) { return true; } - return obj != null && obj.getClass() == getClass(); + if (obj == null || obj.getClass() != getClass()) { + return false; + } + return true; } @Override