Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/cpw/mods/cl/ModuleClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cpw.mods.util.LambdaExceptionUtils;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
Expand All @@ -13,6 +12,7 @@
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.file.NoSuchFileException;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Consumer;
Expand Down Expand Up @@ -279,8 +279,11 @@ protected Class<?> findClass(final String moduleName, final String name) {
}

protected <T> T loadFromModule(final String moduleName, BiFunction<ModuleReader, ModuleReference, T> lookup) throws IOException {
var module = configuration.findModule(moduleName).orElseThrow(FileNotFoundException::new);
var ref = module.reference();
var module = configuration.findModule(moduleName);
if (module.isEmpty()) {
throw new NoSuchFileException("module " + moduleName);
}
var ref = module.get().reference();
try (var reader = ref.open()) {
return lookup.apply(reader, ref);
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/cpw/mods/niofs/union/UnionFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,12 @@ private Path toRealPath(final Path basePath, final UnionPath path) {

public SeekableByteChannel newReadByteChannel(final UnionPath path) throws IOException {
try {
return findFirstFiltered(path)
.map(this::byteChannel)
.orElseThrow(FileNotFoundException::new);
var ret = findFirstFiltered(path).map(this::byteChannel);
if (ret.isPresent()) {
return ret.get();
} else {
throw new NoSuchFileException(path.toString());
}
} catch (UncheckedIOException ioe) {
throw ioe.getCause();
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/cpw/mods/niofs/union/TestUnionFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
Expand Down Expand Up @@ -267,7 +266,7 @@ public void testDirectoryVisitorJar() throws Exception {
.peek(path -> foundFiles.add(path.toString()))
.map(p-> ()-> {
if (!Files.exists(p)) {
throw new FileNotFoundException(p.toString());
throw new NoSuchFileException(p.toString());
}
})
);
Expand Down