mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 01:26:52 -04:00
same InterruptedIOException in all cases
This commit is contained in:
@@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.cryptomator.filesystem.crypto;
|
package org.cryptomator.filesystem.crypto;
|
||||||
|
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ class CiphertextReader implements Callable<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() {
|
public Void call() throws InterruptedIOException {
|
||||||
file.position(startpos);
|
file.position(startpos);
|
||||||
int bytesRead = -1;
|
int bytesRead = -1;
|
||||||
try {
|
try {
|
||||||
@@ -37,7 +38,7 @@ class CiphertextReader implements Callable<Void> {
|
|||||||
} while (bytesRead > 0);
|
} while (bytesRead > 0);
|
||||||
decryptor.append(FileContentCryptor.EOF);
|
decryptor.append(FileContentCryptor.EOF);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
throw new InterruptedIOException("Task interrupted while waiting for ciphertext");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.cryptomator.filesystem.crypto;
|
package org.cryptomator.filesystem.crypto;
|
||||||
|
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.io.UncheckedIOException;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@@ -20,14 +19,14 @@ class CiphertextWriter implements Callable<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() {
|
public Void call() throws InterruptedIOException {
|
||||||
try {
|
try {
|
||||||
ByteBuffer ciphertext;
|
ByteBuffer ciphertext;
|
||||||
while ((ciphertext = encryptor.ciphertext()) != FileContentCryptor.EOF) {
|
while ((ciphertext = encryptor.ciphertext()) != FileContentCryptor.EOF) {
|
||||||
file.write(ciphertext);
|
file.write(ciphertext);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.cryptomator.filesystem.crypto;
|
package org.cryptomator.filesystem.crypto;
|
||||||
|
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.cryptomator.common.UncheckedInterruptedException;
|
|
||||||
import org.cryptomator.crypto.engine.FileContentCryptor;
|
import org.cryptomator.crypto.engine.FileContentCryptor;
|
||||||
import org.cryptomator.crypto.engine.FileContentDecryptor;
|
import org.cryptomator.crypto.engine.FileContentDecryptor;
|
||||||
import org.cryptomator.filesystem.ReadableFile;
|
import org.cryptomator.filesystem.ReadableFile;
|
||||||
@@ -56,8 +56,7 @@ class CryptoReadableFile implements ReadableFile {
|
|||||||
}
|
}
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for cleartext"));
|
||||||
throw new UncheckedInterruptedException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.cryptomator.filesystem.crypto;
|
package org.cryptomator.filesystem.crypto;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -18,18 +19,13 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.cryptomator.common.UncheckedInterruptedException;
|
|
||||||
import org.cryptomator.crypto.engine.FileContentCryptor;
|
import org.cryptomator.crypto.engine.FileContentCryptor;
|
||||||
import org.cryptomator.crypto.engine.FileContentEncryptor;
|
import org.cryptomator.crypto.engine.FileContentEncryptor;
|
||||||
import org.cryptomator.filesystem.WritableFile;
|
import org.cryptomator.filesystem.WritableFile;
|
||||||
import org.cryptomator.io.ByteBuffers;
|
import org.cryptomator.io.ByteBuffers;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
class CryptoWritableFile implements WritableFile {
|
class CryptoWritableFile implements WritableFile {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CryptoWritableFile.class);
|
|
||||||
|
|
||||||
final WritableFile file;
|
final WritableFile file;
|
||||||
private final ExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
private final ExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
private final FileContentEncryptor encryptor;
|
private final FileContentEncryptor encryptor;
|
||||||
@@ -59,8 +55,7 @@ class CryptoWritableFile implements WritableFile {
|
|||||||
encryptor.append(cleartextCopy);
|
encryptor.append(cleartextCopy);
|
||||||
return size;
|
return size;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for encryptor capacity"));
|
||||||
throw new UncheckedInterruptedException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user