Jelajahi Sumber

same InterruptedIOException in all cases

Sebastian Stenzel 9 tahun lalu
induk
melakukan
fa35b63b6d

+ 0 - 14
main/commons/src/main/java/org/cryptomator/common/UncheckedInterruptedException.java

@@ -1,14 +0,0 @@
-package org.cryptomator.common;
-
-public class UncheckedInterruptedException extends RuntimeException {
-
-	public UncheckedInterruptedException(InterruptedException e) {
-		super(e);
-	}
-
-	@Override
-	public InterruptedException getCause() {
-		return (InterruptedException) super.getCause();
-	}
-
-}

+ 3 - 2
main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextReader.java

@@ -1,5 +1,6 @@
 package org.cryptomator.filesystem.crypto;
 
+import java.io.InterruptedIOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.Callable;
 
@@ -22,7 +23,7 @@ class CiphertextReader implements Callable<Void> {
 	}
 
 	@Override
-	public Void call() {
+	public Void call() throws InterruptedIOException {
 		file.position(startpos);
 		int bytesRead = -1;
 		try {
@@ -37,7 +38,7 @@ class CiphertextReader implements Callable<Void> {
 			} while (bytesRead > 0);
 			decryptor.append(FileContentCryptor.EOF);
 		} catch (InterruptedException e) {
-			Thread.currentThread().interrupt();
+			throw new InterruptedIOException("Task interrupted while waiting for ciphertext");
 		}
 		return null;
 	}

+ 2 - 3
main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextWriter.java

@@ -1,7 +1,6 @@
 package org.cryptomator.filesystem.crypto;
 
 import java.io.InterruptedIOException;
-import java.io.UncheckedIOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.Callable;
 
@@ -20,14 +19,14 @@ class CiphertextWriter implements Callable<Void> {
 	}
 
 	@Override
-	public Void call() {
+	public Void call() throws InterruptedIOException {
 		try {
 			ByteBuffer ciphertext;
 			while ((ciphertext = encryptor.ciphertext()) != FileContentCryptor.EOF) {
 				file.write(ciphertext);
 			}
 		} catch (InterruptedException e) {
-			throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for ciphertext"));
+			throw new InterruptedIOException("Task interrupted while waiting for ciphertext");
 		}
 		return null;
 	}

+ 2 - 3
main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoReadableFile.java

@@ -8,13 +8,13 @@
  *******************************************************************************/
 package org.cryptomator.filesystem.crypto;
 
+import java.io.InterruptedIOException;
 import java.io.UncheckedIOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
-import org.cryptomator.common.UncheckedInterruptedException;
 import org.cryptomator.crypto.engine.FileContentCryptor;
 import org.cryptomator.crypto.engine.FileContentDecryptor;
 import org.cryptomator.filesystem.ReadableFile;
@@ -56,8 +56,7 @@ class CryptoReadableFile implements ReadableFile {
 			}
 			return bytesRead;
 		} catch (InterruptedException e) {
-			Thread.currentThread().interrupt();
-			throw new UncheckedInterruptedException(e);
+			throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for cleartext"));
 		}
 	}
 

+ 2 - 7
main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoWritableFile.java

@@ -9,6 +9,7 @@
 package org.cryptomator.filesystem.crypto;
 
 import java.io.IOException;
+import java.io.InterruptedIOException;
 import java.io.UncheckedIOException;
 import java.nio.ByteBuffer;
 import java.time.Instant;
@@ -18,18 +19,13 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
-import org.cryptomator.common.UncheckedInterruptedException;
 import org.cryptomator.crypto.engine.FileContentCryptor;
 import org.cryptomator.crypto.engine.FileContentEncryptor;
 import org.cryptomator.filesystem.WritableFile;
 import org.cryptomator.io.ByteBuffers;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 class CryptoWritableFile implements WritableFile {
 
-	private static final Logger LOG = LoggerFactory.getLogger(CryptoWritableFile.class);
-
 	final WritableFile file;
 	private final ExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
 	private final FileContentEncryptor encryptor;
@@ -59,8 +55,7 @@ class CryptoWritableFile implements WritableFile {
 			encryptor.append(cleartextCopy);
 			return size;
 		} catch (InterruptedException e) {
-			Thread.currentThread().interrupt();
-			throw new UncheckedInterruptedException(e);
+			throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for encryptor capacity"));
 		}
 	}