You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Mitch Christensen <mi...@informatixinc.com> on 2002/11/26 22:33:07 UTC

Nasty Turbine 'feature' ;)

Hey,

I just came across a 'feature' of Turbine (actually, the jakarta commons
library) that might be of interest to others.

At the end of the TurbineResources.properties file, you will see an include
of flux.properties.  There is a comment just above this that states
"...Duplicate name values will be replaced, so be careful."  I interpreted
this to mean that values set in the *included* file will override the values
in TRP.  I just discovered that neither this, nor the opposite is true.
What happens is if you define the same key more than once, the value of that
key becomes an array of strings as if you had entered them on the same line,
with commas.  This is *as documented*.  However, this may not be intuitive.

As a result of this, you may see strange exceptions.  If you define a value
more than once, then try to use TurbineResources.getInt("key.name") ; you
get a ClassCastException.  This is because you are trying to cast an array
of Strings into an Integer.

I apologize for consuming bandwidth if everyone else knew this, and I was
the last to figure it out. :)

Does anyone have a trick for getting the latest defined value without having
to get the array, and then get the last element as a string, and then
convert the string to your desired type (i.e. int)?  It would be nice to
have a 'resources.override.previous.values = true' that you could put
directly into TRP to control this behavior.

...probably a subject for a different group though.

-Mitch