"Geir Magnusson Jr." <[EMAIL PROTECTED]> writes:

> Yes.  I hope to get 0.1 of collections pushed out real soon now.  Like
> get working on it tomorrow.  I just wanted to give people time to
> comment..

Speaking of which...

The getString() methods of the Configuration class that was originally
part of the Velocity project--where I am a committer--tends to blow up
with a ClassCastException when the properties file it was loaded from
is misconfigured (i.e. when getString() is called with a key whose
value is a list).  This is a problem because ClassCastException is one
of those exceptions that can happen almost anywhere, and thus aren't
often caught and dealt with at the level they should be (which IMO
would be by the immediate caller of getString()).  We've discussed
this a bit on the Velocity list, and other definitely consider it to
be an issue as well.  The two solutions that seem the most acceptable
include either returning only the first element (Servlet API and C
style), or changing the method decl so that it throws an
exception--preferably one other than ClassCastException--which
indicates a misconfiguration and/or misuse.  I've outlined the first
suggestion below as a patch to the Velocity code base.  Anyhow, I
really just want to get some additional input.

Thanks,
Daniel Rall


Index: Configuration.java 
=================================================================== 
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/confi\guration/Configuration.java,v

retrieving revision 1.29 
diff -u -u -r1.29 Configuration.java 
--- Configuration.java  2001/05/01 18:55:33     1.29 
+++ Configuration.java  2001/05/02 00:08:49 
@@ -963,6 +963,10 @@ 
                 return defaultValue; 
             } 
         } 
+        else if (value instanceof Vector) 
+        { 
+            return (String) ((Vector) value).get(0); 
+        } 
         else 
         { 
             throw new ClassCastException( 

Reply via email to