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
Trailing slash on the root dir leads to an IOException when calling URL.openstream() #276
Comments
I can confirm this behaviour. |
Wow. That's weird... thanks for the PR, @StephanRichter |
It's not only for the Even if public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) {
super(delimiterStartChar, delimiterStopChar);
this.groupDirName = dirName;
File dir = new File(dirName);
if ( dir.exists() && dir.isDirectory() ) {
// we found the directory and it'll be file based
try {
root = dir.toURI().toURL(); so the root ( Seems like the PR will fix that case too but it is still not released. |
this is next on my list to look at....thanks! |
this seems very strange to me. Why does |
this seems to pass: @Test public void testSimpleGroupWithTrailingSlashOnDir() throws Exception {
String dir = getRandomDir() + "/"; <---------------- add /
writeFile(dir, "a.st", "a(x) ::= <<foo>>");
STGroup group = new STGroupDir(dir);
ST st = group.getInstanceOf("a");
String expected = "foo";
String result = st.render();
assertEquals(expected, result);
} maybe it has to be a URL like |
I should also point out that without the
|
Instantiating a
STGroupDir(URL root, ...)
, where root contains a trailing slash (/
), leads to an JavaIOException
when callingURL.openstream()
in the methodpublic CompiledST loadTemplateFile(String prefix, String unqualifiedFileName)
. The reason is a doubleslash//
coming from the expressionf = new URL(root+prefix+unqualifiedFileName)
. Maybe URI normalizing could fix the problem, i.e.f = f.toURI().normalize().toURL()
. This situation occurs (for example) after updating Apache Felix Framework to version 7.0.0 because of https://issues.apache.org/jira/browse/FELIX-6294.The text was updated successfully, but these errors were encountered: