Skip to content

Commit b05eb1c

Browse files
committed
Fix StackOverflowError during "Apply changes to the internal targets model"
Problem: `calculateOutputJarsLibraries()` was creating synthetic dependencies from targets to output_jars libraries that already exist as real targets. For example, with BUILD file: ```starlark proto_library( name = "proto", srcs = glob(["proto/**/*.proto"]), strip_import_prefix = "proto", ) java_proto_library( name = "proto_output_jars", deps = [":proto"], ) ``` The plugin would create a synthetic dependency proto -> proto_output_jars, combined with the real dependency proto_output_jars -> proto, creating cycles: proto -> proto_output_jars -> proto -> proto_output_jars -> ... This resulted in infinite recursion and `StackOverflowError` in `calculateTransitivelyExecutableTargets` during the "Apply changes to the internal targets model" sync phase, causing sync to hang. Stack trace excerpt: ``` at org.jetbrains.bazel.target.TargetUtils.calculateTransitivelyExecutableTargets(TargetUtils.kt:206) at org.jetbrains.bazel.target.TargetUtils.access$calculateTransitivelyExecutableTargets(TargetUtils.kt:60) at org.jetbrains.bazel.target.TargetUtils$calculateTransitivelyExecutableTargets$1$1.invoke(TargetUtils.kt:216) at org.jetbrains.bazel.target.TargetUtils$calculateTransitivelyExecutableTargets$1$1.invoke(TargetUtils.kt:215) [infinite recursion continues...] ``` Solution: rename the suffix so that a clash is less likely
1 parent d216598 commit b05eb1c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

plugin-bazel/src/main/kotlin/org/jetbrains/bazel/sync/workspace/mapper/normal/AspectBazelProjectMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class AspectBazelProjectMapper(
258258
targetsToImport
259259
.filter { shouldCreateOutputJarsLibrary(it) }
260260
.mapNotNull { target ->
261-
createLibrary(Label.parse(target.id + "_output_jars"), target, onlyOutputJars = true, isInternalTarget = true)?.let { library ->
261+
createLibrary(Label.parse(target.id + "_internal_ij_output_jars"), target, onlyOutputJars = true, isInternalTarget = true)?.let { library ->
262262
target.label() to listOf(library)
263263
}
264264
}.toMap()

0 commit comments

Comments
 (0)