You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by zh...@apache.org on 2009/06/30 09:18:29 UTC
svn commit: r789594 - in /harmony/enhanced/classlib/trunk/modules/beans/src:
main/java/java/beans/XMLDecoder.java
test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
Author: zhoukevin
Date: Tue Jun 30 07:18:29 2009
New Revision: 789594
URL: http://svn.apache.org/viewvc?rev=789594&view=rev
Log:
Applied patch for HARMONY-6214, java.beans.XMLDecoder.XMLDecoder(InputStream inputStream, Object owner, ExceptionListener listener) should not throw IllegalArgumentException.
Modified:
harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java
harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java?rev=789594&r1=789593&r2=789594&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java Tue Jun 30 07:18:29 2009
@@ -570,9 +570,6 @@
public XMLDecoder(InputStream inputStream, Object owner,
ExceptionListener listener, ClassLoader cl) {
- if (inputStream == null) {
- throw new IllegalArgumentException("Input stream cannot be null"); //$NON-NLS-1$
- }
this.inputStream = inputStream;
this.owner = owner;
this.listener = (listener == null) ? new DefaultExceptionListener()
@@ -584,6 +581,9 @@
* Close the input stream of xml data.
*/
public void close() {
+ if (inputStream == null) {
+ return;
+ }
try {
inputStream.close();
} catch (Exception e) {
@@ -618,6 +618,9 @@
*/
@SuppressWarnings("nls")
public Object readObject() {
+ if (inputStream == null) {
+ return null;
+ }
if (saxHandler == null) {
saxHandler = new SAXHandler();
try {
Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java?rev=789594&r1=789593&r2=789594&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java Tue Jun 30 07:18:29 2009
@@ -78,33 +78,45 @@
/*
* test XMLDecoder constructor with null inputStream argument
*/
- public void test_Constructor_NullInputStream() {
- XMLDecoder xmlDecoder;
- try {
- xmlDecoder = new XMLDecoder(null);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- // Expected
- }
-
- try{
- xmlDecoder = new XMLDecoder(null, null);
- }catch(IllegalArgumentException iae){
- // Expected
- }
-
- try{
- xmlDecoder = new XMLDecoder(null, null, null);
- }catch(IllegalArgumentException iae){
- // Expected
- }
-
- try{
- xmlDecoder = new XMLDecoder(null, null, null, null);
- }catch(IllegalArgumentException iae){
- // Expected
- }
-
+ public void test_Constructor_NullInputStream_scenario1() {
+ XMLDecoder xmlDecoder = new XMLDecoder(null);
+ assertNull(xmlDecoder.readObject());
+ assertNull(xmlDecoder.getOwner());
+ assertNotNull(xmlDecoder.getExceptionListener());
+ xmlDecoder.close();
+ }
+
+ /*
+ * test XMLDecoder constructor with null inputStream argument
+ */
+ public void test_Constructor_NullInputStream_scenario2() {
+ XMLDecoder xmlDecoder = new XMLDecoder(null, null);
+ assertNull(xmlDecoder.readObject());
+ assertNull(xmlDecoder.getOwner());
+ assertNotNull(xmlDecoder.getExceptionListener());
+ xmlDecoder.close();
+ }
+
+ /*
+ * test XMLDecoder constructor with null inputStream argument
+ */
+ public void test_Constructor_NullInputStream_scenario3() {
+ XMLDecoder xmlDecoder = new XMLDecoder(null, null, null);
+ assertNull(xmlDecoder.readObject());
+ assertNull(xmlDecoder.getOwner());
+ assertNotNull(xmlDecoder.getExceptionListener());
+ xmlDecoder.close();
+ }
+
+ /*
+ * test XMLDecoder constructor with null inputStream argument
+ */
+ public void test_Constructor_NullInputStream_scenario4() {
+ XMLDecoder xmlDecoder = new XMLDecoder(null, null, null, null);
+ assertNull(xmlDecoder.readObject());
+ assertNull(xmlDecoder.getOwner());
+ assertNotNull(xmlDecoder.getExceptionListener());
+ xmlDecoder.close();
}
/*