From d20e4f53af58315f2d7d79c235c90b3e76717607 Mon Sep 17 00:00:00 2001 From: emopers Date: Wed, 9 Jan 2019 03:35:27 -0600 Subject: [PATCH 1/2] [LANG-1476] Added sync for iterating over synced set --- src/main/java/org/apache/commons/lang3/CharSet.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/CharSet.java b/src/main/java/org/apache/commons/lang3/CharSet.java index 21e7e175f..3fdfd07d8 100644 --- a/src/main/java/org/apache/commons/lang3/CharSet.java +++ b/src/main/java/org/apache/commons/lang3/CharSet.java @@ -237,9 +237,11 @@ public class CharSet implements Serializable { * @return {@code true} if the set contains the characters */ public boolean contains(final char ch) { - for (final CharRange range : set) { - if (range.contains(ch)) { - return true; + synchronized(set) { + for (final CharRange range : set) { + if (range.contains(ch)) { + return true; + } } } return false; From 2402e66a8c7e635540f7b9f6b39b83b5c812469d Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Tue, 20 Aug 2019 22:04:05 +1200 Subject: [PATCH 2/2] [LANG-1476] Add changes.xml entry --- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 180cc9ae0..905a7b299 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -55,6 +55,7 @@ The type attribute can be add,update,fix,remove. Add ArrayUtils.addFirst() methods. Remove redundant if statements in join methods #411. Trivial: year of release for 3.9 says 2018, should be 2019 + Use synchronise on a set created with Collections.synchronizedSet before iterating