[8.5.0] Use comparator when extracting relevant facts for lockfile#27882
[8.5.0] Use comparator when extracting relevant facts for lockfile#27882meteorcloudy merged 1 commit intobazelbuild:release-8.5.0from
Conversation
ModuleExtensionId is not comparable by itself and needs a comparator. Before this fix, I was able to crash Bazel with this message:
```
FATAL: bazel crashed due to an internal error. Printing stack trace: java.lang.ClassCastException: class com.google.devtools.build.lib.bazel.bzlmod.ModuleExtensionId cannot be cast to class java.lang.Comparable (com.google.devtools.build.lib.bazel.bzlmod.ModuleExtensionId is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')
at com.google.common.collect.NaturalOrdering.compare(NaturalOrdering.java:29)
at com.google.common.collect.ImmutableSortedMap.lambda$fromEntries$0(ImmutableSortedMap.java:536)
at java.base/java.util.TimSort.countRunAndMakeAscending(Unknown Source)
at java.base/java.util.TimSort.sort(Unknown Source)
at java.base/java.util.Arrays.sort(Unknown Source)
at com.google.common.collect.ImmutableSortedMap.fromEntries(ImmutableSortedMap.java:528)
at com.google.common.collect.ImmutableSortedMap.fromEntries(ImmutableSortedMap.java:495)
at com.google.common.collect.ImmutableSortedMap.copyOfInternal(ImmutableSortedMap.java:474)
at com.google.common.collect.ImmutableSortedMap.copyOf(ImmutableSortedMap.java:372)
at com.google.devtools.build.lib.bazel.bzlmod.BazelLockFileModule.afterCommand(BazelLockFileModule.java:135)
at com.google.devtools.build.lib.runtime.BlazeRuntime.afterCommand(BlazeRuntime.java:734)
at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:711)
at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:257)
at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:607)
at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$0(GrpcServerImpl.java:677)
at io.grpc.Context$1.run(Context.java:566)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
```
Fixes bazelbuild#27522
Closes bazelbuild#27816.
PiperOrigin-RevId: 840671327
Change-Id: Ia7eb05be4fd099f0e2711065faf4c344d45265b5
Summary of ChangesHello @bazel-io, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical stability issue in Bazel's Bzlmod system where the absence of a proper comparator for Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a ClassCastException by explicitly providing ModuleExtensionId.LEXICOGRAPHIC_COMPARATOR when creating an ImmutableSortedMap of facts. This is a crucial fix as ModuleExtensionId does not implement Comparable by itself, which previously led to runtime errors. A new regression test, testMultipleExtensionsWithFacts, has been added to ensure the stability and correctness of this behavior, particularly when multiple extensions with facts are present. The changes are well-justified and correctly implemented.
|
The CI failure is a timeout and probably an (unrelated) flake. |
ModuleExtensionId is not comparable by itself and needs a comparator. Before this fix, I was able to crash Bazel with this message:
Fixes #27522
Closes #27816.
PiperOrigin-RevId: 840671327
Change-Id: Ia7eb05be4fd099f0e2711065faf4c344d45265b5
Commit b2587f6