Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit b7e8464

Browse files
committed
fix(javac-services): ignore errors when caching JAR file attrs (fixes #1708)
1 parent 0f53646 commit b7e8464

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

subprojects/javac-services/src/main/java/com/itsaky/androidide/javac/services/fs/CacheFSInfoSingleton.kt

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.itsaky.androidide.javac.services.fs
1919

2020
import com.itsaky.androidide.utils.VMUtils
2121
import openjdk.tools.javac.file.CacheFSInfo
22+
import org.slf4j.LoggerFactory
2223
import java.nio.file.Path
2324

2425
/**
@@ -27,26 +28,35 @@ import java.nio.file.Path
2728
* @author Akash Yadav
2829
*/
2930
object CacheFSInfoSingleton : CacheFSInfo() {
30-
31+
32+
const val TEST_PROP_ENABLED_ON_JVM = "ide.testing.javac.fsCache.isEnabledOnJVM"
33+
private val log = LoggerFactory.getLogger(CacheFSInfoSingleton::class.java)
34+
3135
/**
3236
* Caches information about the given [Path].
3337
*/
3438
@JvmOverloads
3539
fun cache(file: Path, cacheJarClasspath: Boolean = true) {
36-
37-
if (VMUtils.isJvm()) {
38-
return
40+
41+
if (System.getProperty(TEST_PROP_ENABLED_ON_JVM, null) != "true") {
42+
if (VMUtils.isJvm()) {
43+
return
44+
}
3945
}
40-
41-
// Cache canonical path
42-
getCanonicalFile(file)
43-
44-
// Cache attributes
45-
getAttributes(file)
46-
47-
// Cache jar classpath if requested
48-
if (cacheJarClasspath) {
49-
getJarClassPath(file)
46+
47+
try {
48+
// Cache canonical path
49+
getCanonicalFile(file)
50+
51+
// Cache attributes
52+
getAttributes(file)
53+
54+
// Cache jar classpath if requested
55+
if (cacheJarClasspath) {
56+
getJarClassPath(file)
57+
}
58+
} catch (err: Throwable) {
59+
log.warn("Failed to cache jar file: {}", file, err)
5060
}
5161
}
5262
}

0 commit comments

Comments
 (0)