Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with file hash cache during runtime classpath normalization #16145

Merged
merged 2 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

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