--- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Wed Feb 13 08:29:35 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Wed Feb 13 14:43:25 2019 +0000
@@ -434,18 +434,25 @@
&& localport != 0 && address != null && port != 0;
// copy fields
+ nsi.stream = this.stream;
nsi.fd = this.fd;
- nsi.stream = this.stream;
- nsi.closer = FileDescriptorCloser.create(nsi);
nsi.localport = this.localport;
nsi.address = this.address;
nsi.port = this.port;
+
+ // reset fields; do not reset timeout
+ nsi.nonBlocking = false;
+ nsi.isInputClosed = false;
+ nsi.isOutputClosed = false;
+ nsi.isReuseAddress = false;
nsi.state = ST_CONNECTED;
- // disable closer to prevent GC'ing of this impl from
- // closing the file descriptor
+ // GC'ing of this impl should not close the file descriptor
this.closer.disable();
this.state = ST_CLOSED;
+
+ // create new closer to execute when nsi is GC'ed
+ nsi.closer = FileDescriptorCloser.create(nsi);
}
}
} else {