[
https://issues.apache.org/jira/browse/CONFIGURATION-837?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rob Walker updated CONFIGURATION-837:
-------------------------------------
Description:
Note sure if 1.10 is actively maintained, but there's an issue with cloning
MapConfiguration objects.
When trying to convert using an interpolatedConfiguration:
{code:java}
Map expanded =
ConfigurationConverter.getProperties(launchConfig.interpolatedConfiguration());
{code}
The following exception is thrown
{code:java}
org.apache.commons.configuration.ConfigurationRuntimeException:
java.lang.reflect.InvocationTargetException at
org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:325)
at
org.apache.commons.configuration.ConfigurationUtils.cloneConfiguration(ConfigurationUtils.java:282)
at
org.apache.commons.configuration.CombinedConfiguration.clone(CombinedConfiguration.java:670)
at
org.apache.commons.configuration.HierarchicalConfiguration.interpolatedConfiguration(HierarchicalConfiguration.java:937)
at com.ascert.vt.launch.VtLauncher.launchFelix(VtLauncher.java:1220) Caused
by: java.lang.reflect.InvocationTargetException at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566) at
org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:311)
... 7 more Caused by:
org.apache.commons.configuration.ConfigurationRuntimeException:
java.lang.CloneNotSupportedException:
org.apache.commons.configuration.MapConfiguration$1 does not implement
Cloneable at
org.apache.commons.configuration.MapConfiguration.clone(MapConfiguration.java:249)
... 12 more Caused by: java.lang.CloneNotSupportedException:
org.apache.commons.configuration.MapConfiguration$1 does not implement
Cloneable at
org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:330)
at
org.apache.commons.configuration.MapConfiguration.clone(MapConfiguration.java:242)
... 12 more
{code}
The issue seems to be caused by extending AbstractMap as an anyonymous return
class. From line 253 of MapConfiguration:
{code:java}
/**
* Helper method for copying all string keys from the given
* {@code Properties} object to a newly created map.
*
* @param props the {@code Properties} to be copied
* @return a newly created map with all string keys of the properties
*/
private static Map<String, Object> convertPropertiesToMap(final Properties
props)
{
return new AbstractMap<String, Object>() {
@Override
public Set<Map.Entry<String, Object>> entrySet()
{code}
This class does not implement Cloneable as noted in the error message. Just
looking for a decent solution, but returning some inner subclass which supports
cloneable seems the way to go.
was:
Note sure if 1.10 is actively maintained, but there's an issue with cloning
MapConfiguration objects.
When trying to convert using an interpolatedConfiguration:
{code:java}
Map expanded =
ConfigurationConverter.getProperties(launchConfig.interpolatedConfiguration());
{code}
The following exception is thrown
{code:java}
org.apache.commons.configuration.ConfigurationRuntimeException:
java.lang.reflect.InvocationTargetException at
org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:325)
at
org.apache.commons.configuration.ConfigurationUtils.cloneConfiguration(ConfigurationUtils.java:282)
at
org.apache.commons.configuration.CombinedConfiguration.clone(CombinedConfiguration.java:670)
at
org.apache.commons.configuration.HierarchicalConfiguration.interpolatedConfiguration(HierarchicalConfiguration.java:937)
at com.ascert.vt.launch.VtLauncher.launchFelix(VtLauncher.java:1220) Caused
by: java.lang.reflect.InvocationTargetException at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566) at
org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:311)
... 7 more Caused by:
org.apache.commons.configuration.ConfigurationRuntimeException:
java.lang.CloneNotSupportedException:
org.apache.commons.configuration.MapConfiguration$1 does not implement
Cloneable at
org.apache.commons.configuration.MapConfiguration.clone(MapConfiguration.java:249)
... 12 more Caused by: java.lang.CloneNotSupportedException:
org.apache.commons.configuration.MapConfiguration$1 does not implement
Cloneable at
org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:330)
at
org.apache.commons.configuration.MapConfiguration.clone(MapConfiguration.java:242)
... 12 more
{code}
The issue seems to be caused by extending AbstractMap as an anyonymous return
class. From line 253 of MapConfiguration:
{code:java}
/**
* Helper method for copying all string keys from the given
* {@code Properties} object to a newly created map.
*
* @param props the {@code Properties} to be copied
* @return a newly created map with all string keys of the properties
*/
private static Map<String, Object> convertPropertiesToMap(final Properties
props)
{
return new AbstractMap<String, Object>() { @Override
public Set<Map.Entry<String, Object>> entrySet()
{code}
This class does not implement Cloneable as noted in the error message. Just
looking for a decent solution, but returning some inner subclass which supports
cloneable seems the way to go.
> MapConfiguration$1 does not implement Cloneable exception
> ---------------------------------------------------------
>
> Key: CONFIGURATION-837
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-837
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.10
> Reporter: Rob Walker
> Priority: Major
>
> Note sure if 1.10 is actively maintained, but there's an issue with cloning
> MapConfiguration objects.
> When trying to convert using an interpolatedConfiguration:
>
> {code:java}
> Map expanded =
> ConfigurationConverter.getProperties(launchConfig.interpolatedConfiguration());
>
> {code}
> The following exception is thrown
>
> {code:java}
> org.apache.commons.configuration.ConfigurationRuntimeException:
> java.lang.reflect.InvocationTargetException at
> org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:325)
> at
> org.apache.commons.configuration.ConfigurationUtils.cloneConfiguration(ConfigurationUtils.java:282)
> at
> org.apache.commons.configuration.CombinedConfiguration.clone(CombinedConfiguration.java:670)
> at
> org.apache.commons.configuration.HierarchicalConfiguration.interpolatedConfiguration(HierarchicalConfiguration.java:937)
> at com.ascert.vt.launch.VtLauncher.launchFelix(VtLauncher.java:1220) Caused
> by: java.lang.reflect.InvocationTargetException at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method) at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:566) at
> org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:311)
> ... 7 more Caused by:
> org.apache.commons.configuration.ConfigurationRuntimeException:
> java.lang.CloneNotSupportedException:
> org.apache.commons.configuration.MapConfiguration$1 does not implement
> Cloneable at
> org.apache.commons.configuration.MapConfiguration.clone(MapConfiguration.java:249)
> ... 12 more Caused by: java.lang.CloneNotSupportedException:
> org.apache.commons.configuration.MapConfiguration$1 does not implement
> Cloneable at
> org.apache.commons.configuration.ConfigurationUtils.clone(ConfigurationUtils.java:330)
> at
> org.apache.commons.configuration.MapConfiguration.clone(MapConfiguration.java:242)
> ... 12 more
>
> {code}
> The issue seems to be caused by extending AbstractMap as an anyonymous return
> class. From line 253 of MapConfiguration:
>
> {code:java}
> /**
> * Helper method for copying all string keys from the given
> * {@code Properties} object to a newly created map.
> *
> * @param props the {@code Properties} to be copied
> * @return a newly created map with all string keys of the properties
> */
> private static Map<String, Object> convertPropertiesToMap(final
> Properties props)
> {
> return new AbstractMap<String, Object>() {
> @Override
> public Set<Map.Entry<String, Object>> entrySet()
>
> {code}
> This class does not implement Cloneable as noted in the error message. Just
> looking for a decent solution, but returning some inner subclass which
> supports cloneable seems the way to go.
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)