diff --git a/fdb-relational-api/src/main/java/com/apple/foundationdb/relational/util/Assert.java b/fdb-relational-api/src/main/java/com/apple/foundationdb/relational/util/Assert.java index 47b3328cbd..b1e02978bb 100644 --- a/fdb-relational-api/src/main/java/com/apple/foundationdb/relational/util/Assert.java +++ b/fdb-relational-api/src/main/java/com/apple/foundationdb/relational/util/Assert.java @@ -27,6 +27,7 @@ import com.apple.foundationdb.relational.api.exceptions.RelationalException; import javax.annotation.Nonnull; +import java.util.Locale; import java.util.function.Supplier; /** @@ -58,13 +59,13 @@ public static void that(boolean mustBeTrue, @Nonnull final ErrorCode errorCodeIf public static void that(boolean mustBeTrue, @Nonnull final ErrorCode errorCodeIfNotTrue, @Nonnull final String messageFormat, @Nonnull Object messageValue) throws RelationalException { if (!mustBeTrue) { - throw new RelationalException(String.format(messageFormat, messageValue), errorCodeIfNotTrue); + throw new RelationalException(String.format(Locale.ROOT, messageFormat, messageValue), errorCodeIfNotTrue); } } public static void that(boolean mustBeTrue, @Nonnull final ErrorCode errorCodeIfNotTrue, @Nonnull final String messageFormat, @Nonnull Object messageValue1, @Nonnull Object messageValue2) throws RelationalException { if (!mustBeTrue) { - throw new RelationalException(String.format(messageFormat, messageValue1, messageValue2), errorCodeIfNotTrue); + throw new RelationalException(String.format(Locale.ROOT, messageFormat, messageValue1, messageValue2), errorCodeIfNotTrue); } } @@ -132,13 +133,13 @@ public static void thatUnchecked(boolean mustBeTrue, @Nonnull final ErrorCode er public static void thatUnchecked(boolean mustBeTrue, @Nonnull final ErrorCode errorCodeIfNotTrue, @Nonnull final String messageTemplate, @Nonnull final Object messageValue) { if (!mustBeTrue) { - throw new RelationalException(String.format(messageTemplate, messageValue), errorCodeIfNotTrue).toUncheckedWrappedException(); + throw new RelationalException(String.format(Locale.ROOT, messageTemplate, messageValue), errorCodeIfNotTrue).toUncheckedWrappedException(); } } public static void thatUnchecked(boolean mustBeTrue, @Nonnull final ErrorCode errorCodeIfNotTrue, @Nonnull final String messageTemplate, @Nonnull final Object messageValue1, @Nonnull final Object messageValue2) { if (!mustBeTrue) { - throw new RelationalException(String.format(messageTemplate, messageValue1, messageValue2), errorCodeIfNotTrue).toUncheckedWrappedException(); + throw new RelationalException(String.format(Locale.ROOT, messageTemplate, messageValue1, messageValue2), errorCodeIfNotTrue).toUncheckedWrappedException(); } } @@ -168,7 +169,7 @@ public static T notNullUnchecked(T object, @Nonnull final ErrorCode errorCod public static T notNullUnchecked(T object, @Nonnull final ErrorCode errorCodeIfNull, @Nonnull final String messageTemplate, @Nonnull final Object messageValue) { if (object == null) { - throw new RelationalException(String.format(messageTemplate, messageValue), errorCodeIfNull).toUncheckedWrappedException(); + throw new RelationalException(String.format(Locale.ROOT, messageTemplate, messageValue), errorCodeIfNull).toUncheckedWrappedException(); } else { return object; } diff --git a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/catalog/RecordLayerStoreCatalog.java b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/catalog/RecordLayerStoreCatalog.java index 0f175c6f34..53a90f55de 100644 --- a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/catalog/RecordLayerStoreCatalog.java +++ b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/catalog/RecordLayerStoreCatalog.java @@ -215,7 +215,7 @@ public void saveSchema(@Nonnull final Transaction txn, @Nonnull final Schema sch if (createDatabaseIfNecessary) { createDatabase(recordStore, URI.create(schema.getDatabaseName())); } else { - throw new RelationalException(String.format("Cannot create schema %s because database %s does not exist.", schema.getName(), schema.getDatabaseName()), + throw new RelationalException("Cannot create schema " + schema.getName() + " because database " + schema.getDatabaseName() + " does not exist.", ErrorCode.UNDEFINED_DATABASE); } } @@ -223,9 +223,9 @@ public void saveSchema(@Nonnull final Transaction txn, @Nonnull final Schema sch Assert.that(schemaTemplateCatalog.doesSchemaTemplateExist(txn, schema.getSchemaTemplate().getName(), schema.getSchemaTemplate().getVersion()), ErrorCode.UNKNOWN_SCHEMA_TEMPLATE, - () -> String.format("Cannot create schema %s because schema template %s version %d does not exist.", - schema.getName(), schema.getSchemaTemplate().getName(), - schema.getSchemaTemplate().getVersion())); + () -> "Cannot create schema " + schema.getName() + " because schema template " + + schema.getSchemaTemplate().getName() + " version " + + schema.getSchemaTemplate().getVersion() + " does not exist."); try { putSchema((RecordLayerSchema) schema, recordStore); } catch (RecordCoreException ex) { diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/IntermingledTablesTest.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/IntermingledTablesTest.java index f677eed59d..9305744989 100644 --- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/IntermingledTablesTest.java +++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/IntermingledTablesTest.java @@ -138,7 +138,7 @@ void queryFromSharedExtent() throws SQLException { } for (int group = 0; group < groupCount; group++) { - try (RelationalResultSet resultSet = statement.executeQuery(String.format("SELECT * FROM t1 WHERE group = %d", group))) { + try (RelationalResultSet resultSet = statement.executeQuery("SELECT * FROM t1 WHERE group = " + group)) { ResultSetAssert.assertThat(resultSet).containsRowsExactly(List.of( new Object[]{group, "t1_0", 0}, new Object[]{group, "t1_1", 10},