Skip to content

Commit f0b602a

Browse files
authored
Merge pull request #2098 from SAP/pr-jdk-17.0.18+2
Merge to tag jdk-17.0.18+2
2 parents 6b9c7d4 + e3c50e1 commit f0b602a

File tree

41 files changed

+2920
-873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2920
-873
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ jobs:
243243
uses: ./.github/workflows/build-macos.yml
244244
with:
245245
platform: macos-x64
246-
runs-on: 'macos-13'
247-
xcode-toolset-version: '14.3.1'
246+
runs-on: 'macos-15-intel'
247+
xcode-toolset-version: '16.4'
248248
configure-arguments: ${{ github.event.inputs.configure-arguments }}
249249
make-arguments: ${{ github.event.inputs.make-arguments }}
250250
if: needs.prepare.outputs.macos-x64 == 'true'
@@ -255,8 +255,8 @@ jobs:
255255
uses: ./.github/workflows/build-macos.yml
256256
with:
257257
platform: macos-aarch64
258-
runs-on: 'macos-14'
259-
xcode-toolset-version: '15.4'
258+
runs-on: 'macos-15'
259+
xcode-toolset-version: '16.4'
260260
configure-arguments: ${{ github.event.inputs.configure-arguments }}
261261
make-arguments: ${{ github.event.inputs.make-arguments }}
262262
if: needs.prepare.outputs.macos-aarch64 == 'true'
@@ -309,8 +309,8 @@ jobs:
309309
with:
310310
platform: macos-aarch64
311311
bootjdk-platform: macos-aarch64
312-
runs-on: macos-14
313-
xcode-toolset-version: '15.4'
312+
runs-on: macos-15
313+
xcode-toolset-version: '16.4'
314314

315315
test-windows-x64:
316316
name: windows-x64

make/autoconf/basic_tools.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
373373
374374
# Check if it's a GNU date compatible version
375375
AC_MSG_CHECKING([if date is a GNU compatible version])
376-
check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox"`
376+
check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox\|uutils"`
377377
if test "x$check_date" != x; then
378378
AC_MSG_RESULT([yes])
379379
IS_GNU_DATE=yes

src/java.base/share/classes/sun/nio/ch/Net.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public String name() {
7070
// set to true if the fast tcp loopback should be enabled on Windows
7171
private static final boolean fastLoopback;
7272

73+
// set to true if shut down before close should be enabled on Windows
74+
private static final boolean SHUTDOWN_WRITE_BEFORE_CLOSE;
75+
7376
// -- Miscellaneous utilities --
7477

7578
private static volatile boolean checkedIPv6;
@@ -106,6 +109,13 @@ static boolean useExclusiveBind() {
106109
return exclusiveBind;
107110
}
108111

112+
/**
113+
* Tells whether a TCP connection should be shutdown for writing before closing.
114+
*/
115+
static boolean shouldShutdownWriteBeforeClose() {
116+
return SHUTDOWN_WRITE_BEFORE_CLOSE;
117+
}
118+
109119
/**
110120
* Tells whether both IPV6_XXX and IP_XXX socket options should be set on
111121
* IPv6 sockets. On some kernels, both IPV6_XXX and IP_XXX socket options
@@ -506,6 +516,8 @@ public static boolean isFastTcpLoopbackRequested() {
506516
*/
507517
private static native int isExclusiveBindAvailable();
508518

519+
private static native boolean shouldShutdownWriteBeforeClose0();
520+
509521
private static native boolean shouldSetBothIPv4AndIPv6Options0();
510522

511523
private static native boolean canIPv6SocketJoinIPv4Group0();
@@ -832,5 +844,6 @@ static native int blockOrUnblock6(boolean block, FileDescriptor fd, byte[] group
832844
}
833845

834846
fastLoopback = isFastTcpLoopbackRequested();
847+
SHUTDOWN_WRITE_BEFORE_CLOSE = shouldShutdownWriteBeforeClose0();
835848
}
836849
}

