Skip to content

Commit 40df7b6

Browse files
committed
Polishing
Issue: SPR-15673
1 parent fa4d139 commit 40df7b6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

spring-beans/src/main/java/org/springframework/beans/BeanUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,33 +320,33 @@ else if (!method.isBridge() && targetMethod.getParameterCount() == numParams) {
320320

321321
/**
322322
* Return the primary constructor of the provided class (single or default constructor
323-
* for Java classes and primary constructor for Kotlin classes) if any.
323+
* for Java classes and primary constructor for Kotlin classes), if any.
324324
* @param clazz the {@link Class} of the Kotlin class
325-
* @see <a href="http://kotlinlang.org/docs/reference/classes.html#constructors">http://kotlinlang.org/docs/reference/classes.html#constructors</a>
326325
* @since 5.0
326+
* @see <a href="http://kotlinlang.org/docs/reference/classes.html#constructors">Kotlin docs</a>
327327
*/
328328
@SuppressWarnings("unchecked")
329329
@Nullable
330330
public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz) {
331331
Assert.notNull(clazz, "Class must not be null");
332332
Constructor<T> ctor = null;
333333
if (kotlinPresent && isKotlinClass(clazz)) {
334-
ctor = KotlinDelegate.findPrimaryConstructor(clazz);
334+
return KotlinDelegate.findPrimaryConstructor(clazz);
335335
}
336336
else {
337-
Constructor<T>[] ctors = (Constructor<T>[])clazz.getConstructors();
337+
Constructor<T>[] ctors = (Constructor<T>[]) clazz.getConstructors();
338338
if (ctors.length == 1) {
339-
ctor = ctors[0];
339+
return ctors[0];
340340
}
341341
else {
342342
try {
343-
ctor = clazz.getDeclaredConstructor();
343+
return clazz.getDeclaredConstructor();
344344
}
345-
catch (NoSuchMethodException e) {
345+
catch (NoSuchMethodException ex) {
346+
return null;
346347
}
347348
}
348349
}
349-
return ctor;
350350
}
351351

352352
/**

0 commit comments

Comments
 (0)