-
Bug
-
Resolution: Duplicate
-
P4
-
8, 9
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8171857 | 9 | Brian Burkhalter | P4 | Closed | Fixed | b151 |
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
When using SocketChannel.read() after a timeout has been set on the socket, it will fail if the system date/time is changed during the call to read().
This is visible here:
http://hg.openjdk.java.net/jdk8/jdk8/jdk/annotate/687fd7c7986d/src/share/classes/sun/nio/ch/SocketAdaptor.java#l203
The function uses System.currentTimeMillis() whith is not monothonic. So changing the system date during a call to read() may make this function loop over and over and thus nos respecting the timeout.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Create a SocketChannel
- Set a timeout on the socket, like 1000ms
- Call read() in a loop and display some text between calls
- Change date (like 1 year in the past)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The timeout stay 1000ms and the code continue executing normally
ACTUAL -
The next read() will never return (I mean, the timeout is buggy and depends on the date you pick)
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
When using SocketChannel.read() after a timeout has been set on the socket, it will fail if the system date/time is changed during the call to read().
This is visible here:
http://hg.openjdk.java.net/jdk8/jdk8/jdk/annotate/687fd7c7986d/src/share/classes/sun/nio/ch/SocketAdaptor.java#l203
The function uses System.currentTimeMillis() whith is not monothonic. So changing the system date during a call to read() may make this function loop over and over and thus nos respecting the timeout.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Create a SocketChannel
- Set a timeout on the socket, like 1000ms
- Call read() in a loop and display some text between calls
- Change date (like 1 year in the past)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The timeout stay 1000ms and the code continue executing normally
ACTUAL -
The next read() will never return (I mean, the timeout is buggy and depends on the date you pick)
REPRODUCIBILITY :
This bug can be reproduced always.
- backported by
-
JDK-8171857 (ch) sun.nio.ch.SocketAdaptor does not respect timeout in case of system date/time change and blocks
-
- Closed
-
- duplicates
-
JDK-8171857 (ch) sun.nio.ch.SocketAdaptor does not respect timeout in case of system date/time change and blocks
-
- Closed
-