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

#7580 fix por parsing sparkex.jar path #7591

Merged
merged 2 commits into from
Jun 27, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddJarMagicCommand;
import com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutcomeItem;

import java.io.File;
import java.net.URLDecoder;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

public class SparkexJarServiceImpl implements SparkexJarService {
Expand All @@ -36,10 +39,8 @@ public MagicCommandOutcomeItem addSparkexJar(KernelFunctionality kernel) {

private String getSparkexJar() {
try {
String path = EnableSparkSupportMagicCommand.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8")
.replace("scala/lib/scala.jar", "sparkex/lib/sparkex.jar");
return decodedPath;
Path path = Paths.get(EnableSparkSupportMagicCommand.class.getProtectionDomain().getCodeSource().getLocation().toURI());
return path.getParent().getParent().getParent().resolve("sparkex").resolve("lib").resolve("sparkex.jar").toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.Test;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -51,9 +52,9 @@ public class SparkUiDefaultsImplTest {
private final String SPARK_OPT = "config";

@Before
public void setUp() {
String path = this.getClass().getClassLoader().getResource("beakerxTest.json").getPath();
this.pathToBeakerxTestJson = Paths.get(path);
public void setUp() throws URISyntaxException {
Path path = Paths.get(this.getClass().getClassLoader().getResource("beakerxTest.json").toURI());
this.pathToBeakerxTestJson = path;
this.sut = new SparkUiDefaultsImpl(pathToBeakerxTestJson);
}

Expand Down