Skip to content

Commit

Permalink
Fix JVM fingerprinting by adding tags (#8175)
Browse files Browse the repository at this point in the history
# Problem

Tags could decide how a target is compiled (rsc, zinc), but we are not factoring them into the cache key, causing RscCompile task to hit the cache that should not be hit.

# Solution

Explicitly add tags to target's fingerprint.
  • Loading branch information
wisechengyi authored and stuhood committed Aug 22, 2019
1 parent 3bb4feb commit 7ffc81e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/python/pants/backend/jvm/subsystems/dependency_context.py
Expand Up @@ -10,6 +10,7 @@
from pants.backend.jvm.targets.javac_plugin import JavacPlugin
from pants.backend.jvm.targets.scalac_plugin import ScalacPlugin
from pants.base.fingerprint_strategy import FingerprintStrategy
from pants.base.hash_utils import stable_json_sha1
from pants.build_graph.dependency_context import DependencyContext as DependencyContextBase
from pants.build_graph.resources import Resources
from pants.build_graph.target_scopes import Scopes
Expand Down Expand Up @@ -86,6 +87,8 @@ def compute_fingerprint(self, target):

hasher = hashlib.sha1()
hasher.update(target.payload.fingerprint().encode())
# Adding tags into cache key because it may decide which workflow applies to the target.
hasher.update(stable_json_sha1(target.tags).encode())
if isinstance(target, JarLibrary):
# NB: Collects only the jars for the current jar_library, and hashes them to ensure that both
# the resolved coordinates, and the requested coordinates are used. This ensures that if a
Expand Down

0 comments on commit 7ffc81e

Please sign in to comment.