commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [commons-configuration] Variable Syntax Conflict
Date Sat, 23 Jun 2007 15:03:59 GMT
Hi Dave,

Dave Westerman wrote:
> I am using the commons-configuration for my property files. However, 
> unfortunately, I have a need to have a value in some of my properties 
> that look exactly like the variables that commons-config uses.
> myproperty=${myNonCommonsConfigVariable}
> I've tried to escape it thus:
> myproperty=\${myNonCommonsConfigVariable}
> myproperty=\\${myNonCommonsConfigVariable}
> myproperty=$${myNonCommonsConfigVariable}
> but all to no avail.
> Is there any way for me to get around this conflict? Can I change the 
> delimiter that commons-config uses (I've looked at all the classes, 
> there doesn't seem to be a way)?
> The error I'm getting is this:
> java.lang.IllegalStateException: infinite loop in property interpolation 
> of 
> ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar,${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar,${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar:


which version of Commons Configuration do you use? Since the 1.3 release 
substituation of variables is handled by the StrSubstitutor class of 
Commons Lang [1]. Here the '$' sign is used for escaping variables, so 
your 3rd example


should work. There is also a unit test that checks this behavior:

     public void testInterpolationEscaped()
         config.addProperty("var", "x");
         config.addProperty("escVar", "Use the variable $${${var}}.");
         assertEquals("Wrong escaped variable", "Use the variable 
${x}.", config

IIRC in earlier versions of Configuration escaping variables was not 



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message