Skip to content

Commit

Permalink
Remove CloseablePathProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Aug 28, 2016
1 parent afb80b5 commit 87ff19e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 49 deletions.
Expand Up @@ -116,8 +116,7 @@ private List<Class<?>> findClassesForUris(List<URI> baseUris, String basePackage
}

private List<Class<?>> findClassesForUri(String basePackageName, URI baseUri, Predicate<Class<?>> classFilter) {
CloseablePathProvider provider = CloseablePathProvider.create(baseUri.getScheme());
try (CloseablePath closeablePath = provider.toCloseablePath(baseUri)) {
try (CloseablePath closeablePath = CloseablePath.create(baseUri)) {
Path baseDir = closeablePath.getPath();
return findClassesForPath(basePackageName, baseDir, classFilter);
}
Expand Down
Expand Up @@ -10,22 +10,40 @@

package org.junit.platform.commons.util;

import static java.util.Collections.emptyMap;

import java.io.Closeable;
import java.io.IOException;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;

final class CloseablePath implements Closeable {

static final Closeable NULL_CLOSEABLE = () -> {
};
private static final String JAR_URI_SCHEME = "jar";
private static final String JAR_URI_SEPARATOR = "!";

private static final Closeable NULL_CLOSEABLE = () -> {
};

private final Path path;
private final Closeable delegate;

CloseablePath(Path path, Closeable delegate) {
this.path = path;
this.delegate = delegate;
}
static CloseablePath create(URI uri) throws IOException {
if (JAR_URI_SCHEME.equals(uri.getScheme())) {
String[] parts = uri.toString().split(JAR_URI_SEPARATOR);
FileSystem fileSystem = FileSystems.newFileSystem(URI.create(parts[0]), emptyMap());
return new CloseablePath(fileSystem.getPath(parts[1]), fileSystem);
}
return new CloseablePath(Paths.get(uri), NULL_CLOSEABLE);
}

private CloseablePath(Path path, Closeable delegate) {
this.path = path;
this.delegate = delegate;
}

public Path getPath() {
return path;
Expand Down

This file was deleted.

0 comments on commit 87ff19e

Please sign in to comment.