File tree 1 file changed +10
-4
lines changed
lint-checks/src/main/java/androidx/com/android/tools/idea/lang/aidl
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 22
22
* Android IDL Language.
23
23
*/
24
24
public class AidlLanguage extends Language {
25
+ private static final Object INSTANCE_LOCK = new Object ();
26
+
25
27
public static final Language INSTANCE = getOrCreate ();
26
28
27
29
private static Language getOrCreate () {
28
- Language lang = Language .findLanguageByID (ID );
29
- if (lang != null ) {
30
- return lang ;
30
+ // The Language class is not thread-safe, so this is a best-effort to avoid a race condition
31
+ // during our own access across multiple lint worker threads.
32
+ synchronized (INSTANCE_LOCK ) {
33
+ Language lang = Language .findLanguageByID (ID );
34
+ if (lang != null ) {
35
+ return lang ;
36
+ }
37
+ return new AidlLanguage ();
31
38
}
32
- return new AidlLanguage ();
33
39
}
34
40
35
41
@ NonNls private static final String ID = "AIDL" ;
You can’t perform that action at this time.
0 commit comments