8381176: Utilities.expectedNegoAppProtocol chooses client ALPN protocol over server's

Reviewed-by: djelinski, myankelevich
This commit is contained in:
Matthew Donovan 2026-04-16 14:11:07 +00:00
parent 8688c0b655
commit 04bb3a91db
2 changed files with 25 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2026, 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
@ -430,10 +430,10 @@ public class Utilities {
public static String expectedNegoAppProtocol(String[] serverAppProtocols,
String[] clientAppProtocols) {
if (serverAppProtocols != null && clientAppProtocols != null) {
for(String clientAppProtocol : clientAppProtocols) {
for(String serverAppProtocol : serverAppProtocols) {
if (clientAppProtocol.equals(serverAppProtocol)) {
return clientAppProtocol;
for(String serverAppProtocol : serverAppProtocols) {
for(String clientAppProtocol : clientAppProtocols) {
if (serverAppProtocol.equals(clientAppProtocol)) {
return serverAppProtocol;
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2025, 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
@ -36,6 +36,8 @@
* @run main/manual AlpnTest false
*/
import jtreg.SkippedException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -98,6 +100,19 @@ public class AlpnTest extends ExtInteropTest {
clientCase.setCipherSuites(cipherSuite);
clientCase.setAppProtocols("h2");
testCases.add(
new TestCase<ExtUseCase>(serverCase, clientCase));
serverCase = ExtUseCase.newInstance();
serverCase.setCertTuple(certTuple);
serverCase.setAppProtocols("http/1.1", "h2");
clientCase = ExtUseCase.newInstance();
clientCase.setCertTuple(certTuple);
clientCase.setProtocols(protocol);
clientCase.setCipherSuites(cipherSuite);
clientCase.setAppProtocols("h2", "http/1.1");
testCases.add(
new TestCase<ExtUseCase>(serverCase, clientCase));
}
@ -171,6 +186,10 @@ public class AlpnTest extends ExtInteropTest {
Boolean defaultJdkAsServer = Boolean.valueOf(args[0]);
Set<JdkInfo> jdkInfos = Utils.jdkInfoList();
if (jdkInfos.isEmpty()) {
throw new SkippedException("No JDKs to test");
}
for (JdkInfo jdkInfo : jdkInfos) {
AlpnTest test = new AlpnTest(
defaultJdkAsServer ? JdkInfo.DEFAULT : jdkInfo,