mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-25 16:46:10 +00:00
migrate code to common JDK 25 apis and constructs
This commit is contained in:
@@ -299,6 +299,10 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${mvn-surefire.version}</version>
|
||||
<configuration>
|
||||
<!--suppress MavenModelInspection -->
|
||||
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
@@ -399,6 +403,12 @@
|
||||
<includeGroupIds>${nonModularGroupIds}</includeGroupIds>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>get-mockito-agent-path</id>
|
||||
<goals>
|
||||
<goal>properties</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -166,7 +165,7 @@ public class Environment {
|
||||
|
||||
private Optional<Path> getPath(String propertyName) {
|
||||
String value = System.getProperty(propertyName);
|
||||
return Optional.ofNullable(value).map(Paths::get);
|
||||
return Optional.ofNullable(value).map(Path::of);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ErrorCode {
|
||||
public static ErrorCode of(Throwable throwable) {
|
||||
var causalChain = Throwables.getCausalChain(throwable);
|
||||
if (causalChain.size() > 1) {
|
||||
var rootCause = causalChain.get(causalChain.size() - 1);
|
||||
var rootCause = causalChain.getLast();
|
||||
var parentOfRootCause = causalChain.get(causalChain.size() - 2);
|
||||
var rootSpecificFrames = countTopmostFrames(rootCause.getStackTrace(), parentOfRootCause.getStackTrace());
|
||||
return new ErrorCode(throwable, rootCause, rootSpecificFrames);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SubstitutingProperties extends PropertiesDecorator {
|
||||
|
||||
private enum Source {
|
||||
ENV,
|
||||
PROPS;
|
||||
PROPS
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,9 +8,9 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -78,7 +78,7 @@ public final class OneDriveWindowsLocationPresetsProvider implements LocationPre
|
||||
*/
|
||||
@Blocking
|
||||
private static void waitForSuccess(Process process, int timeoutSeconds, String cmdDescription) throws TimeoutException, InterruptedException, CommandFailedException {
|
||||
boolean exited = process.waitFor(timeoutSeconds, TimeUnit.SECONDS);
|
||||
boolean exited = process.waitFor(Duration.ofSeconds(timeoutSeconds));
|
||||
if (!exited) {
|
||||
throw new TimeoutException(cmdDescription + " timed out after " + timeoutSeconds + "s");
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public final class MountWithinParentUtil {
|
||||
|
||||
EMPTY_DIR,
|
||||
|
||||
BROKEN_JUNCTION;
|
||||
BROKEN_JUNCTION
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -62,7 +61,7 @@ public class VaultSettings {
|
||||
|
||||
VaultSettings(VaultSettingsJson json) {
|
||||
this.id = json.id;
|
||||
this.path = new SimpleObjectProperty<>(this, "path", json.path == null ? null : Paths.get(json.path));
|
||||
this.path = new SimpleObjectProperty<>(this, "path", json.path == null ? null : Path.of(json.path));
|
||||
this.displayName = new SimpleStringProperty(this, "displayName", json.displayName);
|
||||
this.unlockAfterStartup = new SimpleBooleanProperty(this, "unlockAfterStartup", json.unlockAfterStartup);
|
||||
this.revealAfterMount = new SimpleBooleanProperty(this, "revealAfterMount", json.revealAfterMount);
|
||||
|
||||
@@ -47,7 +47,6 @@ import javafx.beans.property.ReadOnlyStringProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.ReadOnlyFileSystemException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
@@ -58,7 +57,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
public class Vault {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Vault.class);
|
||||
private static final Path HOME_DIR = Paths.get(SystemUtils.USER_HOME);
|
||||
private static final Path HOME_DIR = Path.of(SystemUtils.USER_HOME);
|
||||
private static final int UNLIMITED_FILENAME_LENGTH = Integer.MAX_VALUE;
|
||||
|
||||
private final VaultSettings vaultSettings;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class VaultState extends ObservableValueBase<VaultState.Value> implements
|
||||
/**
|
||||
* Unknown state due to preceding unrecoverable exceptions.
|
||||
*/
|
||||
ERROR;
|
||||
ERROR
|
||||
}
|
||||
|
||||
private final AtomicReference<Value> value;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SupportedLanguages {
|
||||
var collator = Collator.getInstance(preferredLocale);
|
||||
collator.setStrength(Collator.PRIMARY);
|
||||
var sorted = new ArrayList<String>();
|
||||
sorted.add(0, null);
|
||||
sorted.addFirst(null);
|
||||
sorted.add(1, ENGLISH);
|
||||
LANGUAGE_TAGS.stream() //
|
||||
.sorted((a, b) -> collator.compare(Locale.forLanguageTag(a).getDisplayName(), Locale.forLanguageTag(b).getDisplayName())) //
|
||||
|
||||
+1
-2
@@ -41,7 +41,6 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -50,7 +49,7 @@ import java.util.concurrent.ExecutorService;
|
||||
public class CreateNewVaultLocationController implements FxController {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CreateNewVaultLocationController.class);
|
||||
private static final Path DEFAULT_CUSTOM_VAULT_PATH = Paths.get(System.getProperty("user.home"));
|
||||
private static final Path DEFAULT_CUSTOM_VAULT_PATH = Path.of(System.getProperty("user.home"));
|
||||
private static final String TEMP_FILE_PREFIX = ".locationTest.cryptomator";
|
||||
|
||||
private final Stage window;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SystemBarUtil {
|
||||
/**
|
||||
* OS Bar placed at the bottom screen edge
|
||||
*/
|
||||
BOTTOM;
|
||||
BOTTOM
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,7 +90,7 @@ public class Check {
|
||||
SUCCEEDED,
|
||||
SKIPPED,
|
||||
ERROR,
|
||||
CANCELLED;
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
ObservableList<Result> getResults() {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CheckListController implements FxController {
|
||||
|
||||
checks.filtered(c -> !c.isChosenForExecution()).forEach(c -> c.setState(Check.CheckState.SKIPPED));
|
||||
checkExecutor.executeBatch(chosenChecks);
|
||||
checksListView.getSelectionModel().select(chosenChecks.get(0));
|
||||
checksListView.getSelectionModel().select(chosenChecks.getFirst());
|
||||
checksListView.refresh();
|
||||
window.sizeToScene();
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class VaultListController implements FxController {
|
||||
vaults.addListener((ListChangeListener.Change<? extends Vault> c) -> {
|
||||
while (c.next()) {
|
||||
if (c.wasAdded()) {
|
||||
Vault anyAddedVault = c.getAddedSubList().get(0);
|
||||
Vault anyAddedVault = c.getAddedSubList().getFirst();
|
||||
vaultList.getSelectionModel().select(anyAddedVault);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class RecoveryKeyValidateController implements FxController {
|
||||
/**
|
||||
* Recovery key is not a valid key.
|
||||
*/
|
||||
INVALID;
|
||||
INVALID
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -140,9 +140,9 @@ public class VaultStatisticsController implements FxController {
|
||||
long allTimeMaxAccessedFiles = Arrays.stream(maxAccessBuf).max().orElse(0L);
|
||||
|
||||
// remove oldest value:
|
||||
decryptedBytesRead.getData().remove(0);
|
||||
encryptedBytesWrite.getData().remove(0);
|
||||
accessedFiles.getData().remove(0);
|
||||
decryptedBytesRead.getData().removeFirst();
|
||||
encryptedBytesWrite.getData().removeFirst();
|
||||
accessedFiles.getData().removeFirst();
|
||||
|
||||
// add latest value:
|
||||
decryptedBytesRead.getData().add(new Data<>(currentStep, decBytes));
|
||||
|
||||
@@ -110,7 +110,7 @@ public class UnlockInvalidMountPointController implements FxController {
|
||||
|
||||
//TODO Add option to show filesystem, e.g. for ExceptionType.HIDEAWAY_EXISTS
|
||||
SHOW_PREFERENCES,
|
||||
SHOW_VAULT_OPTIONS;
|
||||
SHOW_VAULT_OPTIONS
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.junit.jupiter.api.condition.EnabledIf;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
@@ -56,7 +55,7 @@ public class EnvironmentTest {
|
||||
List<Path> result = env.getPaths("test.path.property").toList();
|
||||
|
||||
MatcherAssert.assertThat(result, Matchers.hasSize(1));
|
||||
MatcherAssert.assertThat(result, Matchers.hasItem(Paths.get("/foo/bar/test")));
|
||||
MatcherAssert.assertThat(result, Matchers.hasItem(Path.of("/foo/bar/test")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SettingsJsonTest {
|
||||
|
||||
Assertions.assertTrue(jsonObj.checkForUpdatesEnabled);
|
||||
Assertions.assertEquals(2, jsonObj.directories.size());
|
||||
Assertions.assertEquals("/vault1", jsonObj.directories.get(0).path);
|
||||
Assertions.assertEquals("/vault1", jsonObj.directories.getFirst().path);
|
||||
Assertions.assertEquals("/vault2", jsonObj.directories.get(1).path);
|
||||
Assertions.assertEquals("--foo --bar", jsonObj.directories.get(1).mountFlags);
|
||||
Assertions.assertEquals(8080, jsonObj.port);
|
||||
@@ -67,7 +67,7 @@ public class SettingsJsonTest {
|
||||
public void testSerialize() throws JsonProcessingException {
|
||||
var jsonObj = new SettingsJson();
|
||||
jsonObj.directories = List.of(new VaultSettingsJson(), new VaultSettingsJson());
|
||||
jsonObj.directories.get(0).id = "test";
|
||||
jsonObj.directories.getFirst().id = "test";
|
||||
jsonObj.theme = UiTheme.DARK;
|
||||
jsonObj.showTrayIcon = false;
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.mockito.Mockito;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -43,7 +42,7 @@ public class FileOpenRequestHandlerTest {
|
||||
AppLaunchEvent evt = queue.poll();
|
||||
Assertions.assertNotNull(evt);
|
||||
Collection<Path> paths = evt.pathsToOpen();
|
||||
MatcherAssert.assertThat(paths, CoreMatchers.hasItems(Paths.get("foo"), Paths.get("bar")));
|
||||
MatcherAssert.assertThat(paths, CoreMatchers.hasItems(Path.of("foo"), Path.of("bar")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user