diff --git a/main/commons/pom.xml b/main/commons/pom.xml
new file mode 100644
index 000000000..b2e8b1bf3
--- /dev/null
+++ b/main/commons/pom.xml
@@ -0,0 +1,16 @@
+
+
+
+ 4.0.0
+
+ org.cryptomator
+ main
+ 0.11.0-SNAPSHOT
+
+ commons
+ Cryptomator common
+ Shared utilities
+
+
diff --git a/main/commons/src/main/java/org/cryptomator/common/UncheckedInterruptedException.java b/main/commons/src/main/java/org/cryptomator/common/UncheckedInterruptedException.java
new file mode 100644
index 000000000..9207c216c
--- /dev/null
+++ b/main/commons/src/main/java/org/cryptomator/common/UncheckedInterruptedException.java
@@ -0,0 +1,14 @@
+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/pom.xml b/main/filesystem-crypto/pom.xml
index a5e73da35..a04425df9 100644
--- a/main/filesystem-crypto/pom.xml
+++ b/main/filesystem-crypto/pom.xml
@@ -31,6 +31,10 @@
org.cryptomator
filesystem-nameshortening
+
+ org.cryptomator
+ commons
+
diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FifoParallelDataProcessor.java b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FifoParallelDataProcessor.java
index f63045016..5dca43753 100644
--- a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FifoParallelDataProcessor.java
+++ b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FifoParallelDataProcessor.java
@@ -11,10 +11,15 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import org.cryptomator.common.UncheckedInterruptedException;
+
/**
- * Executes long-running computations and returns the result strictly in order of the job submissions, no matter how long each job takes.
+ * Executes long-running computations and returns the result strictly in order
+ * of the job submissions, no matter how long each job takes.
*
- * The internally used thread pool is shut down automatically as soon as this FifiParallelDataProcessor is no longer referenced (see Finalization behaviour of {@link ThreadPoolExecutor}).
+ * The internally used thread pool is shut down automatically as soon as this
+ * FifiParallelDataProcessor is no longer referenced (see Finalization behaviour
+ * of {@link ThreadPoolExecutor}).
*/
class FifoParallelDataProcessor {
@@ -24,8 +29,11 @@ class FifoParallelDataProcessor {
private final ExecutorService executorService;
/**
- * @param numThreads How many jobs can run in parallel.
- * @param workQueueSize Maximum number of jobs accepted without blocking, when no results are polled from {@link #processedData()}.
+ * @param numThreads
+ * How many jobs can run in parallel.
+ * @param workQueueSize
+ * Maximum number of jobs accepted without blocking, when no
+ * results are polled from {@link #processedData()}.
*/
public FifoParallelDataProcessor(int numThreads, int workQueueSize) {
this.workQueue = new ArrayBlockingQueue<>(workQueueSize);
@@ -33,7 +41,8 @@ class FifoParallelDataProcessor {
}
/**
- * Enqueues tasks into the blocking queue, if they can not be executed immediately.
+ * Enqueues tasks into the blocking queue, if they can not be executed
+ * immediately.
*
* @see ThreadPoolExecutor#execute(Runnable)
*/
@@ -41,27 +50,30 @@ class FifoParallelDataProcessor {
try {
this.workQueue.put(r);
} catch (InterruptedException e) {
- throw new SneakyInterruptedException(e);
+ throw new UncheckedInterruptedException(e);
}
}
/**
- * Enqueues a job for execution. The results of multiple submissions can be polled in FIFO order using {@link #processedData()}.
+ * Enqueues a job for execution. The results of multiple submissions can be
+ * polled in FIFO order using {@link #processedData()}.
*
- * @param processingJob A task, that will compute a result.
+ * @param processingJob
+ * A task, that will compute a result.
* @throws InterruptedException
*/
void submit(Callable processingJob) throws InterruptedException {
try {
Future future = executorService.submit(processingJob);
processedData.offer(new SequencedFutureResult(future, jobSequence.getAndIncrement()));
- } catch (SneakyInterruptedException e) {
+ } catch (UncheckedInterruptedException e) {
throw e.getCause();
}
}
/**
- * Submits already pre-processed data, that can be polled in FIFO order from {@link #processedData()}.
+ * Submits already pre-processed data, that can be polled in FIFO order from
+ * {@link #processedData()}.
*
* @throws InterruptedException
*/
@@ -72,10 +84,13 @@ class FifoParallelDataProcessor {
}
/**
- * Result of previously {@link #submit(Callable) submitted} jobs in the same order as they have been submitted. Blocks if the job didn't finish yet.
+ * Result of previously {@link #submit(Callable) submitted} jobs in the same
+ * order as they have been submitted. Blocks if the job didn't finish yet.
*
* @return Next job result
- * @throws InterruptedException If the calling thread was interrupted while waiting for the next result.
+ * @throws InterruptedException
+ * If the calling thread was interrupted while waiting for the
+ * next result.
*/
T processedData() throws InterruptedException {
return processedData.take().get();
@@ -110,19 +125,4 @@ class FifoParallelDataProcessor {
}
- private static class SneakyInterruptedException extends RuntimeException {
-
- private static final long serialVersionUID = 331817765088138556L;
-
- public SneakyInterruptedException(InterruptedException cause) {
- super(cause);
- }
-
- @Override
- public InterruptedException getCause() {
- return (InterruptedException) super.getCause();
- }
-
- }
-
}
diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoReadableFile.java b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoReadableFile.java
index c297a73dc..20e78cf7f 100644
--- a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoReadableFile.java
+++ b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoReadableFile.java
@@ -7,6 +7,7 @@ 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;
@@ -60,7 +61,7 @@ class CryptoReadableFile implements ReadableFile {
return bytesRead;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
- throw new RuntimeException(e);
+ throw new UncheckedInterruptedException(e);
}
}
diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoWritableFile.java b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoWritableFile.java
index 59fc3def3..da238cb94 100644
--- a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoWritableFile.java
+++ b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/fs/CryptoWritableFile.java
@@ -10,6 +10,7 @@ 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;
@@ -47,7 +48,7 @@ class CryptoWritableFile implements WritableFile {
return size;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
- throw new RuntimeException(e);
+ throw new UncheckedInterruptedException(e);
}
}
diff --git a/main/pom.xml b/main/pom.xml
index 54879dd88..db046a3de 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -1,13 +1,9 @@
-
-
+
+
4.0.0
org.cryptomator
main
@@ -62,6 +58,12 @@
test
+
+
+ org.cryptomator
+ commons
+ ${project.version}
+
org.cryptomator
filesystem-api
@@ -149,7 +151,8 @@
${commons-codec.version}
-
+
commons-httpclient
commons-httpclient
${commons-httpclient.version}
@@ -237,6 +240,8 @@
+ commons
+ commons-test
filesystem-api
filesystem-inmemory
filesystem-nio
@@ -244,10 +249,9 @@
filesystem-crypto
crypto-api
crypto-aes
+ jackrabbit-filesystem-adapter
core
ui
- jackrabbit-filesystem-adapter
- commons-test