MINA
  1. MINA
  2. DIRMINA-627

ByteBuffer.getObject() doesn't support Class objects for non-serializable classes

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.7
    • Fix Version/s: 2.0.3
    • Component/s: Core
    • Labels:
      None

      Description

      Instances of java.lang.Class are serializable, whether or not the class they represent is serializable. However, org.apache.mina.common.ByteBuffer's optimizations prevent it from unserializing Class instances representing classes that are not serializable. For example, given

      public interface NotSerializable {}
      /.../
      ObjectOutputStream o = /.../;
      o.writeObject (NotSerializable.class);
      /.../
      ObjectInputStream i = /..bytes written by o, above../;
      Object read = i.readObject();

      The 'read' object will be NotSerializable.class.

      Trying the same thing with buffer.putObject (NotSerializable.class); buffer.flip(); buffer.getObject() throws a NullPointerException.

      1. tests.patch
        3 kB
        Owen Jacobson
      2. IoBufferTest.java
        3 kB
        wangzhenghang
      3. fix.patch
        3 kB
        Owen Jacobson
      4. AbstractIoBuffer.java
        1 kB
        wangzhenghang

        Activity

        Owen Jacobson created issue -
        Owen Jacobson made changes -
        Field Original Value New Value
        Attachment tests.patch [ 12391393 ]
        Owen Jacobson made changes -
        Attachment fix.patch [ 12391394 ]
        Emmanuel Lecharny made changes -
        Fix Version/s 3.0.0-M1 [ 12313531 ]
        wangzhenghang made changes -
        Attachment AbstractIoBuffer.java [ 12405522 ]
        Attachment IoBufferTest.java [ 12405523 ]
        wangzhenghang made changes -
        Attachment AbstractIoBuffer.java [ 12405522 ]
        wangzhenghang made changes -
        Attachment IoBufferTest.java [ 12405523 ]
        wangzhenghang made changes -
        Comment [ This bug can be easly to fixed. Serializable object can be divide into three types:

        a)Class instances representing classes that are not serializable

        b)Primitive objects

        c)Other serializable objects.

          

        The first tow types's ClassDescriptor should be written, the third one just write its class name. The attachments are AbstractIoBuffer.java fixed by me and a testCase. The attachments are about mina-2.0.0-M5, it's the same way to fixed this bug in mina-1.1.7.
        ]
        wangzhenghang made changes -
        Attachment AbstractIoBuffer.java [ 12405525 ]
        Attachment IoBufferTest.java [ 12405526 ]
        wangzhenghang made changes -
        Attachment AbstractIoBuffer.java [ 12405525 ]
        wangzhenghang made changes -
        Comment [ This bug can be easly to fixed. Serializable object can be divide into three types:

        a)Class instances representing classes that are not serializable

        b)Primitive objects

        c)Other serializable objects.

          

        The first tow types's ClassDescriptor should be written, the third one just write its class name. The attachments are AbstractIoBuffer.java fixed by me and a testCase. The attachments are about mina-2.0.0-M5, it's the same way to fixed this bug in mina-1.1.7.
        [ Show ? ]
        wangzhenghang added a comment - 15/Apr/09 06:14 AM - edited This bug can be easly to fixed. Serializable object can be divide into three types: a)Class instances representing classes that are not serializable b)Primitive objects c)Other serializable objects. The first tow types's ClassDescriptor should be written, the third one just write its class name. The attachments are AbstractIoBuffer.java fixed by me and a testCase. The attachments are about mina-2.0.0-M5, it's the same way to fixed this bug in mina-1.1.7.
        ]
        wangzhenghang made changes -
        Attachment IoBufferTest.java [ 12405526 ]
        wangzhenghang made changes -
        Attachment AbstractIoBuffer.java [ 12405527 ]
        Attachment IoBufferTest.java [ 12405528 ]
        wangzhenghang made changes -
        Attachment AbstractIoBuffer.java [ 12405527 ]
        wangzhenghang made changes -
        Attachment IoBufferTest.java [ 12405528 ]
        wangzhenghang made changes -
        Attachment AbstractIoBuffer.java [ 12405531 ]
        Attachment IoBufferTest.java [ 12405532 ]
        wangzhenghang made changes -
        Comment [ This bug can be easly to fixed. Serializable object can be divide into three types:

        a)Class instances representing classes that are not serializable

        b)Primitive objects

        c)Other serializable objects.

          

        The first tow types's ClassDescriptor should be written, the third one just write its class name. The attachments are AbstractIoBuffer.java fixed by me and a testCase. The attachments are about mina-2.0.0-M5, it's the same way to fixed this bug in mina-1.1.7.
        [ Show ? ]
        wangzhenghang added a comment - 15/Apr/09 06:14 AM - edited This bug can be easly to fixed. Serializable object can be divide into three types: a)Class instances representing classes that are not serializable b)Primitive objects c)Other serializable objects. The first tow types's ClassDescriptor should be written, the third one just write its class name. The attachments are AbstractIoBuffer.java fixed by me and a testCase. The attachments are about mina-2.0.0-M5, it's the same way to fixed this bug in mina-1.1.7.
        ]
        Emmanuel Lecharny made changes -
        Fix Version/s 2.0.3 [ 12315510 ]
        Emmanuel Lecharny made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Julien Vermillard made changes -
        Fix Version/s 3.0.0-M1 [ 12313531 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Owen Jacobson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development