You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Heiko Seebach (JIRA)" <ji...@apache.org> on 2007/02/01 16:20:05 UTC
[jira] Created: (CONFIGURATION-252) Detection of absolute fileNames
when configuration sources are defined in a JAR file
Detection of absolute fileNames when configuration sources are defined in a JAR file
------------------------------------------------------------------------------------
Key: CONFIGURATION-252
URL: https://issues.apache.org/jira/browse/CONFIGURATION-252
Project: Commons Configuration
Issue Type: Bug
Affects Versions: 1.3
Environment: Linux
Reporter: Heiko Seebach
When using several configuration sources, the sources are defined in a an xml attribute like
fileName="usergui.properties"
The method org.apache.commons.configuration.ConfigurationUtils.getFile(String basePath, String fileName) converts the basePath and fileName into a File.
The JavaDoc says: "The parameter strings can be relative files, absolute files and URLs as well."
The file containing the definition of the configuration sources will become the basePath of this method.
After a log of debugging I found, that if the basePath start with "jar:" the method assumes that the fileName is relative, evene if it's absolute. This happens, because there's a ProtocolHandler for Jar files and "jar:" is a valid protocol. So the statement "new URL(new URL(basePath), fileName)" doesn't throw a MalformedUrlException.
Since the URL is valid, it's never checked, if the fileName may be absolute.
Attention: this is only the case on Unix/Linux, since this is a valid URL
jar:file:/C:/myjar.jar!/my-config.xml/someprops.properties
while under Windows, a MalformedUrlException will be thrown, when the fileName is absolute:
jar:file:/C:/myjar.jar!/my-config.xml/c:/someprops.properties
I attached a patch that checks, whether the URL protocol is "jar" and the fileName is absolute. If so, the absolute file will be used.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (CONFIGURATION-252) Detection of absolute
fileNames when configuration sources are defined in a JAR file
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oliver Heger resolved CONFIGURATION-252.
----------------------------------------
Resolution: Fixed
Fix Version/s: 1.4
The getFile() method now checks first whether an absolute file name is passed in. A note about the behavior of File.isAbsolute() on Windows and Unix was also added to the Javadocs.
> Detection of absolute fileNames when configuration sources are defined in a JAR file
> ------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-252
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-252
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: Linux
> Reporter: Heiko Seebach
> Assigned To: Oliver Heger
> Fix For: 1.4
>
> Attachments: support-for-jar-protocol.patch.txt
>
>
> When using several configuration sources, the sources are defined in a an xml attribute like
> fileName="usergui.properties"
> The method org.apache.commons.configuration.ConfigurationUtils.getFile(String basePath, String fileName) converts the basePath and fileName into a File.
> The JavaDoc says: "The parameter strings can be relative files, absolute files and URLs as well."
> The file containing the definition of the configuration sources will become the basePath of this method.
> After a log of debugging I found, that if the basePath start with "jar:" the method assumes that the fileName is relative, evene if it's absolute. This happens, because there's a ProtocolHandler for Jar files and "jar:" is a valid protocol. So the statement "new URL(new URL(basePath), fileName)" doesn't throw a MalformedUrlException.
> Since the URL is valid, it's never checked, if the fileName may be absolute.
> Attention: this is only the case on Unix/Linux, since this is a valid URL
> jar:file:/C:/myjar.jar!/my-config.xml/someprops.properties
> while under Windows, a MalformedUrlException will be thrown, when the fileName is absolute:
> jar:file:/C:/myjar.jar!/my-config.xml/c:/someprops.properties
> I attached a patch that checks, whether the URL protocol is "jar" and the fileName is absolute. If so, the absolute file will be used.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (CONFIGURATION-252) Detection of absolute
fileNames when configuration sources are defined in a JAR file
Posted by "Heiko Seebach (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469791 ]
Heiko Seebach commented on CONFIGURATION-252:
---------------------------------------------
Well, how to determine if a file is absolute?
Since it even depends on the OS, it's not that easy.
Scenario:
basePath=http://aconfigserver/configSources/config.xml
and
fileName=/configSources/config.properties
What could be the intention of it and what would others think, if they see it defined like that?
The properties files could reside at
http://aconfigserver/configSources/config.properties
or
http://aconfigserver/configSources/configSources/config.properties
or
file:///configSources/config.properties
I think, a good definition of the meaning and interpretation of the fileName (regarding the "File.isAbsolute()" concern) would help.
Maybe defining something simple like the definition before plus
-> If fileName starts with "/" it's always interpreted as absolute. <-
would help?
> Detection of absolute fileNames when configuration sources are defined in a JAR file
> ------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-252
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-252
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: Linux
> Reporter: Heiko Seebach
> Attachments: support-for-jar-protocol.patch.txt
>
>
> When using several configuration sources, the sources are defined in a an xml attribute like
> fileName="usergui.properties"
> The method org.apache.commons.configuration.ConfigurationUtils.getFile(String basePath, String fileName) converts the basePath and fileName into a File.
> The JavaDoc says: "The parameter strings can be relative files, absolute files and URLs as well."
> The file containing the definition of the configuration sources will become the basePath of this method.
> After a log of debugging I found, that if the basePath start with "jar:" the method assumes that the fileName is relative, evene if it's absolute. This happens, because there's a ProtocolHandler for Jar files and "jar:" is a valid protocol. So the statement "new URL(new URL(basePath), fileName)" doesn't throw a MalformedUrlException.
> Since the URL is valid, it's never checked, if the fileName may be absolute.
> Attention: this is only the case on Unix/Linux, since this is a valid URL
> jar:file:/C:/myjar.jar!/my-config.xml/someprops.properties
> while under Windows, a MalformedUrlException will be thrown, when the fileName is absolute:
> jar:file:/C:/myjar.jar!/my-config.xml/c:/someprops.properties
> I attached a patch that checks, whether the URL protocol is "jar" and the fileName is absolute. If so, the absolute file will be used.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (CONFIGURATION-252) Detection of absolute
fileNames when configuration sources are defined in a JAR file
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469842 ]
Oliver Heger commented on CONFIGURATION-252:
--------------------------------------------
So, would it be okay to always check for an absolute file name first (by using File.isAbsolute()) and pointing this out in the Javadoc of getFile()?
> Detection of absolute fileNames when configuration sources are defined in a JAR file
> ------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-252
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-252
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: Linux
> Reporter: Heiko Seebach
> Attachments: support-for-jar-protocol.patch.txt
>
>
> When using several configuration sources, the sources are defined in a an xml attribute like
> fileName="usergui.properties"
> The method org.apache.commons.configuration.ConfigurationUtils.getFile(String basePath, String fileName) converts the basePath and fileName into a File.
> The JavaDoc says: "The parameter strings can be relative files, absolute files and URLs as well."
> The file containing the definition of the configuration sources will become the basePath of this method.
> After a log of debugging I found, that if the basePath start with "jar:" the method assumes that the fileName is relative, evene if it's absolute. This happens, because there's a ProtocolHandler for Jar files and "jar:" is a valid protocol. So the statement "new URL(new URL(basePath), fileName)" doesn't throw a MalformedUrlException.
> Since the URL is valid, it's never checked, if the fileName may be absolute.
> Attention: this is only the case on Unix/Linux, since this is a valid URL
> jar:file:/C:/myjar.jar!/my-config.xml/someprops.properties
> while under Windows, a MalformedUrlException will be thrown, when the fileName is absolute:
> jar:file:/C:/myjar.jar!/my-config.xml/c:/someprops.properties
> I attached a patch that checks, whether the URL protocol is "jar" and the fileName is absolute. If so, the absolute file will be used.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (CONFIGURATION-252) Detection of absolute
fileNames when configuration sources are defined in a JAR file
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469731 ]
Oliver Heger commented on CONFIGURATION-252:
--------------------------------------------
Wouldn't it make sense if getFile() always checked whether the passed in fileName is an absolute file, no matter of the protocol? If this is the case, this file must be returned.
> Detection of absolute fileNames when configuration sources are defined in a JAR file
> ------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-252
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-252
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: Linux
> Reporter: Heiko Seebach
> Attachments: support-for-jar-protocol.patch.txt
>
>
> When using several configuration sources, the sources are defined in a an xml attribute like
> fileName="usergui.properties"
> The method org.apache.commons.configuration.ConfigurationUtils.getFile(String basePath, String fileName) converts the basePath and fileName into a File.
> The JavaDoc says: "The parameter strings can be relative files, absolute files and URLs as well."
> The file containing the definition of the configuration sources will become the basePath of this method.
> After a log of debugging I found, that if the basePath start with "jar:" the method assumes that the fileName is relative, evene if it's absolute. This happens, because there's a ProtocolHandler for Jar files and "jar:" is a valid protocol. So the statement "new URL(new URL(basePath), fileName)" doesn't throw a MalformedUrlException.
> Since the URL is valid, it's never checked, if the fileName may be absolute.
> Attention: this is only the case on Unix/Linux, since this is a valid URL
> jar:file:/C:/myjar.jar!/my-config.xml/someprops.properties
> while under Windows, a MalformedUrlException will be thrown, when the fileName is absolute:
> jar:file:/C:/myjar.jar!/my-config.xml/c:/someprops.properties
> I attached a patch that checks, whether the URL protocol is "jar" and the fileName is absolute. If so, the absolute file will be used.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (CONFIGURATION-252) Detection of absolute fileNames
when configuration sources are defined in a JAR file
Posted by "Heiko Seebach (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Heiko Seebach updated CONFIGURATION-252:
----------------------------------------
Attachment: support-for-jar-protocol.patch.txt
Simply apply this patch on org.apache.commons.configuration.ConfigurationUtils
> Detection of absolute fileNames when configuration sources are defined in a JAR file
> ------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-252
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-252
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: Linux
> Reporter: Heiko Seebach
> Attachments: support-for-jar-protocol.patch.txt
>
>
> When using several configuration sources, the sources are defined in a an xml attribute like
> fileName="usergui.properties"
> The method org.apache.commons.configuration.ConfigurationUtils.getFile(String basePath, String fileName) converts the basePath and fileName into a File.
> The JavaDoc says: "The parameter strings can be relative files, absolute files and URLs as well."
> The file containing the definition of the configuration sources will become the basePath of this method.
> After a log of debugging I found, that if the basePath start with "jar:" the method assumes that the fileName is relative, evene if it's absolute. This happens, because there's a ProtocolHandler for Jar files and "jar:" is a valid protocol. So the statement "new URL(new URL(basePath), fileName)" doesn't throw a MalformedUrlException.
> Since the URL is valid, it's never checked, if the fileName may be absolute.
> Attention: this is only the case on Unix/Linux, since this is a valid URL
> jar:file:/C:/myjar.jar!/my-config.xml/someprops.properties
> while under Windows, a MalformedUrlException will be thrown, when the fileName is absolute:
> jar:file:/C:/myjar.jar!/my-config.xml/c:/someprops.properties
> I attached a patch that checks, whether the URL protocol is "jar" and the fileName is absolute. If so, the absolute file will be used.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (CONFIGURATION-252) Detection of absolute
fileNames when configuration sources are defined in a JAR file
Posted by "Heiko Seebach (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469899 ]
Heiko Seebach commented on CONFIGURATION-252:
---------------------------------------------
Yes, I think that's fine. Maybe the JavaDoc could remind the the user that
new File("/file.properties").isAbsolute() is false under Windows but true under Unix....
> Detection of absolute fileNames when configuration sources are defined in a JAR file
> ------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-252
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-252
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: Linux
> Reporter: Heiko Seebach
> Attachments: support-for-jar-protocol.patch.txt
>
>
> When using several configuration sources, the sources are defined in a an xml attribute like
> fileName="usergui.properties"
> The method org.apache.commons.configuration.ConfigurationUtils.getFile(String basePath, String fileName) converts the basePath and fileName into a File.
> The JavaDoc says: "The parameter strings can be relative files, absolute files and URLs as well."
> The file containing the definition of the configuration sources will become the basePath of this method.
> After a log of debugging I found, that if the basePath start with "jar:" the method assumes that the fileName is relative, evene if it's absolute. This happens, because there's a ProtocolHandler for Jar files and "jar:" is a valid protocol. So the statement "new URL(new URL(basePath), fileName)" doesn't throw a MalformedUrlException.
> Since the URL is valid, it's never checked, if the fileName may be absolute.
> Attention: this is only the case on Unix/Linux, since this is a valid URL
> jar:file:/C:/myjar.jar!/my-config.xml/someprops.properties
> while under Windows, a MalformedUrlException will be thrown, when the fileName is absolute:
> jar:file:/C:/myjar.jar!/my-config.xml/c:/someprops.properties
> I attached a patch that checks, whether the URL protocol is "jar" and the fileName is absolute. If so, the absolute file will be used.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org