commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r417175 - in /jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly: tags/ant/AntTag.java task/AntJellyContext.java
Date Mon, 26 Jun 2006 11:48:58 GMT
Author: polx
Date: Mon Jun 26 04:48:58 2006
New Revision: 417175

URL: http://svn.apache.org/viewvc?rev=417175&view=rev
Log:
Fixing JELLY-232 with a method to safely invoke toString.
Also fixing the data-type coercion assumption as reported (and patched)
by Hang Sun in JELLY-228.
paul

Modified:
    jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.java
    jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/task/AntJellyContext.java

Modified: jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.java?rev=417175&r1=417174&r2=417175&view=diff
==============================================================================
--- jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.java
(original)
+++ jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.java
Mon Jun 26 04:48:58 2006
@@ -245,7 +245,7 @@
                     try {
                         if (log.isDebugEnabled()) {
                             log.debug("About to set the: " + tagName
-                                + " property on: " + parentObject + " to value: "
+                                + " property on: " + safeToString(parentObject) + " to value:
"
                                 + nested + " with type: " + nested.getClass()
                             );
                         }
@@ -263,7 +263,7 @@
                         BeanUtils.setProperty( parentObject, tagName, nested );
                     }
                     catch (Exception e) {
-                        log.debug("Caught exception trying to set property: " + tagName +
" on: " + parentObject);
+                        log.debug("Caught exception trying to set property: " + tagName +
" on: " + safeToString(parentObject));
                     }
                 }
             }
@@ -351,7 +351,7 @@
 
     public void setBeanProperty(Object object, String name, Object value) throws JellyTagException
{
         if ( log.isDebugEnabled() ) {
-            log.debug( "Setting bean property on: "+  object + " name: " + name + " value:
" + value );
+            log.debug( "Setting bean property on: "+  safeToString(object )+ " name: " +
name + " value: " + safeToString(value));
         }
 
         IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() );
@@ -394,7 +394,7 @@
         if ( object != null ) {
             IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() );
 
-            if ( ih != null ) {
+            if ( ih != null && ! (object instanceof AntTag)) {
                 try {
                     dataType = ih.createElement( getAntProject(), object, name.toLowerCase()
);
                 } catch (BuildException be) {
@@ -450,7 +450,7 @@
             else {
                 dataType = createDataType(ctor, new Object[] { getAntProject() }, name, "an
Ant project");
             }
-            if (dataType != null) {
+            if (dataType != null && dataType instanceof DataType) {
                 ((DataType)dataType).setProject( getAntProject() );
             }
         }
@@ -557,6 +557,17 @@
             tag = tag.getParent();
         }
         return null;
+    }
+
+    private String safeToString(Object o) {
+        if(o==null) return "null";
+        String r = null;
+        try {
+            r = o.toString();
+        } catch(Exception ex) {}
+        if(r == null)
+            r = "(object of class " + o.getClass() + ")";
+        return r;
     }
 
 }

Modified: jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/task/AntJellyContext.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/task/AntJellyContext.java?rev=417175&r1=417174&r2=417175&view=diff
==============================================================================
--- jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/task/AntJellyContext.java
(original)
+++ jakarta/commons/proper/jelly/trunk/jelly-tags/ant/src/java/org/apache/commons/jelly/task/AntJellyContext.java
Mon Jun 26 04:48:58 2006
@@ -53,7 +53,10 @@
         }
 
         if ( log.isDebugEnabled() ) {
-            log.debug( "Looking up variable: " + name + " answer: " + answer );
+            String answerString = null;
+            try { answerString = answer.toString(); } catch(Exception ex) {}
+            if(answerString==null && answer!=null) answerString = " of class " +
answer.getClass();
+            log.debug( "Looking up variable: " + name + " answer: " + answerString );
         }
 
         return answer;



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message