This forum has been archived. Please start a new discussion on GitHub.

Deeply nested optional sequences lead to serialization error.

Hello, I have run across a bug using optional values in Ice 3.5.1 (java).

Given a slice definition like this:
module Demo {
    class Inner0 {
        int value;

    sequence<Inner0> Inner0Seq;

    class Inner1 {
        optional(0) Inner0Seq value;

    sequence<Inner1> Inner1Seq;

    class Outer {
        optional(0) Inner1Seq value;

Outer#__writeImpl will contain this code fragment:
Inner1SeqHelper.write(__os, value);

Inner1#__writeImpl will contain this code fragment:
Inner0SeqHelper.write(__os, value);

During serialization, the inner calls of startSize/endSize will reset BasicStream._sizePos to -1.
When execution reaches the outer endSize, an exception occurs like the following:
        at java.nio.Buffer.checkIndex(
        at java.nio.HeapByteBuffer.putInt(
        at IceInternal.BasicStream.rewriteInt(
        at IceInternal.BasicStream.endSize(

I hope you find this information useful.


  • benoit
    benoit Rennes, France

    Thanks for the bug report, we will look into fixing this! This problem doesn't affect the C++ implementation but it's an issue for other language mappings.