Skip to content

Commit ccc30ad

Browse files
code quality
1 parent 52beb3b commit ccc30ad

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

src/main/java/org/cryptomator/cryptofs/AsyncDelegatingFileChannel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public Future<Integer> write(ByteBuffer src, long position) {
110110

111111
private <T> Future<T> exceptionalFuture(Throwable exception) {
112112
CompletableFuture<T> future = new CompletableFuture<>();
113-
future.completeExceptionally(new ClosedChannelException());
113+
future.completeExceptionally(exception);
114114
return future;
115115
}
116116

src/main/java/org/cryptomator/cryptofs/CryptoFileAttributeProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
class CryptoFileAttributeProvider {
2222

23-
private static interface AttributeProvider<A extends BasicFileAttributes> {
24-
A provide(A delegate, Path ciphertextPath, FileHeaderCryptor headerCryptor);
25-
}
26-
2723
private final Map<Class<? extends BasicFileAttributes>, AttributeProvider<? extends BasicFileAttributes>> attributeProviders = new HashMap<>();
2824
private final FileHeaderCryptor headerCryptor;
2925

@@ -45,4 +41,8 @@ public <A extends BasicFileAttributes> A readAttributes(Path ciphertextPath, Cla
4541
}
4642
}
4743

44+
private static interface AttributeProvider<A extends BasicFileAttributes> {
45+
A provide(A delegate, Path ciphertextPath, FileHeaderCryptor headerCryptor);
46+
}
47+
4848
}

src/test/java/org/cryptomator/cryptofs/BasicPathTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ public class BasicPathTest {
4242
public final ExpectedException thrown = ExpectedException.none();
4343

4444
private static final String FS_SCHEME = "MOCK";
45-
private FileSystemProvider fsProvider;
4645
private BasicFileSystem fs;
4746
private BasicPath fsRoot;
4847
private BasicPath emptyPath;
4948

5049
@Before
5150
public void setup() {
52-
fsProvider = Mockito.mock(FileSystemProvider.class);
51+
FileSystemProvider fsProvider = Mockito.mock(FileSystemProvider.class);
5352
fs = Mockito.mock(BasicFileSystem.class);
5453
fsRoot = new BasicPath(fs, Collections.emptyList(), true);
5554
emptyPath = new BasicPath(fs, Collections.emptyList(), false);

src/test/java/org/cryptomator/cryptofs/CryptoFileAttributeProviderTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public class CryptoFileAttributeProviderTest {
2626

2727
private FileHeaderCryptor fileHeaderCryptor;
2828
private Path ciphertextFilePath;
29-
private BasicFileAttributes basicAttr;
30-
private PosixFileAttributes posixAttr;
31-
private DosFileAttributes dosAttr;
3229

3330
@Before
3431
public void setup() throws IOException {
@@ -38,9 +35,9 @@ public void setup() throws IOException {
3835
Mockito.when(ciphertextFilePath.getFileSystem()).thenReturn(fs);
3936
FileSystemProvider provider = Mockito.mock(FileSystemProvider.class);
4037
Mockito.when(fs.provider()).thenReturn(provider);
41-
basicAttr = Mockito.mock(BasicFileAttributes.class);
42-
posixAttr = Mockito.mock(PosixFileAttributes.class);
43-
dosAttr = Mockito.mock(DosFileAttributes.class);
38+
BasicFileAttributes basicAttr = Mockito.mock(BasicFileAttributes.class);
39+
PosixFileAttributes posixAttr = Mockito.mock(PosixFileAttributes.class);
40+
DosFileAttributes dosAttr = Mockito.mock(DosFileAttributes.class);
4441
Mockito.when(provider.readAttributes(Mockito.same(ciphertextFilePath), Mockito.same(BasicFileAttributes.class), Mockito.any())).thenReturn(basicAttr);
4542
Mockito.when(provider.readAttributes(Mockito.same(ciphertextFilePath), Mockito.same(PosixFileAttributes.class), Mockito.any())).thenReturn(posixAttr);
4643
Mockito.when(provider.readAttributes(Mockito.same(ciphertextFilePath), Mockito.same(DosFileAttributes.class), Mockito.any())).thenReturn(dosAttr);

src/test/java/org/cryptomator/cryptofs/CryptoFileSystemTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ public synchronized void nextBytes(byte[] bytes) {
4141
public final ExpectedException thrown = ExpectedException.none();
4242

4343
private Path tmpPath;
44-
private ConcurrentHashMap<Path, CryptoFileSystem> openFileSystems;
4544
private CryptoFileSystemProvider provider;
4645

4746
@Before
4847
public void setup() throws IOException, ReflectiveOperationException {
4948
tmpPath = Files.createTempDirectory("unit-tests");
50-
openFileSystems = new ConcurrentHashMap<>();
5149
provider = Mockito.mock(CryptoFileSystemProvider.class);
50+
ConcurrentHashMap<Path, CryptoFileSystem> openFileSystems = new ConcurrentHashMap<>();
5251
Mockito.when(provider.getFileSystems()).thenReturn(openFileSystems);
5352
}
5453

0 commit comments

Comments
 (0)