commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CONFIGURATION-609) When using a VFSFileSystem on a PropertiesConfiguration, processing an include token defaults back to DefaultFileSystem
Date Wed, 26 Aug 2015 19:42:45 GMT

    [ https://issues.apache.org/jira/browse/CONFIGURATION-609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14715391#comment-14715391
] 

Oliver Heger commented on CONFIGURATION-609:
--------------------------------------------

This looks indeed like a bug. I will have a look (in the next few days). Thanks for the report.

> When using a VFSFileSystem on a PropertiesConfiguration, processing an include token
defaults back to DefaultFileSystem
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-609
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-609
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: File reloading
>    Affects Versions: 2.0
>         Environment: OSX using Eclipse/Maven
>            Reporter: Patrick Ethier
>
> I have uploaded two files to HDFS.
> -----
> bob.properties:
> ==
> include=fred.properties
> ==
> ----
> fred.properties
> ==
> key=value
> ==
> ---
> If I load fred.properties and evaluated the "key", value is returned as expected. If
I load bob.properties, I get a ConfigurationException.
> Here is the code snippet, please change setFileName() to reflect both cases:
> 		FileSystem fsTest = new VFSFileSystem();
> 		fsTest.setFileOptionsProvider(new HDFSOptionsProvider());
> 		
> 		Parameters params = new Parameters();
> 		FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
> 		    new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
> 		    .configure(params.fileBased()
> 		    	.setLocationStrategy(new FileSystemLocationStrategy())
> 		    	.setBasePath("hdfs://localhost:8020/user/myusername")
> 		        .setFileName("bob.properties")
> 		        .setFileSystem(fsTest));
> 		
> 		Configuration config;
> 		try {
> 			config = builder.getConfiguration();
> 			System.out.println(config.getString("key"));
> 		} catch (ConfigurationException e) {
> 			e.printStackTrace();
> 		}
> --------------------
> HDFSOptionsProvider.java:
> ==
> public class HDFSOptionsProvider implements FileOptionsProvider {
> 	@Override
> 	public Map<String, Object> getOptions() {
> 		Map<String, Object> opts = new HashMap<String, Object>();
> 		opts.put("DefaultProvider", HdfsFileProvider.class);
> 		return  opts;
> 	}
> }
> ==
> -------------
> Here is the Exception trace:
> 15/08/25 14:14:46 INFO impl.StandardFileSystemManager: Using "/tmp/vfs_cache" as temporary
files store.
> 15/08/25 14:14:47 WARN util.NativeCodeLoader: Unable to load native-hadoop library for
your platform... using builtin-java classes where applicable
> org.apache.commons.configuration2.ex.ConfigurationException: Unable to load the configuration
from the URL hdfs://localhost:8020/user/myusername/fred.properties
> 	at org.apache.commons.configuration2.io.DefaultFileSystem.getInputStream(DefaultFileSystem.java:56)
> 	at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:979)
> 	at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:740)
> 	at org.apache.commons.configuration2.PropertiesConfiguration.loadIncludeFile(PropertiesConfiguration.java:1419)
> 	at org.apache.commons.configuration2.PropertiesConfiguration.propertyLoaded(PropertiesConfiguration.java:571)
> 	at org.apache.commons.configuration2.PropertiesConfigurationLayout.load(PropertiesConfigurationLayout.java:494)
> 	at org.apache.commons.configuration2.PropertiesConfiguration.read(PropertiesConfiguration.java:509)
> 	at org.apache.commons.configuration2.io.FileHandler.loadFromReader(FileHandler.java:1124)
> 	at org.apache.commons.configuration2.io.FileHandler.loadFromTransformedStream(FileHandler.java:1110)
> 	at org.apache.commons.configuration2.io.FileHandler.loadFromStream(FileHandler.java:1049)
> 	at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:980)
> 	at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:963)
> 	at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:692)
> 	at org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder.initFileHandler(FileBasedConfigurationBuilder.java:312)
> 	at org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder.initResultInstance(FileBasedConfigurationBuilder.java:291)
> 	at org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder.initResultInstance(FileBasedConfigurationBuilder.java:60)
> 	at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.createResult(BasicConfigurationBuilder.java:421)
> 	at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.getConfiguration(BasicConfigurationBuilder.java:285)
> 	at com.secureops.config.TestLoadConf.main(TestLoadConf.java:33)
> Caused by: java.io.IOException: VFS URLs can only be used with VFS APIs
> 	at org.apache.commons.configuration2.io.VFSFileSystem$VFSURLStreamHandler.openConnection(VFSFileSystem.java:368)
> 	at java.net.URL.openConnection(URL.java:975)
> 	at java.net.URL.openStream(URL.java:1041)
> 	at org.apache.commons.configuration2.io.DefaultFileSystem.getInputStream(DefaultFileSystem.java:52)
> 	... 18 more



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message