From 58e2ec4742d5e20e3fd361afe750539a67545a47 Mon Sep 17 00:00:00 2001 From: JaniruTEC Date: Thu, 8 Oct 2020 19:14:03 +0200 Subject: [PATCH] Changed contract of priorities in MPC, added null-check See: ab538cd21573de70aa7d100382a8a70c25eeccaf (original commit) See: 6b6867b826f474e5926afb65c1ce2d3c8a58366d (reverting commit) --- .../common/mountpoint/MountPointChooser.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java b/main/commons/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java index 393d68b20..2c40bb74a 100644 --- a/main/commons/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java +++ b/main/commons/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java @@ -1,5 +1,6 @@ package org.cryptomator.common.mountpoint; +import com.google.common.base.Preconditions; import org.cryptomator.common.vaults.Volume; import java.nio.file.Path; @@ -12,8 +13,9 @@ import java.util.SortedSet; *

All MountPointChoosers (MPCs) need to implement this class and must be added to * the pool of possible MPCs by the {@link MountPointChooserModule MountPointChooserModule.} * The MountPointChooserModule will sort them according to their {@link #getPriority() priority.} - * The priority must be defined by the developer to reflect a useful execution order; - * the order of execution of MPCs with equal priority is undefined. + * The priority must be defined by the developer to reflect a useful execution order.
+ * A specific priority must not be assigned to more than one MPC at a time; + * the result of having two MPCs with equal priority is undefined. * *

MPCs are executed by a {@link Volume} in ascending order of their priority * (smaller priorities are tried first) to find and prepare a suitable mountpoint for the volume. @@ -138,8 +140,9 @@ public interface MountPointChooser extends Comparable { * and determine their execution order. * The priority must be defined by the developer to reflect a useful execution order. * MPCs with lower priorities will be placed at lower indices in the resulting - * {@link SortedSet} and will be executed with higher probability. - * The order of execution of MPCs with equal priority is undefined. + * {@link SortedSet} and will be executed with higher probability.
+ * A specific priority must not be assigned to more than one MPC at a time; + * the result of having two MPCs with equal priority is undefined. * * @return the priority of this MPC. */ @@ -158,6 +161,8 @@ public interface MountPointChooser extends Comparable { */ @Override default int compareTo(MountPointChooser other) { + Preconditions.checkNotNull(other, "Other must not be null!"); + //Sort by priority (ascending order) return Integer.compare(this.getPriority(), other.getPriority()); }