Skip to content

Commit fd68fb1

Browse files
committed
Backport of recent ExtendedBeanInfo refinements from master
Closes gh-24095
1 parent 43e047c commit fd68fb1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,8 +41,8 @@
4141

4242
/**
4343
* Decorator for a standard {@link BeanInfo} object, e.g. as created by
44-
* {@link Introspector#getBeanInfo(Class)}, designed to discover and register static
45-
* and/or non-void returning setter methods. For example:
44+
* {@link Introspector#getBeanInfo(Class)}, designed to discover and register
45+
* static and/or non-void returning setter methods. For example:
4646
*
4747
* <pre class="code">
4848
* public class Bean {
@@ -145,11 +145,10 @@ private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescript
145145

146146
public static boolean isCandidateWriteMethod(Method method) {
147147
String methodName = method.getName();
148-
Class<?>[] parameterTypes = method.getParameterTypes();
149-
int nParams = parameterTypes.length;
148+
int nParams = method.getParameterCount();
150149
return (methodName.length() > 3 && methodName.startsWith("set") && Modifier.isPublic(method.getModifiers()) &&
151150
(!void.class.isAssignableFrom(method.getReturnType()) || Modifier.isStatic(method.getModifiers())) &&
152-
(nParams == 1 || (nParams == 2 && int.class == parameterTypes[0])));
151+
(nParams == 1 || (nParams == 2 && int.class == method.getParameterTypes()[0])));
153152
}
154153

155154
private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
@@ -209,7 +208,7 @@ private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, C
209208
}
210209

211210
private String propertyNameFor(Method method) {
212-
return Introspector.decapitalize(method.getName().substring(3, method.getName().length()));
211+
return Introspector.decapitalize(method.getName().substring(3));
213212
}
214213

215214

@@ -488,7 +487,7 @@ public void setPropertyEditorClass(@Nullable Class<?> propertyEditorClass) {
488487
}
489488

490489
/*
491-
* See java.beans.IndexedPropertyDescriptor#equals(java.lang.Object)
490+
* See java.beans.IndexedPropertyDescriptor#equals
492491
*/
493492
@Override
494493
public boolean equals(Object other) {
@@ -535,11 +534,13 @@ static class PropertyDescriptorComparator implements Comparator<PropertyDescript
535534
public int compare(PropertyDescriptor desc1, PropertyDescriptor desc2) {
536535
String left = desc1.getName();
537536
String right = desc2.getName();
537+
byte[] leftBytes = left.getBytes();
538+
byte[] rightBytes = right.getBytes();
538539
for (int i = 0; i < left.length(); i++) {
539540
if (right.length() == i) {
540541
return 1;
541542
}
542-
int result = left.getBytes()[i] - right.getBytes()[i];
543+
int result = leftBytes[i] - rightBytes[i];
543544
if (result != 0) {
544545
return result;
545546
}

0 commit comments

Comments
 (0)