Fixed random set order and updated #getAvailableDriveLetter()

Fixed bug introduced by 32a810fe1d:
The Set of existing DriveLetters was in random order because Collectors#toUnmodifiableSet is an unordered collector.

Changed #getAvailableDriveLetter() to use Stream#findFirst() instead of #findAny()
This commit is contained in:
JaniruTEC
2020-08-11 02:23:42 +02:00
parent 4f2120b729
commit 597899d2bf

View File

@@ -5,6 +5,7 @@
*******************************************************************************/
package org.cryptomator.common.vaults;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.SystemUtils;
@@ -25,7 +26,7 @@ public final class WindowsDriveLetters {
static {
try (IntStream stream = IntStream.rangeClosed('C', 'Z')) {
C_TO_Z = stream.mapToObj(i -> String.valueOf((char) i)).collect(Collectors.toUnmodifiableSet());
C_TO_Z = stream.mapToObj(i -> String.valueOf((char) i)).collect(ImmutableSet.toImmutableSet());
}
}
@@ -51,7 +52,7 @@ public final class WindowsDriveLetters {
}
public Optional<String> getAvailableDriveLetter() {
return getAvailableDriveLetters().stream().findAny();
return getAvailableDriveLetters().stream().findFirst();
}
public Optional<Path> getAvailableDriveLetterPath() {