@@ -2566,40 +2566,38 @@ class SkyframePackageLoader {
2566
2566
*/
2567
2567
Package getPackage (ExtendedEventHandler eventHandler , PackageIdentifier pkgName )
2568
2568
throws InterruptedException , NoSuchPackageException {
2569
+ SkyKey key = PackageValue .key (pkgName );
2570
+ ImmutableList <SkyKey > keys = ImmutableList .of (key );
2571
+ EvaluationResult <PackageValue > result ;
2569
2572
synchronized (valueLookupLock ) {
2570
- SkyKey key = PackageValue .key (pkgName );
2571
- // Any call to this method post-loading phase should either be error-free or be in a
2572
- // keep_going build, since otherwise the build would have failed during loading. Thus
2573
- // we set keepGoing=true unconditionally.
2574
- EvaluationResult <PackageValue > result =
2575
- evaluate (
2576
- ImmutableList .of (key ),
2577
- /*keepGoing=*/ true ,
2578
- /*numThreads=*/ DEFAULT_THREAD_COUNT ,
2579
- eventHandler );
2580
- ErrorInfo error = result .getError (key );
2581
- if (error != null ) {
2582
- if (!error .getCycleInfo ().isEmpty ()) {
2583
- reportCycles (eventHandler , result .getError ().getCycleInfo (), key );
2584
- // This can only happen if a package is freshly loaded outside of the target parsing
2585
- // or loading phase
2586
- throw new BuildFileContainsErrorsException (
2587
- pkgName , "Cycle encountered while loading package " + pkgName );
2588
- }
2589
- Throwable e = Preconditions .checkNotNull (error .getException (), "%s %s" , pkgName , error );
2590
- // PackageFunction should be catching, swallowing, and rethrowing all transitive
2591
- // errors as NoSuchPackageExceptions or constructing packages with errors, since we're in
2592
- // keep_going mode.
2593
- Throwables .throwIfInstanceOf (e , NoSuchPackageException .class );
2594
- throw new IllegalStateException (
2595
- "Unexpected Exception type from PackageValue for '"
2596
- + pkgName
2597
- + "'' with error: "
2598
- + error ,
2599
- e );
2573
+ // Loading a single package shouldn't be too bad to do in keep_going mode even if the build
2574
+ // overall is in nokeep_going mode: the worst that happens is we parse some unnecessary
2575
+ // .bzl files.
2576
+ result =
2577
+ evaluate (keys , /*keepGoing=*/ true , /*numThreads=*/ DEFAULT_THREAD_COUNT , eventHandler );
2578
+ }
2579
+ ErrorInfo error = result .getError (key );
2580
+ if (error != null ) {
2581
+ if (!error .getCycleInfo ().isEmpty ()) {
2582
+ reportCycles (eventHandler , result .getError ().getCycleInfo (), key );
2583
+ // This can only happen if a package is freshly loaded outside of the target parsing or
2584
+ // loading phase
2585
+ throw new BuildFileContainsErrorsException (
2586
+ pkgName , "Cycle encountered while loading package " + pkgName );
2600
2587
}
2601
- return result .get (key ).getPackage ();
2588
+ Throwable e = Preconditions .checkNotNull (error .getException (), "%s %s" , pkgName , error );
2589
+ // PackageFunction should be catching, swallowing, and rethrowing all transitive errors as
2590
+ // NoSuchPackageExceptions or constructing packages with errors, since we're in keep_going
2591
+ // mode.
2592
+ Throwables .throwIfInstanceOf (e , NoSuchPackageException .class );
2593
+ throw new IllegalStateException (
2594
+ "Unexpected Exception type from PackageValue for '"
2595
+ + pkgName
2596
+ + "'' with error: "
2597
+ + error ,
2598
+ e );
2602
2599
}
2600
+ return result .get (key ).getPackage ();
2603
2601
}
2604
2602
2605
2603
/** Returns whether the given package should be consider deleted and thus should be ignored. */
0 commit comments