harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r785154 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/XMLEncoder.java test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
Date Tue, 16 Jun 2009 10:46:15 GMT
Author: tellison
Date: Tue Jun 16 10:46:13 2009
New Revision: 785154

URL: http://svn.apache.org/viewvc?rev=785154&view=rev
Log:
Apply patch HARMONY-6215 ([classlib][beans] java.beans.XMLEncoder.writeExpression(Expression
null) should throw NullPointerException)

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java?rev=785154&r1=785153&r2=785154&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
Tue Jun 16 10:46:13 2009
@@ -866,6 +866,9 @@
 	 */
 	@Override
     public void writeExpression(Expression oldExp) {
+        if (null == oldExp) {
+            throw new NullPointerException();
+        }
 	    boolean oldWritingObject = writingObject;
 	    writingObject = true;
 		// get expression value

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java?rev=785154&r1=785153&r2=785154&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
Tue Jun 16 10:46:13 2009
@@ -30,6 +30,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.StringReader;
 import java.util.Map;
@@ -200,8 +201,24 @@
         return str;
     }
 
-    public void testWriteExpression() {
-        // covered by testWriteObject
+    public void testWriteExpression_Scenario1() {
+        XMLEncoder xmlEncoder = new XMLEncoder((OutputStream) null);
+        try {
+            xmlEncoder.writeExpression((Expression) null);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void testWriteExpression_Scenario2() {
+        XMLEncoder xmlEncoder = new XMLEncoder(new ByteArrayOutputStream());
+        try {
+            xmlEncoder.writeExpression((Expression) null);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
     }
 
     public void testWriteStatement() {



Mime
View raw message