Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Loading config.xml from classpath doesn't work properly #6232
According to the Command Line Usage documentation, it should be possible to load
Steps to reproduce:
The root cause is a bug in the method
That call loads
Now that we know the root cause, it's easy to come up with a workaround.
The first workaround is to use an absolute (resource) path to load the resource in my test:
This forces the class loader to look in the root of the classpath. It's not so elegant, but I can live with it.
The second workaround is to move
You can load configuration from absolute path like we do.
Aren't these 2 statements conflicting. You say it is looking only in our package, but you show it is also looking through all classpaths.
I looked at the source of my
One thing to note, since we are using
@romani Should we make this change? I personally don't think we should take all resources as relative and instead require user to only use absolute.
Please understand that my suggestion will not "suddenly" cause all resources to be interpreted relative. In all cases, both absolute resources and relative resources work, the only difference is what the relative resources are relative to.
The question you need to ask yourself is "Is it reasonable to assume that relative classpath resources are loaded relative to
The latter allows greater flexibility in defining and placing configurations, and is much more intuitive to users.
Yes, I started to see somethings after my original post when I started looking into the resource loading source, hence why I made edits.
I was stating to use the absolute file path, not the absolute resource path, which is what your workaround stated. IE:
That is not entirely accurate with the change you recommended. Some tests fail when I make this change because
Based on my previous comment, it looks like this is what exactly it does, hence why the starting
Can you describe what you mean? Absolute versus relative to the root, it all seems the same, just +/- 1 character.
I think it make sense to make resource loading to be from root, it is easier for user to predict what path is required from him.
@rnveach , I think it is reasonable to mark issue as "approved" and discuss details(starting