-
Bug
-
Resolution: Fixed
-
P5
-
8, 11, 12, 13
-
b02
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Windows
A DESCRIPTION OF THE PROBLEM :
Currently when you use https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousServerSocketChannel.html or https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousSocketChannel.html or any class involved with https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/classes/sun/nio/ch/Iocp.java the exception are weird they always end with ".\r\n" which is meant to be for Windows - https://en.wikipedia.org/wiki/Newline#Representation this is because https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/classes/sun/nio/ch/Iocp.java is using it's own https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/classes/sun/nio/ch/Iocp.java#L443 error message system instead of the built in which is located in http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/os/windows/vm/os_windows.cpp#l1862 which removes ".\r\n" whereas Iocp invokes which never removes the ".\r\n" http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/windows/native/sun/nio/ch/Iocp.c#l140
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an exception within https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousServerSocketChannel.html or https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousSocketChannel.html
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
BYTES [84, 104, 101, 32, 115, 112, 101, 99, 105, 102, 105, 101, 100, 32, 110, 101, 116, 119, 111, 114, 107, 32, 110, 97, 109, 101, 32, 105, 115, 32, 110, 111, 32, 108, 111, 110, 103, 101, 114, 32, 97, 118, 97, 105, 108, 97, 98, 108, 101]
java.io.IOException: The specified network name is no longer available
at sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:309)
at sun.nio.ch.Iocp.access$700(Iocp.java:46)
at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:399)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
ACTUAL -
BYTES [84, 104, 101, 32, 115, 112, 101, 99, 105, 102, 105, 101, 100, 32, 110, 101, 116, 119, 111, 114, 107, 32, 110, 97, 109, 101, 32, 105, 115, 32, 110, 111, 32, 108, 111, 110, 103, 101, 114, 32, 97, 118, 97, 105, 108, 97, 98, 108, 101, 46, 13, 10]
java.io.IOException: The specified network name is no longer available.
at sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:309)
at sun.nio.ch.Iocp.access$700(Iocp.java:46)
at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:399)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
---------- BEGIN SOURCE ----------
Server:
AsynchronousServerSocketChannel server = AsynchronousServerSocketChannel.open();
server.bind(new InetSocketAddress("127.0.0.1", 6000));
server.accept(null, new CompletionHandler<AsynchronousSocketChannel, Void>()
{
public void completed(AsynchronousSocketChannel result, Void attachment)
{
System.out.println("ACCEPT");
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(256);
result.read(byteBuffer, result, new CompletionHandler<Integer, AsynchronousSocketChannel>()
{
public void completed(Integer result, AsynchronousSocketChannel client)
{
System.out.println("READ " + result);
byteBuffer.clear();
client.read(byteBuffer, client, this);
}
public void failed(Throwable exc, AsynchronousSocketChannel attachment)
{
System.out.println("BYTES " + Arrays.toString(exc.getMessage().getBytes()));
exc.printStackTrace();
try
{
attachment.close();
} catch(IOException e)
{
e.printStackTrace();
}
}
});
}
public void failed(Throwable exc, Void attachment)
{
exc.printStackTrace();
}
});
while(true)
;
Client:
AsynchronousSocketChannel client = AsynchronousSocketChannel.open();
client.connect(new InetSocketAddress("127.0.0.1", 6000));
This will produce an exception on the server-side since the client will be closed without a proper https://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html#close() invocation
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Well you could do
String message = exc.getMessage();
exc = new Throwable(message == null ? null : message.substring(0, /*3 for '.', '\r' and '\n'*/message.length() - 3));
where "exc" is equal to the current https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html
FREQUENCY : always
Windows
A DESCRIPTION OF THE PROBLEM :
Currently when you use https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousServerSocketChannel.html or https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousSocketChannel.html or any class involved with https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/classes/sun/nio/ch/Iocp.java the exception are weird they always end with ".\r\n" which is meant to be for Windows - https://en.wikipedia.org/wiki/Newline#Representation this is because https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/classes/sun/nio/ch/Iocp.java is using it's own https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/classes/sun/nio/ch/Iocp.java#L443 error message system instead of the built in which is located in http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/os/windows/vm/os_windows.cpp#l1862 which removes ".\r\n" whereas Iocp invokes which never removes the ".\r\n" http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/windows/native/sun/nio/ch/Iocp.c#l140
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an exception within https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousServerSocketChannel.html or https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousSocketChannel.html
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
BYTES [84, 104, 101, 32, 115, 112, 101, 99, 105, 102, 105, 101, 100, 32, 110, 101, 116, 119, 111, 114, 107, 32, 110, 97, 109, 101, 32, 105, 115, 32, 110, 111, 32, 108, 111, 110, 103, 101, 114, 32, 97, 118, 97, 105, 108, 97, 98, 108, 101]
java.io.IOException: The specified network name is no longer available
at sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:309)
at sun.nio.ch.Iocp.access$700(Iocp.java:46)
at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:399)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
ACTUAL -
BYTES [84, 104, 101, 32, 115, 112, 101, 99, 105, 102, 105, 101, 100, 32, 110, 101, 116, 119, 111, 114, 107, 32, 110, 97, 109, 101, 32, 105, 115, 32, 110, 111, 32, 108, 111, 110, 103, 101, 114, 32, 97, 118, 97, 105, 108, 97, 98, 108, 101, 46, 13, 10]
java.io.IOException: The specified network name is no longer available.
at sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:309)
at sun.nio.ch.Iocp.access$700(Iocp.java:46)
at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:399)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
---------- BEGIN SOURCE ----------
Server:
AsynchronousServerSocketChannel server = AsynchronousServerSocketChannel.open();
server.bind(new InetSocketAddress("127.0.0.1", 6000));
server.accept(null, new CompletionHandler<AsynchronousSocketChannel, Void>()
{
public void completed(AsynchronousSocketChannel result, Void attachment)
{
System.out.println("ACCEPT");
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(256);
result.read(byteBuffer, result, new CompletionHandler<Integer, AsynchronousSocketChannel>()
{
public void completed(Integer result, AsynchronousSocketChannel client)
{
System.out.println("READ " + result);
byteBuffer.clear();
client.read(byteBuffer, client, this);
}
public void failed(Throwable exc, AsynchronousSocketChannel attachment)
{
System.out.println("BYTES " + Arrays.toString(exc.getMessage().getBytes()));
exc.printStackTrace();
try
{
attachment.close();
} catch(IOException e)
{
e.printStackTrace();
}
}
});
}
public void failed(Throwable exc, Void attachment)
{
exc.printStackTrace();
}
});
while(true)
;
Client:
AsynchronousSocketChannel client = AsynchronousSocketChannel.open();
client.connect(new InetSocketAddress("127.0.0.1", 6000));
This will produce an exception on the server-side since the client will be closed without a proper https://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html#close() invocation
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Well you could do
String message = exc.getMessage();
exc = new Throwable(message == null ? null : message.substring(0, /*3 for '.', '\r' and '\n'*/message.length() - 3));
where "exc" is equal to the current https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html
FREQUENCY : always
- links to