Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
[GR-38378] Merge in jdk-11.0.16+7.
Browse files Browse the repository at this point in the history
PullRequest: labsjdk-ce-11/286
  • Loading branch information
marwan-hallaoui committed Jun 17, 2022
2 parents 9c38420 + 4d231f1 commit 1ec78bc
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 166 deletions.
18 changes: 12 additions & 6 deletions src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,29 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jobject this,

#if defined(__solaris__)
rv = connect(fd, 0, 0);
#elif defined(__APPLE__)
// On macOS systems we use disconnectx
rv = disconnectx(fd, SAE_ASSOCID_ANY, SAE_CONNID_ANY);
#else
SOCKETADDRESS sa;
socklen_t len = isIPv6 ? sizeof(struct sockaddr_in6) :
sizeof(struct sockaddr_in);

memset(&sa, 0, sizeof(sa));
#if defined(_ALLBSD_SOURCE)
sa.sa.sa_family = isIPv6 ? AF_INET6 : AF_INET;
#else
sa.sa.sa_family = AF_UNSPEC;
#endif
socklen_t len = isIPv6 ? sizeof(struct sockaddr_in6) :
sizeof(struct sockaddr_in);

rv = connect(fd, &sa.sa, len);
#endif

#if defined(_ALLBSD_SOURCE)
#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
// On _ALLBSD_SOURCE except __APPLE__ we consider EADDRNOTAVAIL
// error to be OK and ignore it. __APPLE__ systems are excluded
// in this check since for __APPLE__ systems, unlike other BSD systems,
// we issue a "disconnectx" call (a few lines above),
// which isn't expected to return this error code.
if (rv < 0 && errno == EADDRNOTAVAIL)
rv = errno = 0;
#elif defined(_AIX)
Expand All @@ -115,8 +123,6 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jobject this,
rv = errno = 0;
#endif // defined(_ALLBSD_SOURCE) || defined(_AIX)

#endif // defined(__solaris__)

if (rv < 0)
handleSocketError(env, errno);
}
Expand Down
2 changes: 0 additions & 2 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,6 @@ sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-
sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all
sun/security/ssl/SSLSessionImpl/NoInvalidateSocketException.java 8277970,8280158 generic-all

sun/security/ssl/X509TrustManagerImpl/Symantec/Distrust.java 8287109 generic-all

############################################################################

# jdk_sound
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/nio/channels/DatagramChannel/Disconnect.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -22,7 +22,7 @@
*/

/* @test
* @bug 7132924
* @bug 7132924 8285515
* @key intermittent
* @summary Test DatagramChannel.disconnect when DatagramChannel is connected to an IPv4 socket
* @run main Disconnect
Expand Down
12 changes: 6 additions & 6 deletions test/jdk/java/nio/file/Files/probeContentType/Basic.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ static int checkContentTypes(ExType[] exTypes)
+ " cannot be determined");
failures++;
} else if (!expectedTypes.contains(type)) {
System.err.printf("Content type: %s; expected: %s%n",
type, expectedTypes);
System.err.printf("For extension %s we got content type: %s; expected: %s%n",
extension, type, expectedTypes);
failures++;
}
} finally {
Expand Down Expand Up @@ -156,7 +156,7 @@ public static void main(String[] args) throws IOException {
// Verify that certain extensions are mapped to the correct type.
var exTypes = new ExType[] {
new ExType("adoc", List.of("text/plain")),
new ExType("bz2", List.of("application/bz2", "application/x-bzip2")),
new ExType("bz2", List.of("application/bz2", "application/x-bzip2", "application/x-bzip")),
new ExType("css", List.of("text/css")),
new ExType("csv", List.of("text/csv")),
new ExType("doc", List.of("application/msword")),
Expand All @@ -167,19 +167,19 @@ public static void main(String[] args) throws IOException {
new ExType("js", List.of("text/javascript", "application/javascript")),
new ExType("json", List.of("application/json")),
new ExType("markdown", List.of("text/markdown")),
new ExType("md", List.of("text/markdown")),
new ExType("md", List.of("text/markdown", "application/x-genesis-rom")),
new ExType("mp3", List.of("audio/mpeg")),
new ExType("mp4", List.of("video/mp4")),
new ExType("odp", List.of("application/vnd.oasis.opendocument.presentation")),
new ExType("ods", List.of("application/vnd.oasis.opendocument.spreadsheet")),
new ExType("odt", List.of("application/vnd.oasis.opendocument.text")),
new ExType("pdf", List.of("application/pdf")),
new ExType("php", List.of("text/plain", "text/php")),
new ExType("php", List.of("text/plain", "text/php", "application/x-php")),
new ExType("png", List.of("image/png")),
new ExType("ppt", List.of("application/vnd.ms-powerpoint")),
new ExType("pptx",List.of("application/vnd.openxmlformats-officedocument.presentationml.presentation")),
new ExType("py", List.of("text/plain", "text/x-python", "text/x-python-script")),
new ExType("rar", List.of("application/rar", "application/vnd.rar")),
new ExType("rar", List.of("application/rar", "application/vnd.rar", "application/x-rar")),
new ExType("rtf", List.of("application/rtf", "text/rtf")),
new ExType("webm", List.of("video/webm")),
new ExType("webp", List.of("image/webp")),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -54,15 +54,14 @@ public class Distrust {
// Each of the roots have a test certificate chain stored in a file
// named "<root>-chain.pem".
private static String[] rootsToTest = new String[] {
"geotrustglobalca", "geotrustprimarycag2", "geotrustprimarycag3",
"geotrustprimarycag2", "geotrustprimarycag3",
"geotrustuniversalca", "thawteprimaryrootca", "thawteprimaryrootcag2",
"thawteprimaryrootcag3", "verisignclass3g3ca", "verisignclass3g4ca",
"verisignclass3g5ca", "verisignuniversalrootca" };

// Each of the subCAs with a delayed distrust date have a test certificate
// chain stored in a file named "<subCA>-chain.pem".
private static String[] subCAsToTest = new String[] {
"appleistca2g1", "appleistca8g1" };
private static String[] subCAsToTest = new String[]{"appleistca8g1"};

// A date that is after the restrictions take affect
private static final Date APRIL_17_2019 =
Expand Down Expand Up @@ -180,13 +179,19 @@ private static void testTM(X509TrustManager xtm, X509Certificate[] chain,
throw new Exception("chain should be invalid");
}
} catch (CertificateException ce) {
// expired TLS certificates should not be treated as failure
if (expired(ce)) {
System.err.println("Test is N/A, chain is expired");
return;
}
if (valid) {
throw new Exception("Unexpected exception, chain " +
"should be valid", ce);
}
if (ce instanceof ValidatorException) {
ValidatorException ve = (ValidatorException)ce;
if (ve.getErrorType() != ValidatorException.T_UNTRUSTED_CERT) {
ce.printStackTrace(System.err);
throw new Exception("Unexpected exception: " + ce);
}
} else {
Expand All @@ -195,6 +200,21 @@ private static void testTM(X509TrustManager xtm, X509Certificate[] chain,
}
}

// check if a cause of exception is an expired cert
private static boolean expired(CertificateException ce) {
if (ce instanceof CertificateExpiredException) {
return true;
}
Throwable t = ce.getCause();
while (t != null) {
if (t instanceof CertificateExpiredException) {
return true;
}
t = t.getCause();
}
return false;
}

private static X509Certificate[] loadCertificateChain(String name)
throws Exception {
try (InputStream in = new FileInputStream(TEST_SRC + File.separator +
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 1ec78bc

Please sign in to comment.