aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-04-02 12:11:57 +0200
committerGitHub <noreply@github.com>2020-04-02 12:11:57 +0200
commitfe46aea3b3802f5003754d9d6448d68a51f626bc (patch)
tree20eabfc76bafb0ef91a7d0e03d8a765d69d89d95
parentaeda802f9a0c86a09fa6506f5d5c033ac65517da (diff)
parent6e5eb6ff02915a2f1fab382b5cff67b68af883f9 (diff)
Merge pull request #12801 from vespa-engine/gjoranv/never-allow-duplicates-of-file-bundles
Gjoranv/never allow duplicates of file bundles
-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.java11
2 files changed, 14 insertions, 9 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 4c3d76436dd..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
@@ -148,10 +148,9 @@ public class BundleLoader {
/**
* Returns the bundles that are not assumed to be retained by the new application generation.
- * and cleans up the map of active file references. Note that at this point we don't yet know
- * the full set of new bundles, because of the potential pre-install directives in the new bundles.
- * However, only "disk bundles" (file:) can be listed in the pre-install directive, so we know
- * about all the obsolete application bundles.
+ * Note that at this point we don't yet know the full set of new bundles, because of the potential
+ * pre-install directives in the new bundles. However, only "disk bundles" (file:) can be listed
+ * in the pre-install directive, so we know about all the obsolete application bundles.
*/
private Set<Bundle> getObsoleteBundles(List<FileReference> newReferences) {
Set<Bundle> bundlesToRemove = new HashSet<>(osgi.getCurrentBundles());
@@ -165,6 +164,9 @@ public class BundleLoader {
return bundlesToRemove;
}
+ /**
+ * Cleans up the map of active file references
+ */
private void removeInactiveFileReferences(List<FileReference> newReferences) {
// Clean up the map of active bundles
Set<FileReference> fileReferencesToRemove = getObsoleteFileReferences(newReferences);
@@ -184,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());