Bug#281602: libgcj5: SocketChannel.get(ByteBuffer) returns 0 at EOF.
Package: libgcj5
Version: 3.4.2-3
Severity: normal
When a SocketChannel reaches EOF, the get method doesn't return -1 as it
should.
Example program:
------------------------------------------------------------------------
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.Iterator;
public class Server {
public static void main(String[] args) {
try {
Selector serverSelector;
serverSelector = Selector.open();
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.configureBlocking(true);
ssc.socket().bind(new InetSocketAddress(2003));
SocketChannel sc = ssc.accept();
sc.configureBlocking(true);
while(true) {
ByteBuffer bb = ByteBuffer.allocate(100);
int i = sc.read(bb);
System.out.println("Read : " + i + " bytes.");
for(int j = 0; j < i; j++) {
System.out.print((char)bb.get(j));
}
if(i < 0) {
System.out.println("Closing : " + i);
sc.close();
return;
}
}
} catch(Exception ex) {
}
}
}
------------------------------------------------------------------------
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.4.26-1-k7
Locale: LANG=sv_SE, LC_CTYPE=sv_SE (charmap=ISO-8859-1)
Versions of packages libgcj5 depends on:
ii libc6 2.3.2.ds1-18 GNU C Library: Shared libraries an
ii libgcc1 1:3.4.2-3 GCC support library
ii libgcj-common 1:3.3.5-2 Java runtime library (common files
ii zlib1g 1:1.2.2-3 compression library - runtime
-- no debconf information
Reply to: