Skip to content

Commit 891cf4f

Browse files
sk-brdebora-ito
andauthored
fix ConcurrentModificationException at v2-migration (#5665)
This fixes a ConcurrentModificationException that occured running the OpenRewrite recipe by replacing a HashMap with a ConcurrentHashMap Co-authored-by: Debora N. Ito <[email protected]>
1 parent d69f640 commit 891cf4f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "bugfix",
3+
"category": "v2-migration OpenRewrite recipe",
4+
"contributor": "sk-br",
5+
"description": "This fixes a ConcurrentModificationException - just by replacing a HashMap with ConcurrentHashMap"
6+
}

v2-migration/src/main/java/software/amazon/awssdk/v2migration/ChangeSdkType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import static software.amazon.awssdk.v2migration.internal.utils.SdkTypeUtils.isV1ModelClass;
2323

2424
import java.util.ArrayList;
25-
import java.util.HashMap;
2625
import java.util.HashSet;
2726
import java.util.IdentityHashMap;
2827
import java.util.List;
2928
import java.util.Map;
3029
import java.util.Optional;
3130
import java.util.Set;
3231
import java.util.Stack;
32+
import java.util.concurrent.ConcurrentHashMap;
3333
import org.openrewrite.ExecutionContext;
3434
import org.openrewrite.Recipe;
3535
import org.openrewrite.TreeVisitor;
@@ -88,7 +88,7 @@ private static class ChangeTypeVisitor extends JavaVisitor<ExecutionContext> {
8888
private final Set<String> topLevelClassnames = new HashSet<>();
8989
private final List<String> wildcardImports = new ArrayList<>();
9090

91-
private Map<String, Pair<JavaType.Class, JavaType>> oldTypeToNewType = new HashMap<>();
91+
private Map<String, Pair<JavaType.Class, JavaType>> oldTypeToNewType = new ConcurrentHashMap<>();
9292

9393
@Override
9494
public J visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) {

0 commit comments

Comments
 (0)