Преглед на файлове

Merge pull request #1587 from cryptomator/feature/jdk-16

Update to JDK 16
Sebastian Stenzel преди 4 години
родител
ревизия
31e938de6a

+ 5 - 5
.github/workflows/build.yml

@@ -12,7 +12,7 @@ jobs:
       - uses: actions/checkout@v2
       - uses: actions/setup-java@v1
         with:
-          java-version: 14
+          java-version: 16
       - uses: actions/cache@v1
         with:
           path: ~/.m2/repository
@@ -28,10 +28,10 @@ jobs:
         if: github.repository == 'cryptomator/cryptomator'
         run: |
           curl -o ~/codacy-coverage-reporter.jar https://repo.maven.apache.org/maven2/com/codacy/codacy-coverage-reporter/7.1.0/codacy-coverage-reporter-7.1.0-assembly.jar
-          $JAVA_HOME/bin/java -jar ~/codacy-coverage-reporter.jar report -l Java -r main/commons/target/site/jacoco/jacoco.xml --partial
-          $JAVA_HOME/bin/java -jar ~/codacy-coverage-reporter.jar report -l Java -r main/ui/target/site/jacoco/jacoco.xml --partial
-          $JAVA_HOME/bin/java -jar ~/codacy-coverage-reporter.jar report -l Java -r main/launcher/target/site/jacoco/jacoco.xml --partial
-          $JAVA_HOME/bin/java -jar ~/codacy-coverage-reporter.jar final
+          $JAVA_HOME/bin/java --illegal-access=permit -jar ~/codacy-coverage-reporter.jar report -l Java -r main/commons/target/site/jacoco/jacoco.xml --partial
+          $JAVA_HOME/bin/java --illegal-access=permit -jar ~/codacy-coverage-reporter.jar report -l Java -r main/ui/target/site/jacoco/jacoco.xml --partial
+          $JAVA_HOME/bin/java --illegal-access=permit -jar ~/codacy-coverage-reporter.jar report -l Java -r main/launcher/target/site/jacoco/jacoco.xml --partial
+          $JAVA_HOME/bin/java --illegal-access=permit -jar ~/codacy-coverage-reporter.jar final
         env:
           CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
       - name: Assemble buildkit-linux.zip

+ 1 - 1
.idea/misc.xml

@@ -8,7 +8,7 @@
       </list>
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="false" project-jdk-name="14" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="16" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/out" />
   </component>
 </project>

+ 1 - 1
README.md

