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

Spaces in path to JAR leads to exception "Location does not exist." #15

Closed
scito opened this issue Dec 15, 2016 · 0 comments
Closed

Spaces in path to JAR leads to exception "Location does not exist." #15

scito opened this issue Dec 15, 2016 · 0 comments
Labels

Comments

@scito
Copy link

scito commented Dec 15, 2016

Configuration.getSupportCodeLocation() line 205 of matconsolectl-4.4.2 does not support spaces in path to the code location. Spaces are taken from URL where spaces could be encoded as %20. However this String path is directly put into a Java File path where the space encoding is not handled properly.

//Convert from url to absolute path
String path = url.getFile(); // Path is URL encoded, ie it could contain %20 for spaces
...
File file = new File(path).getCanonicalFile(); // Expects a "normal path"

Proposition: Convert URL directly into a File:

File file = new File(url.toURI()).getCanonicalFile();
matlabcontrol.MatlabConnectionException: Support code location was determined improperly. Location does not exist.
Location determined as: C:\Program%20Files%20(x86)\Polysun915\lib\matconsolectl-4.4.2.jar
Path: /C:/Program%20Files%20(x86)/Polysun915/lib/matconsolectl-4.4.2.jar
URL Location: file:/C:/Program%20Files%20(x86)/Polysun915/lib/matconsolectl-4.4.2.jar
Code Source: (file:/C:/Program%20Files%20(x86)/Polysun915/lib/matconsolectl-4.4.2.jar <no signer certificates>)
Protection Domain: ProtectionDomain  (file:/C:/Program%20Files%20(x86)/Polysun915/lib/matconsolectl-4.4.2.jar <no signer certificates>)
 sun.misc.Launcher$AppClassLoader@1262bf4
 <no principals>
 java.security.Permissions@269b79 (
 ("java.lang.RuntimePermission" "exitVM")
 ("java.io.FilePermission" "\C:\Program Files (x86)\Polysun915\lib\matconsolectl-4.4.2.jar" "read")
)
Class Loader: sun.misc.Launcher$AppClassLoader@1262bf4
Class Loader Class: class sun.misc.Launcher$AppClassLoader
	at matlabcontrol.Configuration.getSupportCodeLocation(Configuration.java:221)
	at matlabcontrol.RemoteMatlabProxyFactory.getRunArg(RemoteMatlabProxyFactory.java:298)
	at matlabcontrol.RemoteMatlabProxyFactory.createProcess(RemoteMatlabProxyFactory.java:262)
	at matlabcontrol.RemoteMatlabProxyFactory.requestProxyImp(RemoteMatlabProxyFactory.java:137)
	at matlabcontrol.RemoteMatlabProxyFactory.access$000(RemoteMatlabProxyFactory.java:36)
	at matlabcontrol.RemoteMatlabProxyFactory$1.call(RemoteMatlabProxyFactory.java:68)
	at matlabcontrol.RemoteMatlabProxyFactory$1.call(RemoteMatlabProxyFactory.java:65)
	at matlabcontrol.RemoteMatlabProxyFactory.callWithClassLoader(RemoteMatlabProxyFactory.java:86)
	at matlabcontrol.RemoteMatlabProxyFactory.requestProxy(RemoteMatlabProxyFactory.java:65)
	at matlabcontrol.RemoteMatlabProxyFactory.getProxy(RemoteMatlabProxyFactory.java:153)
	at matlabcontrol.MatlabProxyFactory.getProxy(MatlabProxyFactory.java:57)
	at com.velasolaris.plugin.controller.matlab.matconsolectl.MatlabPluginController.getProxy(MatlabPluginController.java:481)
	at com.velasolaris.plugin.controller.matlab.matconsolectl.MatlabPluginController.writeMsgToMatlab(MatlabPluginController.java:496)
	at com.velasolaris.plugin.controller.matlab.matconsolectl.MatlabPluginController.setupMatlabCtl(MatlabPluginController.java:462)
	at com.velasolaris.plugin.controller.matlab.matconsolectl.MatlabPluginController.build(MatlabPluginController.java:360)
	... 56 more

This behavior was seen on Windows 10.

scito pushed a commit to scito/matconsolectl that referenced this issue Dec 15, 2016
nedtwigg added a commit that referenced this issue Dec 15, 2016
Fix #15: Convert URL directly into a File
@nedtwigg nedtwigg added the bug label Dec 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants