1 Reply Latest reply on Jan 8, 2008 1:50 PM by Clebert Suconic

    ClassLoader isolation issue with ObjectMessage

    Jeff Mesnil Master

      in the trunk, ObjectMessageTest.testClassLoaderIsolation() is failing:

      junit.framework.AssertionFailedError: expected not same
       at org.jboss.test.messaging.util.ProxyAssertSupport.assertNotSame(ProxyAssertSupport.java:478)
       at org.jboss.test.messaging.jms.message.ObjectMessageTest.testClassLoaderIsolation(ObjectMessageTest.java:100)
      


      The test sends an object message with the normal classloader and receives the message with another classloader set as the current thread's class loader.
      It then checks that the two objects have different classes (since they should belong to 2 different classloaders)

      I tried to reuse JBM Stable StreamUtils to unmarshall the object with the right context class loader but it did not work:

      Index: /home/jmesnil/workspace/jboss-messaging/src/main/org/jboss/jms/message/JBossObjectMessage.java
      ===================================================================
      --- /home/jmesnil/workspace/jboss-messaging/src/main/org/jboss/jms/message/JBossObjectMessage.java (revision 3545)
      +++ /home/jmesnil/workspace/jboss-messaging/src/main/org/jboss/jms/message/JBossObjectMessage.java (working copy)
      @@ -23,8 +23,6 @@
      
       import java.io.DataInputStream;
       import java.io.DataOutputStream;
      -import java.io.ObjectInputStream;
      -import java.io.ObjectOutputStream;
       import java.io.Serializable;
      
       import javax.jms.JMSException;
      @@ -124,9 +122,7 @@
      
       protected void writePayload(DataOutputStream daos) throws Exception
       {
      - ObjectOutputStream oos = new ObjectOutputStream(daos);
      - oos.writeObject(object);
      - oos.flush();
      + StreamUtils.writeObject(daos, object, false, true);
       }
      
       protected void readPayload(DataInputStream dais) throws Exception
      @@ -131,8 +127,7 @@
      
       protected void readPayload(DataInputStream dais) throws Exception
       {
      - ObjectInputStream ois = new ObjectInputStream(dais);
      - object = (Serializable)ois.readObject();
      + object = (Serializable)StreamUtils.readObject(dais, true);
       }
      
       // Private -------------------------------------------------------