4 Replies Latest reply: Nov 29, 2012 12:54 PM by 723376 RSS

    POF Serialization Issue (HashMap)

    AntonZ
      Hi.

      It looks like the following use, produced EOFException error in java serialization.

      I couldn't find any clear documentation regarding whether readMap (java) should be paired to readDictionary (.net) for pof, but currently by using a type pair of Dictionary<String, Double> in .NET side and HashMap<String, Double> in java we started getting the error below.

      Is it a wrong use? Should Hashtable be used instead? Or some other collection? Please advise.

      Error: An exception occurred while decoding a Message for Service=Proxy:ExtendTcpProxyService:TcpAcceptor received from: TcpConnection(Id={CUT}, Open=true, Member(Id=0, Timestamp=3981-11-15 06:40:05.166, Address=10.111.12.147:0, MachineId=0, Location={CUT}, Role=.NET RTC client), {CUT}): java.io.EOFException

           at com.tangosol.io.nio.ByteBufferReadBuffer$ByteBufferInput.readByte(ByteBufferReadBuffer.java:340)
           at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readUnsignedByte(AbstractReadBuffer.java:435)
           at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readPackedInt(AbstractReadBuffer.java:560)
           at com.tangosol.io.MultiBufferReadBuffer$MultiBufferInput.readPackedInt(MultiBufferReadBuffer.java:683)
           at com.tangosol.io.pof.PofBufferReader.readAsUniformObject(PofBufferReader.java:3344)
           at com.tangosol.io.pof.PofBufferReader.readMap(PofBufferReader.java:2537)

      Java Pof where it occurs:

      writer.writeMap(40, getMyDict());
      setMyDict((HashMap<String, Double>)reader.readMap(40, new HashMap<String, Double>()));

           public HashMap<String, Double> getMyDict() {
                return myDict;
           }

           public void setMyDict(HashMap<String, Double> MyDict) {
                this.myDict = MyDict;
           }

      .NET Pof:

      writer.WriteDictionary<String, Double>(40, MyDict);
      MyDict = ((Dictionary<String, Double>)reader.ReadDictionary<String, Double>(40, new Dictionary<String, Double>()));

      public Dictionary<String, Double> MyDict
      {
      get { return myDict; }
      set { myDict = value; }
      }

      Notes: If it helps, 40 is the last pof index on that object. The error appears sometime, not constantly based on data.
        • 1. Re: POF Serialization Issue (HashMap)
          robvarga
          AntonZ wrote:
          Hi.

          It looks like the following use, produced EOFException error in java serialization.

          I couldn't find any clear documentation regarding whether readMap (java) should be paired to readDictionary (.net) for pof, but currently by using a type pair of Dictionary<String, Double> in .NET side and HashMap<String, Double> in java we started getting the error below.

          Is it a wrong use? Should Hashtable be used instead? Or some other collection? Please advise.

          Error: An exception occurred while decoding a Message for Service=Proxy:ExtendTcpProxyService:TcpAcceptor received from: TcpConnection(Id={CUT}, Open=true, Member(Id=0, Timestamp=3981-11-15 06:40:05.166, Address=10.111.12.147:0, MachineId=0, Location={CUT}, Role=.NET RTC client), {CUT}): java.io.EOFException

               at com.tangosol.io.nio.ByteBufferReadBuffer$ByteBufferInput.readByte(ByteBufferReadBuffer.java:340)
               at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readUnsignedByte(AbstractReadBuffer.java:435)
               at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readPackedInt(AbstractReadBuffer.java:560)
               at com.tangosol.io.MultiBufferReadBuffer$MultiBufferInput.readPackedInt(MultiBufferReadBuffer.java:683)
               at com.tangosol.io.pof.PofBufferReader.readAsUniformObject(PofBufferReader.java:3344)
               at com.tangosol.io.pof.PofBufferReader.readMap(PofBufferReader.java:2537)

          Java Pof where it occurs:

          writer.writeMap(40, getMyDict());
          setMyDict((HashMap<String, Double>)reader.readMap(40, new HashMap<String, Double>()));

               public HashMap<String, Double> getMyDict() {
                    return myDict;
               }

               public void setMyDict(HashMap<String, Double> MyDict) {
                    this.myDict = MyDict;
               }

          .NET Pof:

          writer.WriteDictionary<String, Double>(40, MyDict);
          MyDict = ((Dictionary<String, Double>)reader.ReadDictionary<String, Double>(40, new Dictionary<String, Double>()));

          public Dictionary<String, Double> MyDict
          {
          get { return myDict; }
          set { myDict = value; }
          }

          Notes: If it helps, 40 is the last pof index on that object. The error appears sometime, not constantly based on data.
          How is the class containing the map serialized? Is it a PortableObject or do you use a PofSerializer for serializing it? If you use a PofSerializer, please verify that you did not forget the writeRemainder / readRemainder calls from the end of the serialize/deserialize methods.

          Best regards,

          Robert
          • 2. Re: POF Serialization Issue (HashMap)
            AntonZ
            It implements PortableObject (and IPortableObject on .net side).
            • 3. Re: POF Serialization Issue (HashMap)
              AntonZ
              Still awaiting for someone to confirm if this is a bug and a fix will be required, or another data structure should be used in .net or java, or any other solutions for this.

              In .Net using 3.7.1.3 Build 31874
              In Java using 3.7.1.3
              • 4. Re: POF Serialization Issue (HashMap)
                723376
                Could you please provide us a reproducer so we can look into the problem?

                Thanks,
                Luk