Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
Expand Down Expand Up @@ -145,7 +145,7 @@ public HttpRequestBuilderImpl header(String name, String value) {
@Override
public HttpRequestBuilderImpl headers(String... params) {
requireNonNull(params);
if (params.length == 0 || params.length % 2 != 0) {
if (params.length % 2 != 0) {
throw newIAE("wrong number, %d, of parameters", params.length);
}
for (int i = 0; i < params.length; i += 2) {
Expand Down
6 changes: 3 additions & 3 deletions test/jdk/java/net/httpclient/HttpRequestBuilderTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
Expand Down Expand Up @@ -112,8 +112,8 @@ public static void main(String[] args) throws Exception {
builder = test1("headers", builder, builder::headers, (String[]) null,
NullPointerException.class);

builder = test1("headers", builder, builder::headers, new String[0],
IllegalArgumentException.class);
builder = test1("headers", builder, builder::headers, new String[0]
/* no expected exceptions */);

builder = test1("headers", builder, builder::headers,
(String[]) new String[] {null, "bar"},
Expand Down
3 changes: 1 addition & 2 deletions test/jdk/java/net/httpclient/RequestBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,10 @@ public void testMethod() {
public void testHeaders() {
HttpRequest.Builder builder = newBuilder(uri);

String[] empty = new String[0];
assertThrows(IAE, () -> builder.headers(empty).build());
assertThrows(IAE, () -> builder.headers("1").build());
assertThrows(IAE, () -> builder.headers("1", "2", "3").build());
assertThrows(IAE, () -> builder.headers("1", "2", "3", "4", "5").build());
assertEquals(0, builder.headers(new String[0]).build().headers().map().size());
assertEquals(0, builder.build().headers().map().size());

List<HttpRequest> requests = List.of(
Expand Down