aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-04-02 02:34:48 +0200
committergjoranv <gv@verizonmedia.com>2020-04-02 10:32:35 +0200
commit6e5eb6ff02915a2f1fab382b5cff67b68af883f9 (patch)
treef9da28e04a3625eab23efc4fc9e77e6571e6162f
parentdf05ca322bca04cc4c12b2e6bdaa252b10e50e7c (diff)
Safeguard against adding disk bundles to allowed duplicates.
This should not be necessary, because disk bundles should be removed by getObsoleteFileReferences (as long as they are present in both the old and new set of bundles). However, there was an incident where all the model amender's bundles were added to the set of allowed duplicates. One possible explanation is that FileReference.equals or hashCode was broken, so an improved version is added by this commit.
-rwxr-xr-xconfig-lib/src/main/java/com/yahoo/config/FileReference.java12
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java1
2 files changed, 8 insertions, 5 deletions
diff --git a/config-lib/src/main/java/com/yahoo/config/FileReference.java b/config-lib/src/main/java/com/yahoo/config/FileReference.java
index 3b95c2fbd4c..ee99ebfa2b7 100755
--- a/config-lib/src/main/java/com/yahoo/config/FileReference.java
+++ b/config-lib/src/main/java/com/yahoo/config/FileReference.java
@@ -28,14 +28,16 @@ public final class FileReference {
}
@Override
- public int hashCode() {
- return value.hashCode();
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ FileReference that = (FileReference) o;
+ return value.equals(that.value);
}
@Override
- public boolean equals(Object other) {
- return other instanceof FileReference &&
- value.equals(((FileReference)other).value);
+ public int hashCode() {
+ return Objects.hash(value);
}
@Override
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java
index 38aacc2d2a5..ca11ad387ee 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java
@@ -186,6 +186,7 @@ public class BundleLoader {
// The bundle at index 0 for each file reference always corresponds to the bundle at the file reference location
Set<Bundle> allowedDuplicates = obsoleteReferences.stream()
+ .filter(reference -> ! isDiskBundle(reference))
.map(reference -> reference2Bundles.get(reference).get(0))
.collect(Collectors.toSet());