From ba46e77169ac1a5fa92dee8345ba002bbf5918ba Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Sun, 24 Jun 2018 17:45:37 +0200 Subject: [PATCH] Optimize checks for java classes in Binder Closes gh-13567 --- .../springframework/boot/context/properties/bind/Binder.java | 4 +--- .../boot/context/properties/bind/MapBinder.java | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java index f0d34b345e..12295d5cfa 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java @@ -45,7 +45,6 @@ import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.core.env.Environment; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; /** * A container object which Binds objects from one or more @@ -354,8 +353,7 @@ public class Binder { if (resolved.isPrimitive() || NON_BEAN_CLASSES.contains(resolved)) { return true; } - String packageName = ClassUtils.getPackageName(resolved); - return packageName.startsWith("java."); + return resolved.getName().startsWith("java."); } private boolean containsNoDescendantOf(Stream sources, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java index 8aaa5c0c79..07717364fc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java @@ -30,7 +30,6 @@ import org.springframework.boot.context.properties.source.ConfigurationPropertyS import org.springframework.boot.context.properties.source.IterableConfigurationPropertySource; import org.springframework.core.CollectionFactory; import org.springframework.core.ResolvableType; -import org.springframework.util.ClassUtils; /** * {@link AggregateBinder} for Maps. @@ -199,8 +198,7 @@ class MapBinder extends AggregateBinder> { private boolean isScalarValue(ConfigurationPropertySource source, ConfigurationPropertyName name) { Class resolved = this.valueType.resolve(Object.class); - String packageName = ClassUtils.getPackageName(resolved); - if (!packageName.startsWith("java.lang") && !resolved.isEnum()) { + if (!resolved.getName().startsWith("java.lang") && !resolved.isEnum()) { return false; } ConfigurationProperty property = source.getConfigurationProperty(name);