You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/02/14 17:47:46 UTC

svn commit: r910036 - in /pivot/trunk: core/src/org/apache/pivot/beans/BeanDictionary.java wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java

Author: gbrown
Date: Sun Feb 14 16:47:45 2010
New Revision: 910036

URL: http://svn.apache.org/viewvc?rev=910036&view=rev
Log:
Throw PropertyNotFoundException in BeanDictionary#isReadOnly() when the given key does not represent a valid property; eliminate redundant stack trace when logging exceptions in WTKXSerializer.

Modified:
    pivot/trunk/core/src/org/apache/pivot/beans/BeanDictionary.java
    pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java

Modified: pivot/trunk/core/src/org/apache/pivot/beans/BeanDictionary.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BeanDictionary.java?rev=910036&r1=910035&r2=910036&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/beans/BeanDictionary.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/beans/BeanDictionary.java Sun Feb 14 16:47:45 2010
@@ -721,9 +721,17 @@
 
         if (key.startsWith(FIELD_PREFIX)) {
             Field field = getField(type, key.substring(1));
-            isReadOnly = (field == null
-                || (field.getModifiers() & Modifier.FINAL) != 0);
+            if (field == null) {
+                throw new PropertyNotFoundException();
+            }
+
+            isReadOnly = ((field.getModifiers() & Modifier.FINAL) != 0);
         } else {
+            Method getterMethod = getGetterMethod(type, key);
+            if (getterMethod == null) {
+                throw new PropertyNotFoundException();
+            }
+
             Method setterMethod = getSetterMethod(type, key, getType(type, key));
             isReadOnly = (setterMethod == null);
         }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java?rev=910036&r1=910035&r2=910036&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java Sun Feb 14 16:47:45 2010
@@ -451,13 +451,13 @@
                 throw new SerializationException(exception);
             }
         } catch (IOException exception) {
-            logException(exception);
+            logException();
             throw exception;
         } catch (SerializationException exception) {
-            logException(exception);
+            logException();
             throw exception;
         } catch (RuntimeException exception) {
-            logException(exception);
+            logException();
             throw exception;
         }
 
@@ -1040,7 +1040,7 @@
         }
     }
 
-    private void logException(Exception exception) {
+    private void logException() {
         String message = "An error occurred while processing ";
 
         if (element == null) {
@@ -1057,7 +1057,6 @@
         message += ":";
 
         System.err.println(message);
-        exception.printStackTrace();
     }
 
     @Override