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
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Test
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.6.5
gradle-version: 8.7
build-root-directory: tck-impl
arguments: check -Pparsson.home=image/parsson-dist -Pparsson.impl=${{ matrix.test_suite }}
- name: Upload test results
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2026 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -168,7 +168,9 @@ public JsonObjectBuilder addAll(JsonObjectBuilder builder) {
@Override
public JsonObjectBuilder remove(String name) {
validateName(name);
this.valueMap.remove(name);
if (valueMap != null) {
valueMap.remove(name);
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2024 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2026 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -95,6 +95,28 @@ void testJsonObjectMap() {
JsonObjectTest.testPerson(copyPerson);
}

@Test
void testRemoveFromEmptyObjectBuilder() {
JsonObject empty = Json.createObjectBuilder()
.remove("missing")
.build();

JsonObjectTest.testEmpty(empty);
}

@Test
void testRemoveFromObjectBuilderAfterBuild() {
JsonObjectBuilder builder = Json.createObjectBuilder()
.add("firstName", "John");

JsonObject first = builder.build();
builder.remove("firstName");
JsonObject empty = builder.build();

Assertions.assertEquals("John", first.getString("firstName"));
JsonObjectTest.testEmpty(empty);
}

static Map<String, Object> buildPersonAsMap() {
Map<String, Object> person = new HashMap<>();
person.put("firstName", "John");
Expand Down
Loading