Skip to content

Commit e4894f8

Browse files
committed
Use final
- Use direct references - Add missing @deprecated - Merge test expressions with the same outcome
1 parent 00e08c9 commit e4894f8

File tree

9 files changed

+13
-19
lines changed

9 files changed

+13
-19
lines changed

src/main/java/org/apache/commons/beanutils/ConstructorUtils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,8 @@ public static <T> Constructor<T> getAccessibleConstructor(
9090
public static <T> Constructor<T> getAccessibleConstructor(final Constructor<T> ctor) {
9191

9292
// Make sure we have a method to check
93-
if (ctor == null) {
94-
return null;
95-
}
96-
9793
// If the requested method is not public we cannot call it
98-
if (!Modifier.isPublic(ctor.getModifiers())) {
94+
if (ctor == null || !Modifier.isPublic(ctor.getModifiers())) {
9995
return null;
10096
}
10197

src/main/java/org/apache/commons/beanutils/ConversionException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class ConversionException extends RuntimeException {
3232
*
3333
* @deprecated Use {@link Throwable#getCause()}}.
3434
*/
35+
@Deprecated
3536
protected Throwable cause;
3637

3738
/**

src/main/java/org/apache/commons/beanutils/MethodUtils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,8 @@ public static synchronized int clearCache() {
206206
public static Method getAccessibleMethod(Class<?> clazz, Method method) {
207207

208208
// Make sure we have a method to check
209-
if (method == null) {
210-
return null;
211-
}
212-
213209
// If the requested method is not public we cannot call it
214-
if (!Modifier.isPublic(method.getModifiers())) {
210+
if (method == null || !Modifier.isPublic(method.getModifiers())) {
215211
return null;
216212
}
217213

src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ private static Map<String, Object> toPropertyMap(final Object obj) {
136136
* The cache of PropertyDescriptor arrays for beans we have already
137137
* introspected, keyed by the java.lang.Class of this object.
138138
*/
139-
private WeakFastHashMap<Class<?>, BeanIntrospectionData> descriptorsCache;
139+
private final WeakFastHashMap<Class<?>, BeanIntrospectionData> descriptorsCache;
140140

141-
private WeakFastHashMap<Class<?>, FastHashMap> mappedDescriptorsCache;
141+
private final WeakFastHashMap<Class<?>, FastHashMap> mappedDescriptorsCache;
142142

143143

144144
/** Log instance */

src/main/java/org/apache/commons/beanutils/WrapDynaClass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ private static Map<Object, Object> getDynaClassesMap() {
269269
/**
270270
* Name of the JavaBean class represented by this WrapDynaClass.
271271
*/
272-
private String beanClassName;
272+
private final String beanClassName;
273273

274274
/**
275275
* Reference to the JavaBean class represented by this WrapDynaClass.
276276
*/
277-
private Reference<Class<?>> beanClassRef;
277+
private final Reference<Class<?>> beanClassRef;
278278

279279
/** Stores the associated {@code PropertyUtilsBean} instance. */
280280
private final PropertyUtilsBean propertyUtilsBean;

src/test/java/org/apache/commons/beanutils/converters/BooleanArrayConverterTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testAdditionalStrings() {
5757
final BooleanConverter bc = new BooleanConverter(
5858
trueStrings, falseStrings, BooleanConverter.NO_DEFAULT);
5959
final BooleanArrayConverter converter = new BooleanArrayConverter(
60-
bc, BooleanArrayConverter.NO_DEFAULT);
60+
bc, AbstractArrayConverter.NO_DEFAULT);
6161

6262
final boolean[] results = (boolean[]) converter.convert(null, "NOPE, sure, sure");
6363
assertNotNull(results);
@@ -162,7 +162,7 @@ public void testRegistration() {
162162
trueStrings, falseStrings, BooleanConverter.NO_DEFAULT);
163163

164164
final BooleanArrayConverter converter = new BooleanArrayConverter(
165-
bc, BooleanArrayConverter.NO_DEFAULT);
165+
bc, AbstractArrayConverter.NO_DEFAULT);
166166

167167
ConvertUtils.register(converter, BooleanArrayConverter.MODEL);
168168
final boolean[] sample = {};

src/test/java/org/apache/commons/beanutils/converters/SqlTimeConverterTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected Class<?> getExpectedType() {
6363

6464
private boolean isUSTimeFormatWithNarrowNoBreakSpace() {
6565
// Fix tests on Java 20 onwards. See https://bugs.openjdk.org/browse/JDK-8324308 for background.
66-
DateFormat usDateFormat = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
66+
final DateFormat usDateFormat = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
6767
return ((SimpleDateFormat) usDateFormat).toPattern().contains("\u202F");
6868
}
6969

src/test/java/org/apache/commons/beanutils/converters/SqlTimestampConverterTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private boolean isUSFormatWithComma() {
6969

7070
private boolean isUSTimeFormatWithNarrowNoBreakSpace() {
7171
// Fix tests on Java 20 onwards. See https://bugs.openjdk.org/browse/JDK-8324308 for background.
72-
DateFormat usDateFormat = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
72+
final DateFormat usDateFormat = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
7373
return ((SimpleDateFormat) usDateFormat).toPattern().contains("\u202F");
7474
}
7575

src/test/java/org/apache/commons/beanutils/locale/LocaleBeanificationTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Map;
2424
import java.util.WeakHashMap;
2525

26+
import org.apache.commons.beanutils.BeanUtilsBean;
2627
import org.apache.commons.beanutils.ContextClassLoaderLocal;
2728
import org.apache.commons.beanutils.ConversionException;
2829
import org.apache.commons.beanutils.ConvertUtils;
@@ -361,7 +362,7 @@ public String toString() {
361362
assertEquals("Signal not set by test thread", 2, signal.getSignal());
362363
assertTrue(
363364
"Different LocaleBeanUtilsBean instances per context classloader",
364-
LocaleBeanUtilsBean.getInstance() != signal.getBean());
365+
BeanUtilsBean.getInstance() != signal.getBean());
365366
assertTrue(
366367
"Different LocaleConvertUtilsBean instances per context classloader",
367368
LocaleConvertUtilsBean.getInstance() != signal.getConvertUtils());

0 commit comments

Comments
 (0)