diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/src/main/java/Ice/InputStream.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/java/src/Ice/src/main/java/Ice/InputStream.java b/java/src/Ice/src/main/java/Ice/InputStream.java index b203520718b..8c1d23465d3 100644 --- a/java/src/Ice/src/main/java/Ice/InputStream.java +++ b/java/src/Ice/src/main/java/Ice/InputStream.java @@ -634,28 +634,34 @@ public class InputStream * * @param encoding The encapsulation's encoding version. **/ - public void skipEmptyEncapsulation(EncodingVersion encoding) + public Ice.EncodingVersion skipEmptyEncapsulation() { int sz = readInt(); - if(sz != 6) + if(sz < 6) { - throw new EncapsulationException(); + throw new Ice.EncapsulationException(); } - - final int pos = _buf.b.position(); - if(pos + 2 > _buf.size()) + if(sz - 4 > _buf.b.remaining()) { - throw new UnmarshalOutOfBoundsException(); + throw new Ice.UnmarshalOutOfBoundsException(); } - if(encoding != null) + Ice.EncodingVersion encoding = new Ice.EncodingVersion(); + encoding.ice_read(this); + if(encoding.equals(Ice.Util.Encoding_1_0)) { - encoding.ice_read(this); + if(sz != 6) + { + throw new Ice.EncapsulationException(); + } } else { - _buf.b.position(pos + 2); + // Skip the optional content of the encapsulation if we are expecting an + // empty encapsulation. + _buf.b.position(_buf.b.position() + sz - 6); } + return encoding; } /** |