jmcnally    02/03/16 10:07:01

  Modified:    lang/src/java/org/apache/commons/lang Objects.java
               lang/src/test/org/apache/commons/lang ObjectsTest.java
  Log:
  modified so the serialize method returns null on failure instead of
  throwing an exception.  This is to match the behavior of deserialize.
  
  Revision  Changes    Path
  1.3       +9 -3      
jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Objects.java
  
  Index: Objects.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Objects.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Objects.java      11 Mar 2002 08:05:20 -0000      1.2
  +++ Objects.java      16 Mar 2002 18:07:01 -0000      1.3
  @@ -69,7 +69,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Nissim Karpenstein</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Janek Bogucki</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @version $Id: Objects.java,v 1.2 2002/03/11 08:05:20 dlr Exp $
  + * @version $Id: Objects.java,v 1.3 2002/03/16 18:07:01 jmcnally Exp $
    */
   public class Objects
   {
  @@ -132,10 +132,8 @@
        *
        * @param obj The Serializable to convert.
        * @return A byte[] with the converted Serializable.
  -     * @exception IOException, if conversion to a byte[] fails.
        */
       public static byte[] serialize(Serializable obj)
  -        throws IOException
       {
           byte[] byteArray = null;
           ByteArrayOutputStream baos = null;
  @@ -149,11 +147,19 @@
               out.writeObject(obj);
               byteArray = baos.toByteArray();
           }
  +        catch (IOException e)
  +        {
  +            byteArray = null;
  +        }
           finally
           {
  -            if (out != null) 
  +            try
               {
                   out.close();
  +            }
  +            catch (Exception e)
  +            {
  +                // ignore;
               }
           }
           return byteArray;
  
  
  
  1.2       +1 -5      
jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/ObjectsTest.java
  
  Index: ObjectsTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/ObjectsTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectsTest.java  11 Mar 2002 08:05:20 -0000      1.1
  +++ ObjectsTest.java  16 Mar 2002 18:07:01 -0000      1.2
  @@ -55,7 +55,6 @@
    */
   
   import java.util.HashMap;
  -import java.io.IOException;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -89,19 +88,16 @@
       }
           
       public void testDeserialize()
  -        throws IOException
       {
           serializeDeserialize();
       }
   
       public void testSerialize()
  -        throws IOException
       {
           serializeDeserialize();
       }
   
       private void serializeDeserialize()
  -        throws IOException
       {
           HashMap original = new HashMap();
           original.put(FOO, BAR);
  @@ -124,5 +120,5 @@
                      !Objects.equals(FOO, BAR));
           assertTrue("Objects.equals(\"foo\", \"foo\") returned false", 
                      Objects.equals(FOO, FOO));
  -    }
  +    }        
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to