commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1715221 - in /commons/proper/io/trunk/src: main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java
Date Thu, 19 Nov 2015 17:23:28 GMT
Author: bdelacretaz
Date: Thu Nov 19 17:23:28 2015
New Revision: 1715221

URL: http://svn.apache.org/viewvc?rev=1715221&view=rev
Log:
IO-487 - include class name in InvalidClassException

Modified:
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java?rev=1715221&r1=1715220&r2=1715221&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java
(original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java
Thu Nov 19 17:23:28 2015
@@ -93,7 +93,7 @@ public class ValidatingObjectInputStream
      * @throws InvalidClassException
      */
     protected void invalidClassNameFound(String className) throws InvalidClassException{
-        throw new InvalidClassException("Class name not accepted");
+        throw new InvalidClassException("Class name not accepted: " + className);
     }
 
     @Override

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java?rev=1715221&r1=1715220&r2=1715221&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java
Thu Nov 19 17:23:28 2015
@@ -18,6 +18,8 @@
  */
 package org.apache.commons.io.serialization;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.junit.Assert.assertEquals;
 
 import java.io.ByteArrayInputStream;
@@ -86,6 +88,18 @@ public class ValidatingObjectInputStream
     }
 
     @Test
+    public void exceptionIncludesClassName() throws Exception {
+        try {
+            assertSerialization(
+                    willClose(new ValidatingObjectInputStream(testStream)));
+            fail("Expected an InvalidClassException");
+        } catch(InvalidClassException ice) {
+            final String name = OurTestClass.class.getName();
+            assertTrue("Expecting message to contain " + name, ice.getMessage().contains(name));
+        }
+    }
+
+    @Test
     public void acceptCustomMatcher() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))



Mime
View raw message