@@ -65,7 +65,7 @@ For more information on the security details visit [cryptomator.org](https://doc
 
 ### Dependencies
 
-* JDK 14 (e.g. adoptopenjdk)
+* JDK 16 (e.g. adoptopenjdk)
 * Maven 3
 * Optional: OS-dependent build tools for native packaging (see [Windows](https://github.com/cryptomator/cryptomator-win), [OS X](https://github.com/cryptomator/cryptomator-osx), [Linux](https://github.com/cryptomator/builder-containers))
 

+ 6 - 4
main/commons/src/main/java/org/cryptomator/common/CommonsModule.java

@@ -47,10 +47,12 @@ public abstract class CommonsModule {
 	@Named("licensePublicKey")
 	static String provideLicensePublicKey() {
 		// in PEM format without the dash-escaped begin/end lines
-		return "MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQB7NfnqiZbg2KTmoflmZ71PbXru7oW" //
-				+ "fmnV2yv3eDjlDfGruBrqz9TtXBZV/eYWt31xu1osIqaT12lKBvZ511aaAkIBeOEV" //
-				+ "gwcBIlJr6kUw7NKzeJt7r2rrsOyQoOG2nWc/Of/NBqA3mIZRHk5Aq1YupFdD26QE" //
-				+ "r0DzRyj4ixPIt38CQB8=";
+		return """
+				MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQB7NfnqiZbg2KTmoflmZ71PbXru7oW\
+				fmnV2yv3eDjlDfGruBrqz9TtXBZV/eYWt31xu1osIqaT12lKBvZ511aaAkIBeOEV\
+				gwcBIlJr6kUw7NKzeJt7r2rrsOyQoOG2nWc/Of/NBqA3mIZRHk5Aq1YupFdD26QE\
+				r0DzRyj4ixPIt38CQB8=\
+				""";
 	}
 
 	@Provides

+ 2 - 2
main/commons/src/main/java/org/cryptomator/common/LicenseChecker.java

@@ -33,8 +33,8 @@ class LicenseChecker {
 		try {
 			byte[] keyBytes = BaseEncoding.base64().decode(pemEncodedPublicKey);
 			PublicKey key = KeyFactory.getInstance("EC").generatePublic(new X509EncodedKeySpec(keyBytes));
-			if (key instanceof ECPublicKey) {
-				return (ECPublicKey) key;
+			if (key instanceof ECPublicKey k) {
+				return k;
 			} else {
 				throw new IllegalStateException("Key not an EC public key.");
 			}

+ 1 - 2
main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java

@@ -173,8 +173,7 @@ public class VaultSettings {
 
 	@Override
 	public boolean equals(Object obj) {
-		if (obj instanceof VaultSettings && obj.getClass().equals(this.getClass())) {
-			VaultSettings other = (VaultSettings) obj;
+		if (obj instanceof VaultSettings other && obj.getClass().equals(this.getClass())) {
 			return Objects.equals(this.id, other.id);
 		} else {
 			return false;

+ 1 - 2
main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java

@@ -355,8 +355,7 @@ public class Vault {
 
 	@Override
 	public boolean equals(Object obj) {
-		if (obj instanceof Vault && obj.getClass().equals(this.getClass())) {
-			final Vault other = (Vault) obj;
+		if (obj instanceof Vault other && obj.getClass().equals(this.getClass())) {
 			return Objects.equals(this.vaultSettings, other.vaultSettings);
 		} else {
 			return false;

+ 2 - 2
main/commons/src/main/java/org/cryptomator/common/vaults/VaultListChangeListener.java

@@ -22,10 +22,10 @@ class VaultListChangeListener implements ListChangeListener<Vault> {
 	public void onChanged(Change<? extends Vault> c) {
 		while (c.next()) {
 			if (c.wasAdded()) {
-				List<VaultSettings> addedSettings = c.getAddedSubList().stream().map(Vault::getVaultSettings).collect(Collectors.toList());
+				List<VaultSettings> addedSettings = c.getAddedSubList().stream().map(Vault::getVaultSettings).toList();
 				vaultSettingsList.addAll(c.getFrom(), addedSettings);
 			} else if (c.wasRemoved()) {
-				List<VaultSettings> removedSettings = c.getRemoved().stream().map(Vault::getVaultSettings).collect(Collectors.toList());
+				List<VaultSettings> removedSettings = c.getRemoved().stream().map(Vault::getVaultSettings).toList();
 				vaultSettingsList.removeAll(removedSettings);
 			}
 		}

+ 1 - 1
main/commons/src/main/java/org/cryptomator/common/vaults/VaultListManager.java

@@ -79,7 +79,7 @@ public class VaultListManager {
 	}
 
 	private void addAll(Collection<VaultSettings> vaultSettings) {
-		Collection<Vault> vaults = vaultSettings.stream().map(this::create).collect(Collectors.toList());
+		Collection<Vault> vaults = vaultSettings.stream().map(this::create).toList();
 		vaultList.addAll(vaults);
 	}
 

+ 7 - 7
main/commons/src/test/java/org/cryptomator/common/EnvironmentTest.java

@@ -32,7 +32,7 @@ class EnvironmentTest {
 	public void testSettingsPath() {
 		System.setProperty("cryptomator.settingsPath", "~/.config/Cryptomator/settings.json:~/.Cryptomator/settings.json");
 
-		List<Path> result = env.getSettingsPath().collect(Collectors.toList());
+		List<Path> result = env.getSettingsPath().toList();
 		MatcherAssert.assertThat(result, Matchers.hasSize(2));
 		MatcherAssert.assertThat(result, Matchers.contains(Paths.get("/home/testuser/.config/Cryptomator/settings.json"), //
 				Paths.get("/home/testuser/.Cryptomator/settings.json")));
@@ -43,7 +43,7 @@ class EnvironmentTest {
 	public void testIpcPortPath() {
 		System.setProperty("cryptomator.ipcPortPath", "~/.config/Cryptomator/ipcPort.bin:~/.Cryptomator/ipcPort.bin");
 
-		List<Path> result = env.getIpcPortPath().collect(Collectors.toList());
+		List<Path> result = env.getIpcPortPath().toList();
 		MatcherAssert.assertThat(result, Matchers.hasSize(2));
 		MatcherAssert.assertThat(result, Matchers.contains(Paths.get("/home/testuser/.config/Cryptomator/ipcPort.bin"), //
 				Paths.get("/home/testuser/.Cryptomator/ipcPort.bin")));
@@ -54,7 +54,7 @@ class EnvironmentTest {
 	public void testKeychainPath() {
 		System.setProperty("cryptomator.keychainPath", "~/AppData/Roaming/Cryptomator/keychain.json");
 
-		List<Path> result = env.getKeychainPath().collect(Collectors.toList());
+		List<Path> result = env.getKeychainPath().toList();
 		MatcherAssert.assertThat(result, Matchers.hasSize(1));
 		MatcherAssert.assertThat(result, Matchers.contains(Paths.get("/home/testuser/AppData/Roaming/Cryptomator/keychain.json")));
 	}
@@ -88,7 +88,7 @@ class EnvironmentTest {
 		@DisplayName("test.path.property=")
 		public void testEmptyList() {
 			System.setProperty("test.path.property", "");
-			List<Path> result = env.getPaths("test.path.property").collect(Collectors.toList());
+			List<Path> result = env.getPaths("test.path.property").toList();
 
 			MatcherAssert.assertThat(result, Matchers.hasSize(0));
 		}
@@ -97,7 +97,7 @@ class EnvironmentTest {
 		@DisplayName("test.path.property=/foo/bar/test")
 		public void testSingleAbsolutePath() {
 			System.setProperty("test.path.property", "/foo/bar/test");
-			List<Path> result = env.getPaths("test.path.property").collect(Collectors.toList());
+			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")));
@@ -107,7 +107,7 @@ class EnvironmentTest {
 		@DisplayName("test.path.property=~/test")
 		public void testSingleHomeRelativePath() {
 			System.setProperty("test.path.property", "~/test");
-			List<Path> result = env.getPaths("test.path.property").collect(Collectors.toList());
+			List<Path> result = env.getPaths("test.path.property").toList();
 
 			MatcherAssert.assertThat(result, Matchers.hasSize(1));
 			MatcherAssert.assertThat(result, Matchers.hasItem(Paths.get("/home/testuser/test")));
@@ -117,7 +117,7 @@ class EnvironmentTest {
 		@DisplayName("test.path.property=~/test:~/test2:/foo/bar/test")
 		public void testMultiplePaths() {
 			System.setProperty("test.path.property", "~/test:~/test2:/foo/bar/test");
-			List<Path> result = env.getPaths("test.path.property").collect(Collectors.toList());
+			List<Path> result = env.getPaths("test.path.property").toList();
 
 			MatcherAssert.assertThat(result, Matchers.hasSize(3));
 			MatcherAssert.assertThat(result, Matchers.contains(Paths.get("/home/testuser/test"), //

+ 6 - 4
main/commons/src/test/java/org/cryptomator/common/LicenseCheckerTest.java

@@ -9,10 +9,12 @@ import java.util.Optional;
 
 class LicenseCheckerTest {
 
-	private static final String PUBLIC_KEY = "MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBgc4HZz+/fBbC7lmEww0AO3NK9wVZ" //
-			+ "PDZ0VEnsaUFLEYpTzb90nITtJUcPUbvOsdZIZ1Q8fnbquAYgxXL5UgHMoywAib47" //
-			+ "6MkyyYgPk0BXZq3mq4zImTRNuaU9slj9TVJ3ScT3L1bXwVuPJDzpr5GOFpaj+WwM" //
-			+ "Al8G7CqwoJOsW7Kddns=";
+	private static final String PUBLIC_KEY = """
+			MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBgc4HZz+/fBbC7lmEww0AO3NK9wVZ\
+			PDZ0VEnsaUFLEYpTzb90nITtJUcPUbvOsdZIZ1Q8fnbquAYgxXL5UgHMoywAib47\
+			6MkyyYgPk0BXZq3mq4zImTRNuaU9slj9TVJ3ScT3L1bXwVuPJDzpr5GOFpaj+WwM\
+			Al8G7CqwoJOsW7Kddns=\
+			""";
 
 	private LicenseChecker licenseChecker;
 

+ 12 - 7
main/commons/src/test/java/org/cryptomator/common/settings/SettingsJsonAdapterTest.java

@@ -21,13 +21,18 @@ public class SettingsJsonAdapterTest {
 
 	@Test
 	public void testDeserialize() throws IOException {
-		String vault1Json = "{\"id\": \"1\", \"path\": \"/vault1\", \"mountName\": \"vault1\", \"winDriveLetter\": \"X\"}";
-		String vault2Json = "{\"id\": \"2\", \"path\": \"/vault2\", \"mountName\": \"vault2\", \"winDriveLetter\": \"Y\"}";
-		String json = "{\"directories\": [" + vault1Json + "," + vault2Json + "]," //
-				+ "\"checkForUpdatesEnabled\": true,"//
-				+ "\"port\": 8080,"//
-				+ "\"numTrayNotifications\": 42,"//
-				+ "\"preferredVolumeImpl\": \"FUSE\"}";
+		String json = """
+				{
+					"directories": [
+						{"id": "1", "path": "/vault1", "mountName": "vault1", "winDriveLetter": "X"},
+						{"id": "2", "path": "/vault2", "mountName": "vault2", "winDriveLetter": "Y"}
+					],
+					"checkForUpdatesEnabled": true,
+					"port": 8080,
+					"numTrayNotifications": 42,
+					"preferredVolumeImpl": "FUSE"
+				}
+				""";
 
 		Settings settings = adapter.fromJson(json);
 

+ 2 - 2
main/launcher/src/main/java/org/cryptomator/launcher/FileOpenRequestHandler.java

@@ -41,7 +41,7 @@ class FileOpenRequestHandler {
 	}
 
 	private void openFiles(OpenFilesEvent evt) {
-		Collection<Path> pathsToOpen = evt.getFiles().stream().map(File::toPath).collect(Collectors.toList());
+		Collection<Path> pathsToOpen = evt.getFiles().stream().map(File::toPath).toList();
 		AppLaunchEvent launchEvent = new AppLaunchEvent(AppLaunchEvent.EventType.OPEN_FILE, pathsToOpen);
 		tryToEnqueueFileOpenRequest(launchEvent);
 	}
@@ -59,7 +59,7 @@ class FileOpenRequestHandler {
 				LOG.trace("Argument not a valid path: {}", str);
 				return null;
 			}
-		}).filter(Objects::nonNull).collect(Collectors.toList());
+		}).filter(Objects::nonNull).toList();
 		if (!pathsToOpen.isEmpty()) {
 			AppLaunchEvent launchEvent = new AppLaunchEvent(AppLaunchEvent.EventType.OPEN_FILE, pathsToOpen);
 			tryToEnqueueFileOpenRequest(launchEvent);

+ 2 - 2
main/launcher/src/main/java/org/cryptomator/logging/LoggerModule.java

@@ -47,8 +47,8 @@ public class LoggerModule {
 	@Singleton
 	static LoggerContext provideLoggerContext() {
 		ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
-		if (loggerFactory instanceof LoggerContext) {
-			return (LoggerContext) loggerFactory;
+		if (loggerFactory instanceof LoggerContext context) {
+			return context;
 		} else {
 			throw new IllegalStateException("SLF4J not bound to Logback.");
 		}

+ 1 - 1
main/pom.xml

@@ -22,7 +22,7 @@
 
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<project.jdk.version>14</project.jdk.version>
+		<project.jdk.version>16</project.jdk.version>
 
 		<!-- cryptomator dependencies -->
 		<cryptomator.cryptofs.version>1.9.14</cryptomator.cryptofs.version>

+ 2 - 2
main/ui/src/main/java/org/cryptomator/ui/common/DefaultSceneFactory.java

@@ -42,8 +42,8 @@ public class DefaultSceneFactory implements Function<Parent, Scene> {
 	protected void configureScene(Scene scene) {
 		scene.windowProperty().addListener(observable -> {
 			Window window = scene.getWindow();
-			if (window instanceof Stage) {
-				setupDefaultAccelerators(scene, (Stage) window);
+			if (window instanceof Stage s) {
+				setupDefaultAccelerators(scene, s);
 			}
 		});
 	}

+ 2 - 2
main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java

@@ -76,8 +76,8 @@ public class UnlockWorkflow extends Task<Boolean> {
 
 		setOnFailed(event -> {
 			Throwable throwable = event.getSource().getException();
-			if (throwable instanceof InvalidMountPointException) {
-				handleInvalidMountPoint((InvalidMountPointException) throwable);
+			if (throwable instanceof InvalidMountPointException e) {
+				handleInvalidMountPoint(e);
 			} else {
 				handleGenericError(throwable);
 			}

+ 10 - 6
main/ui/src/test/java/org/cryptomator/ui/recoverykey/RecoveryKeyFactoryTest.java

@@ -48,18 +48,22 @@ class RecoveryKeyFactoryTest {
 	@Test
 	@DisplayName("validateRecoveryKey() with invalid checksum")
 	public void testValidateValidateRecoveryKeyWithInvalidCrc() {
-		boolean result = inTest.validateRecoveryKey("pathway lift abuse plenty export texture gentleman landscape beyond ceiling around leaf cafe" //
-				+ " charity border breakdown victory surely computer cat linger restrict infer crowd live computer true written amazed investor boot" //
-				+ " depth left theory snow whereby terminal weekly reject happiness circuit partial cup wrong");
+		boolean result = inTest.validateRecoveryKey("""
+				pathway lift abuse plenty export texture gentleman landscape beyond ceiling around leaf cafe charity \
+				border breakdown victory surely computer cat linger restrict infer crowd live computer true written amazed \
+				investor boot depth left theory snow whereby terminal weekly reject happiness circuit partial cup wrong \
+				""");
 		Assertions.assertFalse(result);
 	}
 
 	@Test
 	@DisplayName("validateRecoveryKey() with valid input")
 	public void testValidateValidateRecoveryKeyWithValidKey() {
-		boolean result = inTest.validateRecoveryKey("pathway lift abuse plenty export texture gentleman landscape beyond ceiling around leaf cafe" //
-				+ " charity border breakdown victory surely computer cat linger restrict infer crowd live computer true written amazed investor boot" //
-				+ " depth left theory snow whereby terminal weekly reject happiness circuit partial cup ad");
+		boolean result = inTest.validateRecoveryKey("""
+				pathway lift abuse plenty export texture gentleman landscape beyond ceiling around leaf cafe charity \
+				border breakdown victory surely computer cat linger restrict infer crowd live computer true written amazed \
+				investor boot depth left theory snow whereby terminal weekly reject happiness circuit partial cup ad \
+				""");
 		Assertions.assertTrue(result);
 	}