diff options
author | Matthew Newhook <matthew@zeroc.com> | 2008-04-07 17:25:53 +0800 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2008-04-07 17:25:53 +0800 |
commit | cf38d16fdb87af3a26624233deeb9678730c69f9 (patch) | |
tree | 1bc2f4fbd8747850e40ec77eacd46b33c05c7160 /java/src/IceInternal/Buffer.java | |
parent | minor fixes for C# multicast demo config files (diff) | |
download | ice-cf38d16fdb87af3a26624233deeb9678730c69f9.tar.bz2 ice-cf38d16fdb87af3a26624233deeb9678730c69f9.tar.xz ice-cf38d16fdb87af3a26624233deeb9678730c69f9.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2985 - Fix bug with C# & Java input & output streams
Diffstat (limited to 'java/src/IceInternal/Buffer.java')
-rw-r--r-- | java/src/IceInternal/Buffer.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/java/src/IceInternal/Buffer.java b/java/src/IceInternal/Buffer.java index 2d836853a66..c45b6d96f80 100644 --- a/java/src/IceInternal/Buffer.java +++ b/java/src/IceInternal/Buffer.java @@ -18,7 +18,7 @@ public class Buffer public Buffer(int maxCapacity) { - b = null; + b = _emptyBuffer; _size = 0; _capacity = 0; _maxCapacity = maxCapacity; @@ -39,7 +39,7 @@ public class Buffer public void clear() { - b = null; + b = _emptyBuffer; _size = 0; _capacity = 0; } @@ -53,7 +53,7 @@ public class Buffer public void expand(int n) { - final int sz = b == null ? n : b.position() + n; + final int sz = (b == _emptyBuffer) ? n : b.position() + n; if(sz > _size) { resize(sz, false); @@ -104,7 +104,7 @@ public class Buffer _shrinkCounter = 0; } _size = 0; - if(b != null) + if(b != _emptyBuffer) { b.limit(b.capacity()); b.position(0); @@ -141,7 +141,7 @@ public class Buffer buf = java.nio.ByteBuffer.allocate(_capacity); } - if(b == null) + if(b == _emptyBuffer) { b = buf; } @@ -168,6 +168,8 @@ public class Buffer } public java.nio.ByteBuffer b; + // Sentinel used for null buffer. + public java.nio.ByteBuffer _emptyBuffer = java.nio.ByteBuffer.allocate(0); private int _size; private int _capacity; // Cache capacity to avoid excessive method calls. |