Skip to content

Commit 02a6708

Browse files
committed
Apply suggestions
1 parent e4cfa86 commit 02a6708

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

core/src/integration-test/java/com/scalar/db/storage/objectstorage/ObjectStorageAdminTestUtils.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,24 @@ public void dropMetadataTable() {
3131

3232
@Override
3333
public void truncateNamespacesTable() throws Exception {
34-
wrapper.delete(
35-
ObjectStorageUtils.getObjectKey(
36-
metadataNamespace, ObjectStorageAdmin.NAMESPACE_METADATA_TABLE));
34+
try {
35+
wrapper.delete(
36+
ObjectStorageUtils.getObjectKey(
37+
metadataNamespace, ObjectStorageAdmin.NAMESPACE_METADATA_TABLE));
38+
} catch (PreconditionFailedException e) {
39+
// The namespace metadata table object does not exist, so do nothing
40+
}
3741
}
3842

3943
@Override
4044
public void truncateMetadataTable() throws Exception {
41-
wrapper.delete(
42-
ObjectStorageUtils.getObjectKey(
43-
metadataNamespace, ObjectStorageAdmin.TABLE_METADATA_TABLE));
45+
try {
46+
wrapper.delete(
47+
ObjectStorageUtils.getObjectKey(
48+
metadataNamespace, ObjectStorageAdmin.TABLE_METADATA_TABLE));
49+
} catch (PreconditionFailedException e) {
50+
// The table metadata table object does not exist, so do nothing
51+
}
4452
}
4553

4654
@Override

core/src/main/java/com/scalar/db/storage/objectstorage/ObjectStorageTableMetadata.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
77
import java.util.Collections;
88
import java.util.HashMap;
9+
import java.util.HashSet;
910
import java.util.LinkedHashSet;
1011
import java.util.Map;
1112
import java.util.Objects;
@@ -34,13 +35,17 @@ public ObjectStorageTableMetadata(
3435
@Nullable Map<String, String> clusteringOrders,
3536
@Nullable Set<String> secondaryIndexNames,
3637
@Nullable Map<String, String> columns) {
37-
this.partitionKeyNames = partitionKeyNames != null ? partitionKeyNames : new LinkedHashSet<>();
38+
this.partitionKeyNames =
39+
partitionKeyNames != null ? new LinkedHashSet<>(partitionKeyNames) : new LinkedHashSet<>();
3840
this.clusteringKeyNames =
39-
clusteringKeyNames != null ? clusteringKeyNames : new LinkedHashSet<>();
40-
this.clusteringOrders = clusteringOrders != null ? clusteringOrders : Collections.emptyMap();
41+
clusteringKeyNames != null
42+
? new LinkedHashSet<>(clusteringKeyNames)
43+
: new LinkedHashSet<>();
44+
this.clusteringOrders =
45+
clusteringOrders != null ? new HashMap<>(clusteringOrders) : Collections.emptyMap();
4146
this.secondaryIndexNames =
42-
secondaryIndexNames != null ? secondaryIndexNames : Collections.emptySet();
43-
this.columns = columns != null ? columns : Collections.emptyMap();
47+
secondaryIndexNames != null ? new HashSet<>(secondaryIndexNames) : Collections.emptySet();
48+
this.columns = columns != null ? new HashMap<>(columns) : Collections.emptyMap();
4449
}
4550

4651
public ObjectStorageTableMetadata(TableMetadata tableMetadata) {

core/src/main/java/com/scalar/db/storage/objectstorage/blob/BlobWrapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ public void update(String key, String object, String version)
119119
|| e.getErrorCode().equals(BlobErrorCode.BLOB_NOT_FOUND)) {
120120
throw new PreconditionFailedException(
121121
String.format(
122-
String.format(
123-
"Failed to update the object with key '%s' due to precondition failure", key)),
122+
"Failed to update the object with key '%s' due to precondition failure", key),
124123
e);
125124
}
126125
throw new ObjectStorageWrapperException(

0 commit comments

Comments
 (0)