Skip to content

Commit db3cbe0

Browse files
committed
Bump commons-collections4 from 4.5.0-M2 to 4.5.0-M3
1 parent b56b475 commit db3cbe0

File tree

8 files changed

+49
-761
lines changed

8 files changed

+49
-761
lines changed

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<commons.jacoco.complexityRatio>0.61</commons.jacoco.complexityRatio>
6666
<commons.jacoco.lineRatio>0.72</commons.jacoco.lineRatio>
6767
<!-- Dependencies -->
68-
<commons.collections.version>4.5.0-M2</commons.collections.version>
68+
<commons.collections.version>4.5.0-M3-SNAPSHOT</commons.collections.version>
6969
</properties>
7070

7171
<issueManagement>
@@ -102,7 +102,6 @@
102102
<groupId>org.apache.commons</groupId>
103103
<artifactId>commons-collections4</artifactId>
104104
<version>${commons.collections.version}</version>
105-
<scope>test</scope>
106105
</dependency>
107106
<dependency>
108107
<groupId>org.apache.commons</groupId>

src/changes/changes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
Fix SpotBugs [ERROR] Medium: org.apache.commons.beanutils2.WrapDynaClass.getDynaProperties() may expose internal representation by returning WrapDynaClass.properties [org.apache.commons.beanutils2.WrapDynaClass] At WrapDynaClass.java:[line 172] EI_EXPOSE_REP.
105105
</action>
106106
<action dev="ggregory" type="fix" due-to="Melloware, sebbASF, Gary Gregory, Michal Landsman">
107-
Replace Commons Collections Test Framework 3.2.2 with 4.5.0-M2 #40.
107+
Replace Commons Collections Test Framework 3.2.2 with 4.5.0-M3 #40.
108108
</action>
109109
<action dev="ggregory" type="fix" due-to="Gary Gregory">
110110
Provide error index in ConversionException message in DateTimeConverter.parse(Class, Class, String, DateFormat).

src/main/java/org/apache/commons/beanutils2/BeanUtils.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.lang.reflect.InvocationTargetException;
2121
import java.util.Map;
2222

23+
import org.apache.commons.collections4.map.ConcurrentReferenceHashMap;
24+
2325
/**
2426
* <p>
2527
* Utility methods for populating JavaBeans properties via reflection.
@@ -32,7 +34,6 @@
3234
*
3335
* @see BeanUtilsBean
3436
*/
35-
3637
public class BeanUtils {
3738

3839
/** An empty class array */
@@ -43,7 +44,7 @@ public class BeanUtils {
4344

4445
/**
4546
* <p>
46-
* Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.
47+
* Clones a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.
4748
* </p>
4849
*
4950
* <p>
@@ -59,14 +60,12 @@ public class BeanUtils {
5960
* @see BeanUtilsBean#cloneBean
6061
*/
6162
public static Object cloneBean(final Object bean) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
62-
6363
return BeanUtilsBean.getInstance().cloneBean(bean);
64-
6564
}
6665

6766
/**
6867
* <p>
69-
* Copy property values from the origin bean to the destination bean for all cases where the property names are the same.
68+
* Copies property values from the origin bean to the destination bean for all cases where the property names are the same.
7069
* </p>
7170
*
7271
* <p>
@@ -82,7 +81,6 @@ public static Object cloneBean(final Object bean) throws IllegalAccessException,
8281
* @see BeanUtilsBean#copyProperties
8382
*/
8483
public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException {
85-
8684
BeanUtilsBean.getInstance().copyProperties(dest, orig);
8785
}
8886

@@ -103,20 +101,20 @@ public static void copyProperties(final Object dest, final Object orig) throws I
103101
* @see BeanUtilsBean#copyProperty
104102
*/
105103
public static void copyProperty(final Object bean, final String name, final Object value) throws IllegalAccessException, InvocationTargetException {
106-
107104
BeanUtilsBean.getInstance().copyProperty(bean, name, value);
108105
}
109106

110107
/**
111-
* Create a cache.
108+
* Creates a cache.
112109
*
113110
* @param <K> the key type of the cache
114111
* @param <V> the value type of the cache
115112
* @return a new cache
116113
* @since 1.8.0
117114
*/
118115
public static <K, V> Map<K, V> createCache() {
119-
return new WeakFastHashMap<>();
116+
return ConcurrentReferenceHashMap.<K, V>builder().get();
117+
// return new ConcurrentHashMap<>();
120118
}
121119

122120
/**
@@ -136,7 +134,6 @@ public static <K, V> Map<K, V> createCache() {
136134
* @see BeanUtilsBean#describe
137135
*/
138136
public static Map<String, String> describe(final Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
139-
140137
return BeanUtilsBean.getInstance().describe(bean);
141138
}
142139

@@ -159,7 +156,6 @@ public static Map<String, String> describe(final Object bean) throws IllegalAcce
159156
*/
160157
public static String[] getArrayProperty(final Object bean, final String name)
161158
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
162-
163159
return BeanUtilsBean.getInstance().getArrayProperty(bean, name);
164160
}
165161