src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ public boolean isConnectionPending() {
743743
/**
744744
* Marks the beginning of a connect operation that might block.
745745
* @param blocking true if configured blocking
746-
* @param isa the remote address
746+
* @param sa the remote socket address
747747
* @throws ClosedChannelException if the channel is closed
748748
* @throws AlreadyConnectedException if already connected
749749
* @throws ConnectionPendingException is a connection is pending
@@ -970,8 +970,8 @@ public boolean finishConnect() throws IOException {
970970
}
971971

972972
/**
973-
* Closes the socket if there are no I/O operations in progress and the
974-
* channel is not registered with a Selector.
973+
* Closes the socket if there are no I/O operations in progress (or no I/O
974+
* operations tracked), and the channel is not registered with a Selector.
975975
*/
976976
private boolean tryClose() throws IOException {
977977
assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
@@ -996,11 +996,16 @@ private void tryFinishClose() {
996996
}
997997

998998
/**
999-
* Closes this channel when configured in blocking mode.
999+
* Closes this channel when configured in blocking mode. If there are no I/O
1000+
* operations in progress (or tracked), then the channel's socket is closed. If
1001+
* there are I/O operations in progress then the behavior is platform specific.
10001002
*
1001-
* If there is an I/O operation in progress then the socket is pre-closed
1002-
* and the I/O threads signalled, in which case the final close is deferred
1003-
* until all I/O operations complete.
1003+
* On Unix systems, the channel's socket is pre-closed. The socket is dup'ed
1004+
* and the threads signalled. The final close is deferred until all I/O
1005+
* operations complete.
1006+
*
1007+
* On Windows, the channel's socket is pre-closed. The channel's
1008+
* socket is closed.
10041009
*
10051010
* Note that a channel configured blocking may be registered with a Selector
10061011
* This arises when a key is canceled and the channel configured to blocking
@@ -1009,7 +1014,19 @@ private void tryFinishClose() {
10091014
private void implCloseBlockingMode() throws IOException {
10101015
synchronized (stateLock) {
10111016
assert state < ST_CLOSING;
1017+
boolean connected = (state == ST_CONNECTED);
10121018
state = ST_CLOSING;
1019+
1020+
if (connected && Net.shouldShutdownWriteBeforeClose()) {
1021+
// shutdown output when linger interval not set to 0
1022+
try {
1023+
var SO_LINGER = StandardSocketOptions.SO_LINGER;
1024+
if ((int) Net.getSocketOption(fd, SO_LINGER) != 0) {
1025+
Net.shutdown(fd, Net.SHUT_WR);
1026+
}
1027+
} catch (IOException ignore) { }
1028+
}
1029+
10131030
if (!tryClose()) {
10141031
long reader = readerThread;
10151032
long writer = writerThread;

src/java.base/unix/native/libnio/ch/Net.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) {
200200
return -1;
201201
}
202202

203+
JNIEXPORT jboolean JNICALL
204+
Java_sun_nio_ch_Net_shouldShutdownWriteBeforeClose0(JNIEnv *env, jclass clazz) {
205+
return JNI_FALSE;
206+
}
207+
203208
JNIEXPORT jboolean JNICALL
204209
Java_sun_nio_ch_Net_shouldSetBothIPv4AndIPv6Options0(JNIEnv* env, jclass cl)
205210
{

src/java.base/windows/native/libnio/ch/Net.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -117,6 +117,11 @@ Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) {
117117
return 1;
118118
}
119119

120+
JNIEXPORT jboolean JNICALL
121+
Java_sun_nio_ch_Net_shouldShutdownWriteBeforeClose0(JNIEnv *env, jclass clazz) {
122+
return JNI_TRUE;
123+
}
124+
120125
JNIEXPORT jboolean JNICALL
121126
Java_sun_nio_ch_Net_shouldSetBothIPv4AndIPv6Options0(JNIEnv* env, jclass cl)
122127
{

0 commit comments

Comments
 (0)