Enable new errorprone checks and fix violations (#3018)

This commit is contained in:
Weimin Yu
2026-04-20 21:03:36 +00:00
committed by GitHub
parent 9d5650132b
commit 3de790fb00
98 changed files with 406 additions and 444 deletions
@@ -111,9 +111,9 @@ public class TestPipelineExtension extends Pipeline
private static class PipelineRunEnforcement {
@SuppressWarnings("WeakerAccess")
protected boolean enableAutoRunIfMissing;
boolean enableAutoRunIfMissing;
protected final Pipeline pipeline;
final Pipeline pipeline;
boolean runAttempted;
@@ -129,9 +129,9 @@ public class TestPipelineExtension extends Pipeline
runAttempted = true;
}
protected void afterPipelineExecution() {}
void afterPipelineExecution() {}
protected void afterUserCodeFinished() {
void afterUserCodeFinished() {
if (!runAttempted && enableAutoRunIfMissing) {
pipeline.run().waitUntilFinish();
}
@@ -346,8 +346,8 @@ public class TestPipelineExtension extends Pipeline
verifyPAssertsSucceeded(this, pipelineResult);
} catch (RuntimeException exc) {
Throwable cause = exc.getCause();
if (cause instanceof AssertionError) {
throw (AssertionError) cause;
if (cause instanceof AssertionError assertionError) {
throw assertionError;
} else {
throw exc;
}
@@ -504,7 +504,7 @@ public class TestPipelineExtension extends Pipeline
private static class IsEmptyVisitor extends PipelineVisitor.Defaults {
private boolean empty = true;
public boolean isEmpty() {
boolean isEmpty() {
return empty;
}
@@ -55,7 +55,12 @@ public class ExportPremiumTermsActionTest {
private static final ImmutableList<String> PREMIUM_NAMES =
ImmutableList.of("2048,USD 549", "0,USD 549");
private static final String EXPECTED_FILE_CONTENT =
"# Premium Terms Export Disclaimer\n# TLD: tld\n0, 549.00\n" + "2048, 549.00\n";
"""
# Premium Terms Export Disclaimer
# TLD: tld
0, 549.00
2048, 549.00
""";
@RegisterExtension
final JpaIntegrationTestExtension jpa =
@@ -158,7 +158,7 @@ public abstract class FlowTestCase<F extends Flow> {
assertThat(flowClass).isAssignableTo(MutatingFlow.class);
} else {
// There's no "isNotAssignableTo" in Truth.
assertWithMessage(flowClass.getSimpleName() + " implements MutatingFlow")
assertWithMessage("%s implements MutatingFlow", flowClass.getSimpleName())
.that(MutatingFlow.class.isAssignableFrom(flowClass))
.isFalse();
}
@@ -192,7 +192,7 @@ public abstract class FlowTestCase<F extends Flow> {
}
private static BillingBase expandGracePeriod(GracePeriod gracePeriod) {
assertWithMessage("Billing event is present for grace period: " + gracePeriod)
assertWithMessage("Billing event is present for grace period: %s", gracePeriod)
.that(gracePeriod.hasBillingEvent())
.isTrue();
return tm().transact(
@@ -73,7 +73,7 @@ public class PremiumListTest {
BloomFilter<String> bloomFilter = pl.getBloomFilter();
assertThat(bloomFilter.mightContain("notpremium")).isFalse();
for (String label : ImmutableList.of("rich", "lol", "johnny-be-goode", "icann")) {
assertWithMessage(label + " should be a probable premium")
assertWithMessage("%s should be a probable premium", label)
.that(bloomFilter.mightContain(label))
.isTrue();
}
@@ -123,7 +123,7 @@ public class ReservedListDaoTest {
assertThat(ReservedListDao.getLatestRevision("testlist").isPresent()).isFalse();
ReservedListDao.save(testReservedList);
ReservedList persistedList = ReservedListDao.getLatestRevision("testlist").get();
assertThat(persistedList.getRevisionId()).isNotNull();
assertThat(persistedList.getRevisionId()).isAtLeast(1L);
assertThat(persistedList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
assertThat(persistedList.getName()).isEqualTo("testlist");
assertThat(persistedList.getReservedListEntries()).containsExactlyEntriesIn(testReservations);
@@ -143,7 +143,7 @@ public class ReservedListDaoTest {
.build());
ReservedListDao.save(testReservedList);
ReservedList persistedList = ReservedListDao.getLatestRevision("testlist").get();
assertThat(persistedList.getRevisionId()).isNotNull();
assertThat(persistedList.getRevisionId()).isAtLeast(1L);
assertThat(persistedList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
assertThat(persistedList.getName()).isEqualTo("testlist");
assertThat(persistedList.getReservedListEntries()).containsExactlyEntriesIn(testReservations);
@@ -99,7 +99,7 @@ public class DateTimeConverterTest {
DateTime dt;
public TestEntity() {}
TestEntity() {}
TestEntity(String name, DateTime dt) {
this.name = name;
@@ -67,7 +67,7 @@ public class LocalDateConverterTest {
LocalDate date;
public LocalDateConverterTestEntity() {}
LocalDateConverterTestEntity() {}
LocalDateConverterTestEntity(LocalDate date) {
this.date = date;
@@ -41,7 +41,8 @@ class JpaTestExtensionsSqlLoggingTest {
@BeforeEach
void beforeEach() {
orgStdout = System.out;
System.setOut(new PrintStream(stdoutBuffer = new ByteArrayOutputStream()));
stdoutBuffer = new ByteArrayOutputStream();
System.setOut(new PrintStream(stdoutBuffer));
}
@AfterEach
@@ -56,6 +57,6 @@ class JpaTestExtensionsSqlLoggingTest {
tm().getEntityManager()
.createNativeQuery("select 1", long.class)
.getSingleResult());
assertThat(stdoutBuffer.toString(UTF_8.name())).contains("select 1");
assertThat(stdoutBuffer.toString(UTF_8)).contains("select 1");
}
}
@@ -906,12 +906,12 @@ class JpaTransactionManagerImplTest {
}
@Id
public String getNameField() {
String getNameField() {
return name;
}
@Id
public int getAgeField() {
int getAgeField() {
return age;
}
@@ -49,7 +49,7 @@ public class QueryComposerTest {
.withEntityClass(TestEntity.class)
.buildUnitTestExtension();
public QueryComposerTest() {}
QueryComposerTest() {}
@BeforeEach
void setUp() {
@@ -324,18 +324,18 @@ public class QueryComposerTest {
@Column(name = "some_value")
private int val;
public TestEntity() {}
TestEntity() {}
public TestEntity(String name, int val) {
TestEntity(String name, int val) {
this.name = name;
this.val = val;
}
public int getVal() {
int getVal() {
return val;
}
public String getName() {
String getName() {
return name;
}
}
@@ -64,7 +64,7 @@ class RdapActionBaseTest extends RdapActionBaseTestCase<RdapActionBaseTest.RdapT
throw new RuntimeException();
}
return new ReplyPayloadBase(BoilerplateType.OTHER) {
@JsonableElement public String key = "value";
@JsonableElement String key = "value";
};
}
}
@@ -111,7 +111,7 @@ final class RdapDataStructuresTest {
@Test
void testLanguage() {
assertThat(LanguageIdentifier.EN.toJson()).isEqualTo(createJson("'en'"));
assertThat(createJson("'en'")).isEqualTo(LanguageIdentifier.EN.toJson());
assertRestrictedNames(LanguageIdentifier.EN, "lang");
}
@@ -157,7 +157,7 @@ final class RdapDataStructuresTest {
@Test
void testRdapStatus() {
assertThat(RdapStatus.ACTIVE.toJson()).isEqualTo(createJson("'active'"));
assertThat(createJson("'active'")).isEqualTo(RdapStatus.ACTIVE.toJson());
assertRestrictedNames(RdapStatus.ACTIVE, "status[]");
}
@@ -178,7 +178,7 @@ final class RdapDataStructuresTest {
@Test
void testObjectClassName() {
assertThat(ObjectClassName.DOMAIN.toJson()).isEqualTo(createJson("'domain'"));
assertThat(createJson("'domain'")).isEqualTo(ObjectClassName.DOMAIN.toJson());
assertRestrictedNames(ObjectClassName.DOMAIN, "objectClassName");
}
}
@@ -26,6 +26,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntr
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import static google.registry.testing.GsonSubject.assertAboutJson;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
@@ -523,7 +524,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
assertThat(linkToNext).isNotNull();
int pos = linkToNext.indexOf("cursor=");
assertThat(pos).isAtLeast(0);
cursor = URLDecoder.decode(linkToNext.substring(pos + 7), "UTF-8");
cursor = URLDecoder.decode(linkToNext.substring(pos + 7), UTF_8);
JsonArray searchResults = results.getAsJsonArray("domainSearchResults");
assertThat(searchResults).hasSize(action.rdapResultSetMaxSize);
for (JsonElement item : searchResults) {
@@ -23,6 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import static google.registry.testing.GsonSubject.assertAboutJson;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
@@ -214,7 +215,7 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
assertThat(linkToNext).isNotNull();
int pos = linkToNext.indexOf("cursor=");
assertThat(pos).isAtLeast(0);
cursor = URLDecoder.decode(linkToNext.substring(pos + 7), "UTF-8");
cursor = URLDecoder.decode(linkToNext.substring(pos + 7), UTF_8);
JsonArray searchResults = results.getAsJsonArray("entitySearchResults");
assertThat(searchResults).hasSize(action.rdapResultSetMaxSize);
for (JsonElement item : searchResults) {
@@ -377,7 +377,7 @@ class RdapJsonFormatterTest {
.that(
TopLevelReplyObject.create(
new ReplyPayloadBase(BoilerplateType.OTHER) {
@JsonableElement public static final String key = "value";
@JsonableElement static final String key = "value";
},
rdapJsonFormatter.createTosNotice())
.toJson())
@@ -390,7 +390,7 @@ class RdapJsonFormatterTest {
.that(
TopLevelReplyObject.create(
new ReplyPayloadBase(BoilerplateType.DOMAIN) {
@JsonableElement public static final String key = "value";
@JsonableElement static final String key = "value";
},
rdapJsonFormatter.createTosNotice())
.toJson())
@@ -25,6 +25,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import static google.registry.testing.GsonSubject.assertAboutJson;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
@@ -653,7 +654,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
assertThat(linkToNext).isNotNull();
int pos = linkToNext.indexOf("cursor=");
assertThat(pos).isAtLeast(0);
cursor = URLDecoder.decode(linkToNext.substring(pos + 7), "UTF-8");
cursor = URLDecoder.decode(linkToNext.substring(pos + 7), UTF_8);
JsonArray searchResults = results.getAsJsonArray("nameserverSearchResults");
assertThat(searchResults).hasSize(action.rdapResultSetMaxSize);
for (JsonElement item : searchResults) {
@@ -67,10 +67,12 @@ abstract class AbstractEppResourceSubject<
@Override
public void isEqualTo(@Nullable Object other) {
// If the objects differ and we can show an interesting ImmutableObject diff, do so.
if (actual != null && other instanceof ImmutableObject && !actual.equals(other)) {
if (actual != null
&& other instanceof ImmutableObject immutableObject
&& !actual.equals(other)) {
String diffText =
prettyPrintEntityDeepDiff(
((ImmutableObject) other).toDiffableFieldMap(), actual.toDiffableFieldMap());
immutableObject.toDiffableFieldMap(), actual.toDiffableFieldMap());
failWithoutActual(fact("expected", other), fact("but was", actual), fact("diff", diffText));
}
// Otherwise, fall back to regular behavior.
@@ -300,7 +300,7 @@ public class CloudTasksHelper implements Serializable {
params = paramBuilder.build();
}
public Map<String, Object> toMap() {
Map<String, Object> toMap() {
Map<String, Object> builder = new HashMap<>();
builder.put("taskName", taskName);
builder.put("method", method);
@@ -226,8 +226,8 @@ public final class FullFieldsTestEntityHelper {
.setBySuperuser(false)
.setReason(reason)
.setRequestedByRegistrar(false);
if (builder instanceof DomainHistory.Builder) {
((DomainHistory.Builder) builder).setPeriod(period);
if (builder instanceof DomainHistory.Builder domainHistoryBuilder) {
domainHistoryBuilder.setPeriod(period);
}
return builder.build();
}
@@ -110,8 +110,7 @@ public final class GpgSystemCommandExtension implements BeforeEachCallback, Afte
publicKeyring.copyTo(pid.getOutputStream());
pid.getOutputStream().close();
int returnValue = pid.waitFor();
assertWithMessage(
String.format("Failed to import public keyring: \n%s", slurp(pid.getErrorStream())))
assertWithMessage("Failed to import public keyring: \n%s", slurp(pid.getErrorStream()))
.that(returnValue)
.isEqualTo(0);
@@ -119,8 +118,7 @@ public final class GpgSystemCommandExtension implements BeforeEachCallback, Afte
privateKeyring.copyTo(pid.getOutputStream());
pid.getOutputStream().close();
returnValue = pid.waitFor();
assertWithMessage(
String.format("Failed to import private keyring: \n%s", slurp(pid.getErrorStream())))
assertWithMessage("Failed to import private keyring: \n%s", slurp(pid.getErrorStream()))
.that(returnValue)
.isEqualTo(0);
}
@@ -87,7 +87,7 @@ public class LogsSubject extends Subject {
for (String messageCandidate : messagesAtLevel) {
if (messageCandidate.contains(message)) {
return new Which<>(
assertWithMessage(String.format("log message at %s matching '%s'", level, message))
assertWithMessage("log message at %s matching '%s'", level, message)
.that(messageCandidate));
}
}
@@ -19,7 +19,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/**
@@ -65,15 +64,13 @@ public final class UriParameters {
private static String decodeString(String str, int start, int end) {
try {
return URLDecoder.decode(str.substring(start, end), UTF_8.name());
return URLDecoder.decode(str.substring(start, end), UTF_8);
} catch (IllegalArgumentException iae) {
// According to the javadoc of URLDecoder, when the input string is
// illegal, it could either leave the illegal characters alone or throw
// an IllegalArgumentException! To deal with both consistently, we
// ignore IllegalArgumentException and just return the original string.
return str.substring(start, end);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@@ -18,6 +18,7 @@ import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Iterables.toArray;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.beust.jcommander.JCommander;
@@ -83,9 +84,9 @@ public abstract class CommandTestCase<C extends Command> {
// Capture standard output/error. Use a single-byte encoding to emulate platforms where default
// charset is not UTF_8.
oldStdout = System.out;
System.setOut(new PrintStream(new OutputSplitter(System.out, stdout), false, "US-ASCII"));
System.setOut(new PrintStream(new OutputSplitter(System.out, stdout), false, US_ASCII));
oldStderr = System.err;
System.setErr(new PrintStream(new OutputSplitter(System.err, stderr), false, "US-ASCII"));
System.setErr(new PrintStream(new OutputSplitter(System.err, stderr), false, US_ASCII));
}
@AfterEach
@@ -183,7 +183,7 @@ public class EppToolVerifier {
assertThat(map).containsEntry("dryRun", Boolean.toString(dryRun));
assertThat(map).containsEntry("clientId", registrarId);
assertThat(map).containsEntry("superuser", Boolean.toString(superuser));
return URLDecoder.decode(map.get("xml"), UTF_8.toString());
return URLDecoder.decode(map.get("xml"), UTF_8);
}
private EppToolVerifier verifySentContents(String expectedXmlContent) throws Exception {
@@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.tools.GenerateSqlErDiagramCommand.FLYWAY_FILE_ELEMENT_ID;
import static google.registry.tools.GenerateSqlErDiagramCommand.getLastFlywayFileName;
import com.google.common.base.Joiner;
import google.registry.util.ResourceUtils;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
@@ -33,15 +32,14 @@ class GenerateSqlErDiagramCommandTest extends CommandTestCase<GenerateSqlErDiagr
private static final String GOLDEN_DIAGRAM_FOLDER = "sql/er_diagram";
private static final String UPDATE_INSTRUCTIONS =
Joiner.on('\n')
.join(
"",
"-------------------------------------------------------------------------------",
"Your changes affect SQL ER diagrams. To update the checked-in version, run the"
+ " following command in the repository root:",
"./gradlew devTool --args=\"-e localhost generate_sql_er_diagram -o"
+ " ../db/src/main/resources/sql/er_diagram\"",
"");
"""
-------------------------------------------------------------------------------
Your changes affect SQL ER diagrams. To update the checked-in version, run the \
following command in the repository root:
./gradlew devTool --args="-e localhost generate_sql_er_diagram -o \
../db/src/main/resources/sql/er_diagram"
""";
@Test
void testSchemaGeneration() throws Exception {
@@ -57,10 +57,12 @@ public class GetFeatureFlagCommandTest extends CommandTestCase<GetFeatureFlagCom
.build());
runCommand("TEST_FEATURE");
assertInStdout(
"featureName: \"TEST_FEATURE\"\n"
+ "status:\n"
+ " \"1970-01-01T00:00:00.000Z\": \"INACTIVE\"\n"
+ " \"2000-02-26T00:00:00.000Z\": \"ACTIVE\"");
"""
featureName: "TEST_FEATURE"
status:
"1970-01-01T00:00:00.000Z": "INACTIVE"
"2000-02-26T00:00:00.000Z": "ACTIVE\"\
""");
}
@Test
@@ -86,16 +88,18 @@ public class GetFeatureFlagCommandTest extends CommandTestCase<GetFeatureFlagCom
.build());
runCommand("TEST_FEATURE", "MINIMUM_DATASET_CONTACTS_OPTIONAL");
assertInStdout(
"featureName: \"TEST_FEATURE\"\n"
+ "status:\n"
+ " \"1970-01-01T00:00:00.000Z\": \"INACTIVE\"\n"
+ " \"2000-02-26T00:00:00.000Z\": \"ACTIVE\""
+ "\n\n"
+ "featureName: \"MINIMUM_DATASET_CONTACTS_OPTIONAL\"\n"
+ "status:\n"
+ " \"1970-01-01T00:00:00.000Z\": \"INACTIVE\"\n"
+ " \"2000-01-22T00:00:00.000Z\": \"ACTIVE\"\n"
+ " \"2000-02-12T00:00:00.000Z\": \"INACTIVE\"");
"""
featureName: "TEST_FEATURE"
status:
"1970-01-01T00:00:00.000Z": "INACTIVE"
"2000-02-26T00:00:00.000Z": "ACTIVE"
featureName: "MINIMUM_DATASET_CONTACTS_OPTIONAL"
status:
"1970-01-01T00:00:00.000Z": "INACTIVE"
"2000-01-22T00:00:00.000Z": "ACTIVE"
"2000-02-12T00:00:00.000Z": "INACTIVE\"\
""");
}
@Test
@@ -56,27 +56,29 @@ class SecurityActionTest extends ConsoleActionBaseTestCase {
private Registrar testRegistrar;
private static final String VALIDITY_TOO_LONG_CERT_PEM =
"-----BEGIN CERTIFICATE-----\n"
+ "MIIDejCCAv+gAwIBAgIQHNcSEt4VENkSgtozEEoQLzAKBggqhkjOPQQDAzB8MQsw\n"
+ "CQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24xGDAW\n"
+ "BgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBSb290IENl\n"
+ "cnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzAeFw0xOTAzMDcxOTQyNDJaFw0zNDAz\n"
+ "MDMxOTQyNDJaMG8xCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UE\n"
+ "BwwHSG91c3RvbjERMA8GA1UECgwIU1NMIENvcnAxKzApBgNVBAMMIlNTTC5jb20g\n"
+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TIFICATE-----\
""";
private AuthenticatedRegistrarAccessor registrarAccessor =
AuthenticatedRegistrarAccessor.createForTesting(
@@ -42,10 +42,10 @@ class XjcObjectTest {
XjcRdeDeposit deposit = unmarshalFullDeposit();
ByteArrayOutputStream out = new ByteArrayOutputStream();
deposit.marshal(out, UTF_8);
String xml = out.toString(UTF_8.toString());
String xml = out.toString(UTF_8);
Pattern pat = Pattern.compile("^<\\?xml version=\"1\\.0\" encoding=\"UTF[-_]?8\"");
assertWithMessage("bad xml declaration: " + xml).that(pat.matcher(xml).find()).isTrue();
assertWithMessage("encode/decode didn't work: " + xml).that(xml).contains("jdoe@example.test");
assertWithMessage("bad xml declaration: %s", xml).that(pat.matcher(xml).find()).isTrue();
assertWithMessage("encode/decode didn't work: %s", xml).that(xml).contains("jdoe@example.test");
}
@Test
@@ -53,10 +53,10 @@ class XjcObjectTest {
XjcRdeDeposit deposit = unmarshalFullDeposit();
ByteArrayOutputStream out = new ByteArrayOutputStream();
deposit.marshal(out, UTF_16);
String xml = out.toString(UTF_16.toString());
String xml = out.toString(UTF_16);
Pattern pat = Pattern.compile("^<\\?xml version=\"1\\.0\" encoding=\"UTF[-_]?16\"");
assertWithMessage(xml).that(pat.matcher(xml).find()).isTrue();
assertWithMessage("encode/decode didn't work: " + xml).that(xml).contains("jdoe@example.test");
assertWithMessage("encode/decode didn't work: %s", xml).that(xml).contains("jdoe@example.test");
}
@Test
@@ -210,7 +210,7 @@ public class XmlTestUtils {
// an empty map, so normalize that here.
return new AbstractMap.SimpleEntry<>(elementName, map.isEmpty() ? "" : map);
}
if (obj instanceof JSONArray) {
if (obj instanceof JSONArray jsonArray) {
// Another problem resulting from JSONification: If the array contains elements whose names
// are the same before URI expansion, but different after URI expansion, because they use
// xmlns attribute that define the namespaces differently, we will screw up. Again, hopefully
@@ -220,9 +220,9 @@ public class XmlTestUtils {
// hands and just assume that the URI expansion of the first element holds for all others.
Set<Object> set = new HashSet<>();
String mappedKey = null;
for (int i = 0; i < ((JSONArray) obj).length(); ++i) {
for (int i = 0; i < jsonArray.length(); ++i) {
Map.Entry<String, Object> simpleEntry =
normalize(null, ((JSONArray) obj).get(i), path, ignoredPaths, nsMap);
normalize(null, jsonArray.get(i), path, ignoredPaths, nsMap);
if (i == 0) {
mappedKey = simpleEntry.getKey();
}
@@ -233,8 +233,8 @@ public class XmlTestUtils {
if (obj instanceof Number) {
return new AbstractMap.SimpleEntry<>(null, obj.toString());
}
if (obj instanceof Boolean) {
return new AbstractMap.SimpleEntry<>(null, ((Boolean) obj) ? "1" : "0");
if (obj instanceof Boolean b) {
return new AbstractMap.SimpleEntry<>(null, b ? "1" : "0");
}
if (obj instanceof String) {
// Turn stringified booleans into integers. Both are acceptable as xml boolean values, but