@@ -182,7 +178,6 @@ public static String[] getArrayProperty(final Object bean, final String name)
182178
*/
183179
public static String getIndexedProperty(final Object bean, final String name)
184180
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
185-
186181
return BeanUtilsBean.getInstance().getIndexedProperty(bean, name);
187182

188183
}
@@ -206,7 +201,6 @@ public static String getIndexedProperty(final Object bean, final String name)
206201
*/
207202
public static String getIndexedProperty(final Object bean, final String name, final int index)
208203
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
209-
210204
return BeanUtilsBean.getInstance().getIndexedProperty(bean, name, index);
211205

212206
}
@@ -230,7 +224,6 @@ public static String getIndexedProperty(final Object bean, final String name, fi
230224
*/
231225
public static String getMappedProperty(final Object bean, final String name)
232226
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
233-
234227
return BeanUtilsBean.getInstance().getMappedProperty(bean, name);
235228

236229
}
@@ -255,7 +248,6 @@ public static String getMappedProperty(final Object bean, final String name)
255248
*/
256249
public static String getMappedProperty(final Object bean, final String name, final String key)
257250
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
258-
259251
return BeanUtilsBean.getInstance().getMappedProperty(bean, name, key);
260252

261253
}
@@ -280,7 +272,6 @@ public static String getMappedProperty(final Object bean, final String name, fin
280272
*/
281273
public static String getNestedProperty(final Object bean, final String name)
282274
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
283-
284275
return BeanUtilsBean.getInstance().getNestedProperty(bean, name);
285276

286277
}
@@ -303,7 +294,6 @@ public static String getNestedProperty(final Object bean, final String name)
303294
* @see BeanUtilsBean#getProperty
304295
*/
305296
public static String getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
306-
307297
return BeanUtilsBean.getInstance().getProperty(bean, name);
308298

309299
}
@@ -327,7 +317,6 @@ public static String getProperty(final Object bean, final String name) throws Il
327317
*/
328318
public static String getSimpleProperty(final Object bean, final String name)
329319
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
330-
331320
return BeanUtilsBean.getInstance().getSimpleProperty(bean, name);
332321

333322
}
@@ -348,7 +337,6 @@ public static String getSimpleProperty(final Object bean, final String name)
348337
* @see BeanUtilsBean#populate
349338
*/
350339
public static void populate(final Object bean, final Map<String, ? extends Object> properties) throws IllegalAccessException, InvocationTargetException {
351-
352340
BeanUtilsBean.getInstance().populate(bean, properties);
353341
}
354342

@@ -369,7 +357,6 @@ public static void populate(final Object bean, final Map<String, ? extends Objec
369357
* @see BeanUtilsBean#setProperty
370358
*/
371359
public static void setProperty(final Object bean, final String name, final Object value) throws IllegalAccessException, InvocationTargetException {
372-
373360
BeanUtilsBean.getInstance().setProperty(bean, name, value);
374361
}
375362
}

src/main/java/org/apache/commons/beanutils2/ConvertUtilsBean.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.Calendar;
4646
import java.util.Collection;
4747
import java.util.Locale;
48+
import java.util.Map;
4849
import java.util.Objects;
4950
import java.util.UUID;
5051
import java.util.regex.Pattern;
@@ -215,13 +216,11 @@ protected static ConvertUtilsBean getInstance() {
215216
/**
216217
* The set of {@link Converter}s that can be used to convert Strings into objects of a specified Class, keyed by the destination Class.
217218
*/
218-
private final WeakFastHashMap<Class<?>, Converter<?>> converters = new WeakFastHashMap<>();
219+
private final Map<Class<?>, Converter<?>> converters = BeanUtils.createCache();
219220

220221
/** Constructs a bean with standard converters registered */
221222
public ConvertUtilsBean() {
222-
converters.setFast(false);
223223
deregister();
224-
converters.setFast(true);
225224
}
226225

227226
/**

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,17 @@ private static Map<String, Object> toPropertyMap(final Object obj) {
112112
/**
113113
* The cache of PropertyDescriptor arrays for beans we have already introspected, keyed by the java.lang.Class of this object.
114114
*/
115-
private final WeakFastHashMap<Class<?>, BeanIntrospectionData> descriptorsCache;
115+
private final Map<Class<?>, BeanIntrospectionData> descriptorsCache;
116116

117-
private final WeakFastHashMap<Class<?>, Map> mappedDescriptorsCache;
117+
private final Map<Class<?>, Map> mappedDescriptorsCache;
118118

119119
/** The list with BeanIntrospector objects. */
120120
private final List<BeanIntrospector> introspectors;
121121

122122
/** Base constructor */
123123
public PropertyUtilsBean() {
124-
descriptorsCache = new WeakFastHashMap<>();
125-
descriptorsCache.setFast(true);
126-
mappedDescriptorsCache = new WeakFastHashMap<>();
127-
mappedDescriptorsCache.setFast(true);
124+
descriptorsCache = BeanUtils.createCache();
125+
mappedDescriptorsCache = BeanUtils.createCache();
128126
introspectors = new CopyOnWriteArrayList<>();
129127
resetBeanIntrospectors();
130128
}

0 commit comments

Comments
 (0)