From e26cdfe21e05be54855b43c517e72532b551238f Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 4 Sep 2019 10:00:13 +0200 Subject: [PATCH 1/4] Fix Artifactory Gradle plugin configuration --- gradle/publish-maven.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle/publish-maven.gradle b/gradle/publish-maven.gradle index 4813ce71d1..9cf0723323 100644 --- a/gradle/publish-maven.gradle +++ b/gradle/publish-maven.gradle @@ -61,5 +61,7 @@ def customizePom(pom, gradleProject) { } artifactoryPublish { - publishConfigs('archives') + publishConfigs('archives', 'published') + publishArtifacts = true + publishPom = true } From 1187fea65cb044456aa5c0e957de14b3474ae148 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 4 Sep 2019 10:26:22 +0200 Subject: [PATCH 2/4] Fix Artifactory Gradle plugin configuration This commit adds a missing dependency from the artifactoryPublish task to the "install" task as POMs are currently missing from the published artifacts and they are generated with the "install" task here. --- gradle/publish-maven.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle/publish-maven.gradle b/gradle/publish-maven.gradle index 9cf0723323..897ef12b66 100644 --- a/gradle/publish-maven.gradle +++ b/gradle/publish-maven.gradle @@ -61,6 +61,7 @@ def customizePom(pom, gradleProject) { } artifactoryPublish { + dependsOn install publishConfigs('archives', 'published') publishArtifacts = true publishPom = true From 3a132f8c3c2f3b5830c0ae03fd3b751c10f6ae40 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 4 Sep 2019 11:21:41 +0200 Subject: [PATCH 3/4] Revert Artifactory Gradle plugin configuration This commit reverts all artifactory configuration changes in this branch. A new build plan has been created for the master branch which is tailored for the latest Gradle changes made on that branch. --- build.gradle | 1 - gradle/publish-maven.gradle | 8 -------- 2 files changed, 9 deletions(-) diff --git a/build.gradle b/build.gradle index e2c916b40f..0b9bdc234f 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,6 @@ plugins { id "org.jetbrains.kotlin.jvm" version "1.2.71" apply false id "org.jetbrains.dokka" version "0.9.18" id "org.asciidoctor.convert" version "1.5.8" - id "com.jfrog.artifactory" version '4.9.8' apply false } ext { diff --git a/gradle/publish-maven.gradle b/gradle/publish-maven.gradle index 897ef12b66..dad95c8452 100644 --- a/gradle/publish-maven.gradle +++ b/gradle/publish-maven.gradle @@ -1,5 +1,4 @@ apply plugin: "propdeps-maven" -apply plugin: 'com.jfrog.artifactory' install { repositories.mavenInstaller { @@ -59,10 +58,3 @@ def customizePom(pom, gradleProject) { } } } - -artifactoryPublish { - dependsOn install - publishConfigs('archives', 'published') - publishArtifacts = true - publishPom = true -} From d036b5a283a7a2a66639a994d37c54f1530a2a3a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 4 Sep 2019 15:48:40 +0200 Subject: [PATCH 4/4] Do not treat void and Void as simple types in BeanUtils Prior to this commit, the isSimpleProperty() and isSimpleValueType() methods in BeanUtils treated void and Void as simple types; however, doing so does not make sense in this context, since void implies the lack of a property or value. This commit addresses this by explicitly excluding void and Void in the logic in isSimpleValueType(). This commit also simplifies the implementation of ViewResolutionResultHandler.supports(HandlerResult) to take advantage of this change. Closes gh-23573 --- .../org/springframework/beans/BeanUtils.java | 47 ++++++------ .../springframework/beans/BeanUtilsTests.java | 71 ++++++++++++++++++- .../view/ViewResolutionResultHandler.java | 8 ++- 3 files changed, 101 insertions(+), 25 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java index 3e3249ef46..ea0b8d2ace 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -554,35 +554,42 @@ public abstract class BeanUtils { } /** - * Check if the given type represents a "simple" property: - * a primitive, a String or other CharSequence, a Number, a Date, - * a URI, a URL, a Locale, a Class, or a corresponding array. + * Check if the given type represents a "simple" property: a simple value + * type or an array of simple value types. + *

See {@link #isSimpleValueType(Class)} for the definition of simple + * value type. *

Used to determine properties to check for a "simple" dependency-check. - * @param clazz the type to check + * @param type the type to check * @return whether the given type represents a "simple" property * @see org.springframework.beans.factory.support.RootBeanDefinition#DEPENDENCY_CHECK_SIMPLE * @see org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#checkDependencies + * @see #isSimpleValueType(Class) */ - public static boolean isSimpleProperty(Class clazz) { - Assert.notNull(clazz, "Class must not be null"); - return isSimpleValueType(clazz) || (clazz.isArray() && isSimpleValueType(clazz.getComponentType())); + public static boolean isSimpleProperty(Class type) { + Assert.notNull(type, "'type' must not be null"); + return isSimpleValueType(type) || (type.isArray() && isSimpleValueType(type.getComponentType())); } /** - * Check if the given type represents a "simple" value type: - * a primitive, an enum, a String or other CharSequence, a Number, a Date, - * a URI, a URL, a Locale or a Class. - * @param clazz the type to check + * Check if the given type represents a "simple" value type: a primitive or + * primitive wrapper, an enum, a String or other CharSequence, a Number, a + * Date, a URI, a URL, a Locale, or a Class. + *

{@code Void} and {@code void} are not considered simple value types. + * @param type the type to check * @return whether the given type represents a "simple" value type + * @see #isSimpleProperty(Class) */ - public static boolean isSimpleValueType(Class clazz) { - return (ClassUtils.isPrimitiveOrWrapper(clazz) || - Enum.class.isAssignableFrom(clazz) || - CharSequence.class.isAssignableFrom(clazz) || - Number.class.isAssignableFrom(clazz) || - Date.class.isAssignableFrom(clazz) || - URI.class == clazz || URL.class == clazz || - Locale.class == clazz || Class.class == clazz); + public static boolean isSimpleValueType(Class type) { + return (type != void.class && type != Void.class && + (ClassUtils.isPrimitiveOrWrapper(type) || + Enum.class.isAssignableFrom(type) || + CharSequence.class.isAssignableFrom(type) || + Number.class.isAssignableFrom(type) || + Date.class.isAssignableFrom(type) || + URI.class == type || + URL.class == type || + Locale.class == type || + Class.class == type)); } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java index 2d8a90788e..f1a17bd567 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -19,8 +19,14 @@ package org.springframework.beans; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; +import java.net.URI; +import java.net.URL; +import java.time.DayOfWeek; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.Locale; +import java.util.stream.Stream; import org.junit.Test; @@ -32,7 +38,12 @@ import org.springframework.tests.sample.beans.DerivedTestBean; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Unit tests for {@link BeanUtils}. @@ -40,6 +51,7 @@ import static org.junit.Assert.*; * @author Juergen Hoeller * @author Rob Harrop * @author Chris Beams + * @author Sam Brannen * @since 19.05.2003 */ public class BeanUtilsTests { @@ -275,6 +287,60 @@ public class BeanUtilsTests { } } + @Test + public void isSimpleValueType() { + Stream.of( + + boolean.class, char.class, byte.class, short.class, int.class, + long.class, float.class, double.class, + + Boolean.class, Character.class, Byte.class, Short.class, Integer.class, + Long.class, Float.class, Double.class, + + DayOfWeek.class, String.class, Date.class, URI.class, URL.class, Locale.class, Class.class + + ).forEach(this::assertIsSimpleValueType); + + Stream.of(int[].class, Object.class, List.class, void.class, Void.class) + .forEach(this::assertIsNotSimpleValueType); + } + + @Test + public void isSimpleProperty() { + Stream.of( + + boolean.class, char.class, byte.class, short.class, int.class, + long.class, float.class, double.class, + + Boolean.class, Character.class, Byte.class, Short.class, Integer.class, + Long.class, Float.class, Double.class, + + DayOfWeek.class, String.class, Date.class, URI.class, URL.class, Locale.class, Class.class, + + boolean[].class, Boolean[].class, Date[].class + + ).forEach(this::assertIsSimpleProperty); + + Stream.of(Object.class, List.class, void.class, Void.class) + .forEach(this::assertIsNotSimpleProperty); + } + + private void assertIsSimpleValueType(Class type) { + assertTrue("Type [" + type.getName() + "] should be a simple value type", BeanUtils.isSimpleValueType(type)); + } + + private void assertIsNotSimpleValueType(Class type) { + assertFalse("Type [" + type.getName() + "] should not be a simple value type", BeanUtils.isSimpleValueType(type)); + } + + private void assertIsSimpleProperty(Class type) { + assertTrue("Type [" + type.getName() + "] should be a simple property", BeanUtils.isSimpleProperty(type)); + } + + private void assertIsNotSimpleProperty(Class type) { + assertFalse("Type [" + type.getName() + "] should not be a simple property", BeanUtils.isSimpleProperty(type)); + } + private void assertSignatureEquals(Method desiredMethod, String signature) { assertEquals(desiredMethod, BeanUtils.resolveSignature(signature, MethodSignatureBean.class)); } @@ -445,6 +511,7 @@ public class BeanUtilsTests { } } + @SuppressWarnings("unused") private static class BeanWithSingleNonDefaultConstructor { private final String name; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java index 66637a2ac8..19ca29f61c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java @@ -160,9 +160,11 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport type = result.getReturnType().getGeneric().toClass(); } - return (CharSequence.class.isAssignableFrom(type) || Rendering.class.isAssignableFrom(type) || - Model.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type) || - Void.class.equals(type) || void.class.equals(type) || View.class.isAssignableFrom(type) || + return (CharSequence.class.isAssignableFrom(type) || + Rendering.class.isAssignableFrom(type) || + Model.class.isAssignableFrom(type) || + Map.class.isAssignableFrom(type) || + View.class.isAssignableFrom(type) || !BeanUtils.isSimpleProperty(type)); }