diff --git a/main/commons/src/main/java/org/cryptomator/common/UncheckedInterruptedException.java b/main/commons/src/main/java/org/cryptomator/common/UncheckedInterruptedException.java deleted file mode 100644 index 9207c216c..000000000 --- a/main/commons/src/main/java/org/cryptomator/common/UncheckedInterruptedException.java +++ /dev/null @@ -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(); - } - -} diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextReader.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextReader.java index 491b954e7..fbba8e950 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextReader.java +++ b/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 { } @Override - public Void call() { + public Void call() throws InterruptedIOException { file.position(startpos); int bytesRead = -1; try { @@ -37,7 +38,7 @@ class CiphertextReader implements Callable { } while (bytesRead > 0); decryptor.append(FileContentCryptor.EOF); } catch (InterruptedException e) { - Thread.currentThread().interrupt(); + throw new InterruptedIOException("Task interrupted while waiting for ciphertext"); } return null; } diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextWriter.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextWriter.java index f4716673b..2fe3c320e 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CiphertextWriter.java +++ b/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 { } @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; } diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoReadableFile.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoReadableFile.java index f7f72e1b7..14a2c7b26 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoReadableFile.java +++ b/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")); } } diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoWritableFile.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoWritableFile.java index d40b7623c..a7508e622 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoWritableFile.java +++ b/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")); } }