From 9ff0d717f2b0c56ff78701d62c88c1cc82cdce1a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 27 Sep 2021 16:52:11 +0200 Subject: [PATCH] Restore lenient fallback in case of several non-public constructors See gh-27437 --- .../java/org/springframework/beans/BeanUtils.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 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 f7708247d7..9483d18871 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -254,14 +254,13 @@ public abstract class BeanUtils { return (Constructor) ctors[0]; } } - else { - // Several public constructors -> let's take the default constructor - try { - return clazz.getDeclaredConstructor(); - } - catch (NoSuchMethodException ex) { - // Giving up... - } + + // Several constructors -> let's try to take the default constructor + try { + return clazz.getDeclaredConstructor(); + } + catch (NoSuchMethodException ex) { + // Giving up... } // No unique constructor at all