Skip to content

Commit

Permalink
fix ConcurrentModificationException at v2-migration (#5665)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sk-br and debora-ito authored Nov 22, 2024
1 parent d69f640 commit 891cf4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "v2-migration OpenRewrite recipe",
"contributor": "sk-br",
"description": "This fixes a ConcurrentModificationException - just by replacing a HashMap with ConcurrentHashMap"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import static software.amazon.awssdk.v2migration.internal.utils.SdkTypeUtils.isV1ModelClass;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
Expand Down Expand Up @@ -88,7 +88,7 @@ private static class ChangeTypeVisitor extends JavaVisitor<ExecutionContext> {
private final Set<String> topLevelClassnames = new HashSet<>();
private final List<String> wildcardImports = new ArrayList<>();

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

@Override
public J visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) {
Expand Down

0 comments on commit 891cf4f

Please sign in to comment.