You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Thomas Fahrmeyer <th...@einsurance.de> on 2001/05/04 19:21:51 UTC

Bug in subset()

Hi,

there is a bug in Configuration.subset() in combination with comma delimited
strings.

Define:
test.prop1 = Hey\, thats a bug

call conf.getString("test.prop1") will return "Hey, thats a bug" -> thats
fine.

but:

Configuration newConf = conf.subset("test")
String str = newConf.getString("prop1")

will throw a ClassCastException, because a Vector is now stored under key
"prop1".

The problem is, that reading the property at startup removes the "\", so the
value has no escaped "," inside anymore.
In subset() the unescaped String is read and added to the Configuration with
addProperty(). There the PropertyTokenizer is
used which splits the String because there are no escaped "," *bang*

Any solutions ?

subset() should call another Method that avoids using PropertyTokenizer ...

bye
Thomas



Re: Bug in subset()

Posted by Jason van Zyl <jv...@apache.org>.
Thomas Fahrmeyer wrote:
> 
> Hi,
> 
> there is a bug in Configuration.subset() in combination with comma delimited
> strings.
> 
> Define:
> test.prop1 = Hey\, thats a bug
> 
> call conf.getString("test.prop1") will return "Hey, thats a bug" -> thats
> fine.
> 
> but:
> 
> Configuration newConf = conf.subset("test")
> String str = newConf.getString("prop1")
> 
> will throw a ClassCastException, because a Vector is now stored under key
> "prop1".
> 
> The problem is, that reading the property at startup removes the "\", so the
> value has no escaped "," inside anymore.
> In subset() the unescaped String is read and added to the Configuration with
> addProperty(). There the PropertyTokenizer is
> used which splits the String because there are no escaped "," *bang*
> 
> Any solutions ?
> 
> subset() should call another Method that avoids using PropertyTokenizer ...

This class has now moved over to the commons, so you'll probably want
to post to the list there. The class is now called ExtendedProperties.

-- 
jvz.

Jason van Zyl
jvanzyl@apache.org

http://jakarta.apache.org/velocity
http://jakarta.apache.org/turbine
http://jakarta.apache.org/commons
http://tambora.zenplex.org