5959 */
6060public class JUnitAssertEqualsToAssertThat extends Recipe {
6161
62- private static final JavaParser ASSERTJ_JAVA_PARSER = JavaParser .fromJavaVersion ().dependsOn (
63- Parser .Input .fromResource ("/META-INF/rewrite/AssertJAssertions.java" , "---" )
64- ).build ();
62+ private static final ThreadLocal <JavaParser > ASSERTJ_JAVA_PARSER = ThreadLocal .withInitial (() ->
63+ JavaParser .fromJavaVersion ().dependsOn (
64+ Parser .Input .fromResource ("/META-INF/rewrite/AssertJAssertions.java" , "---" )
65+ ).build ()
66+ );
6567
6668 @ Override
6769 public String getDisplayName () {
@@ -109,7 +111,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
109111 method = method .withTemplate (
110112 template ("assertThat(#{}).isEqualTo(#{});" )
111113 .staticImports ("org.assertj.core.api.Assertions.assertThat" )
112- .javaParser (ASSERTJ_JAVA_PARSER )
114+ .javaParser (ASSERTJ_JAVA_PARSER . get () )
113115 .build (),
114116 method .getCoordinates ().replace (),
115117 actual ,
@@ -124,7 +126,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
124126 method = method .withTemplate (
125127 template ("assertThat(#{}).#{}(#{}).isEqualTo(#{});" )
126128 .staticImports ("org.assertj.core.api.Assertions.assertThat" )
127- .javaParser (ASSERTJ_JAVA_PARSER )
129+ .javaParser (ASSERTJ_JAVA_PARSER . get () )
128130 .build (),
129131 method .getCoordinates ().replace (),
130132 actual ,
@@ -136,7 +138,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
136138 method = method .withTemplate (
137139 template ("assertThat(#{}).isCloseTo(#{}, within(#{}));" )
138140 .staticImports ("org.assertj.core.api.Assertions.assertThat" , "org.assertj.core.api.Assertions.within" )
139- .javaParser (ASSERTJ_JAVA_PARSER )
141+ .javaParser (ASSERTJ_JAVA_PARSER . get () )
140142 .build (),
141143 method .getCoordinates ().replace (),
142144 actual ,
@@ -155,7 +157,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
155157 method = method .withTemplate (
156158 template ("assertThat(#{}).#{}(#{}).isCloseTo(#{}, within(#{}));" )
157159 .staticImports ("org.assertj.core.api.Assertions.assertThat" , "org.assertj.core.api.Assertions.within" )
158- .javaParser (ASSERTJ_JAVA_PARSER )
160+ .javaParser (ASSERTJ_JAVA_PARSER . get () )
159161 .build (),
160162 method .getCoordinates ().replace (),
161163 actual ,
0 commit comments