Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5701 Fixed resetting environment after merge. #5753

Merged
merged 2 commits into from
Jul 28, 2017
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,26 @@ private MagicCommandFunctionality classpathAddJar() {
}

private Collection<String> addJars(String path) {
Map<Path, String> addedJars = Maps.newHashMap();
List<String> addedJarsName = Lists.newLinkedList();

if (doesPathContainsWildCards(path)) {
validateWildcardPath(path);
Map<Path, String> collect = getPaths(path).keySet().stream()
.filter(
currentPath -> kernel.addJarToClasspath(new PathToJar(currentPath.toString())))
.collect(Collectors.toMap(o -> o, Path::toString));
addedJars.putAll(collect);
List<PathToJar> pathsToJars = getPaths(path).keySet().stream()
.map(currentPath -> new PathToJar(currentPath.toString()))
.collect(Collectors.toList());

List<Path> addedPaths = kernel.addJarsToClasspath(pathsToJars);
addedJarsName.addAll(addedPaths.stream().map(Path::toString).collect(Collectors.toList()));

} else {
validatePath(path);
Path currentPath = Paths.get(path);
if (this.kernel.addJarToClasspath(new PathToJar(path))) {
addedJars.put(currentPath, currentPath.getFileName().toString());
addedJarsName.add(currentPath.getFileName().toString());
}
}
return addedJars.values();

return addedJarsName;
}

private void validateWildcardPath(String path) {
Expand All @@ -230,8 +234,8 @@ private Map<Path, String> getPaths(String pathWithWildcard) {
try {

Map<Path, String> paths = Files.list(Paths.get(pathWithoutWildcards))
.filter(path -> path.toString().toLowerCase().endsWith(".jar"))
.collect(Collectors.toMap(p -> p, o -> o.getFileName().toString()));
.filter(path -> path.toString().toLowerCase().endsWith(".jar"))
.collect(Collectors.toMap(p -> p, o -> o.getFileName().toString()));

if (paths == null || paths.isEmpty()) {
throw new IllegalStateException("Cannot find any jars files in selected path");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we discussed, this exception is inappropriate for user errors.
use a conditional.

Expand Down