Skip to content

Commit

Permalink
Merge pull request #16218 from gradle/wolfs/normalization/fix-missing…
Browse files Browse the repository at this point in the history
…-inputs

Fix issue with file hash cache during runtime classpath normalization (6.8 backport)
  • Loading branch information
wolfs committed Feb 19, 2021
2 parents becaa3a + 35da400 commit 9e26b4a
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 23 deletions.

Large diffs are not rendered by default.

Expand Up @@ -33,6 +33,8 @@ public IgnoringResourceHasher(ResourceHasher delegate, ResourceFilter resourceFi

@Override
public void appendConfigurationToHasher(Hasher hasher) {
delegate.appendConfigurationToHasher(hasher);
hasher.putString(getClass().getName());
resourceFilter.appendConfigurationToHasher(hasher);
}

Expand Down
Expand Up @@ -52,6 +52,7 @@ public MetaInfAwareClasspathResourceHasher(ResourceHasher delegate, ResourceEntr
@Override
public void appendConfigurationToHasher(Hasher hasher) {
delegate.appendConfigurationToHasher(hasher);
hasher.putString(getClass().getName());
attributeResourceFilter.appendConfigurationToHasher(hasher);
}

Expand Down
Expand Up @@ -58,6 +58,8 @@ public PropertiesFileAwareClasspathResourceHasher(ResourceHasher delegate, Map<S

@Override
public void appendConfigurationToHasher(Hasher hasher) {
delegate.appendConfigurationToHasher(hasher);
hasher.putString(getClass().getName());
propertiesFilePatterns.forEach(hasher::putString);
propertiesFileFilters.values().forEach(resourceEntryFilter -> resourceEntryFilter.appendConfigurationToHasher(hasher));
}
Expand Down
Expand Up @@ -37,6 +37,7 @@ public boolean shouldBeIgnored(String entry) {

@Override
public void appendConfigurationToHasher(Hasher hasher) {
hasher.putString(getClass().getName());
filters.forEach(resourceEntryFilter -> resourceEntryFilter.appendConfigurationToHasher(hasher));
}
}
Expand Up @@ -19,6 +19,7 @@ package org.gradle.api.internal.changedetection.state
import org.gradle.internal.file.FileMetadata
import org.gradle.internal.file.impl.DefaultFileMetadata
import org.gradle.internal.hash.HashCode
import org.gradle.internal.hash.Hasher
import org.gradle.internal.snapshot.RegularFileSnapshot
import spock.lang.Specification

Expand Down Expand Up @@ -50,4 +51,14 @@ class IgnoringResourceHasherTest extends Specification {
and:
hash == null
}

def "delegate configuration is added to hasher"() {
def configurationHasher = Mock(Hasher)

when:
hasher.appendConfigurationToHasher(configurationHasher)

then:
1 * delegate.appendConfigurationToHasher(configurationHasher)
}
}
Expand Up @@ -21,6 +21,7 @@ import org.gradle.api.internal.file.archive.ZipEntry
import org.gradle.internal.file.FileMetadata
import org.gradle.internal.file.impl.DefaultFileMetadata
import org.gradle.internal.hash.HashCode
import org.gradle.internal.hash.Hasher
import org.gradle.internal.snapshot.RegularFileSnapshot
import org.junit.Rule
import org.junit.rules.TemporaryFolder
Expand Down Expand Up @@ -389,6 +390,18 @@ class MetaInfAwareClasspathResourceHasherTest extends Specification {
hash3 == hash4
}

def "delegate configuration is added to hasher"() {
def configurationHasher = Mock(Hasher)
def delegate = Mock(ResourceHasher)
useDelegate(delegate)

when:
hasher.appendConfigurationToHasher(configurationHasher)

then:
1 * delegate.appendConfigurationToHasher(configurationHasher)
}

void populateAttributes(Attributes attributes, Map<String, Object> attributesMap) {
attributesMap.each { String name, Object value ->
if (value instanceof String) {
Expand Down
Expand Up @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableSet
import com.google.common.collect.Maps
import com.google.common.io.ByteStreams
import org.gradle.api.internal.file.archive.ZipEntry
import org.gradle.internal.hash.Hasher
import org.gradle.internal.hash.Hashing
import org.gradle.internal.hash.HashingOutputStream
import org.gradle.internal.snapshot.RegularFileSnapshot
Expand Down Expand Up @@ -257,6 +258,17 @@ class PropertiesFileAwareClasspathResourceHasherTest extends Specification {
SnapshotContext.FILE_SNAPSHOT | "key" | 'keyWithBadEscapeSequence\\uxxxx=some value'
}
def "delegate configuration is added to hasher"() {
def configurationHasher = Mock(Hasher)
delegate = Mock(ResourceHasher)
when:
filteredHasher.appendConfigurationToHasher(configurationHasher)
then:
1 * delegate.appendConfigurationToHasher(configurationHasher)
}
enum SnapshotContext {
ZIP_ENTRY, FILE_SNAPSHOT
}
Expand Down

0 comments on commit 9e26b4a

Please sign in to comment.