Skip to content

Commit d64cf16

Browse files
committed
Apply suggestions
1 parent 32136f6 commit d64cf16

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,13 @@ public void deleteByPrefix_WithNonExistingPrefix_ShouldDoNothing() throws Except
279279

280280
@Test
281281
public void close_ShouldNotThrowException() {
282-
try {
283-
// Arrange
282+
// Arrange
283+
Properties properties = getProperties(TEST_NAME);
284+
ObjectStorageConfig objectStorageConfig =
285+
ObjectStorageUtils.getObjectStorageConfig(new DatabaseConfig(properties));
286+
ObjectStorageWrapper wrapper = ObjectStorageWrapperFactory.create(objectStorageConfig);
284287

285-
// Act Assert
286-
assertThatCode(() -> wrapper.close()).doesNotThrowAnyException();
287-
} finally {
288-
Properties properties = getProperties(TEST_NAME);
289-
ObjectStorageConfig objectStorageConfig =
290-
ObjectStorageUtils.getObjectStorageConfig(new DatabaseConfig(properties));
291-
wrapper = ObjectStorageWrapperFactory.create(objectStorageConfig);
292-
}
288+
// Act Assert
289+
assertThatCode(wrapper::close).doesNotThrowAnyException();
293290
}
294291
}

core/src/main/java/com/scalar/db/storage/objectstorage/s3/S3Config.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public S3Config(DatabaseConfig databaseConfig) {
4848
throw new IllegalArgumentException(CoreError.INVALID_CONTACT_POINTS.buildMessage());
4949
}
5050
String contactPoints = databaseConfig.getContactPoints().get(0);
51-
int lastSlashIndex = contactPoints.lastIndexOf('/');
52-
if (lastSlashIndex != -1 && lastSlashIndex < contactPoints.length() - 1) {
53-
region = contactPoints.substring(0, lastSlashIndex);
54-
bucket = contactPoints.substring(lastSlashIndex + 1);
51+
String[] contactPointsParts = contactPoints.split("/");
52+
if (contactPointsParts.length == 2
53+
&& !contactPointsParts[0].isEmpty()
54+
&& !contactPointsParts[1].isEmpty()) {
55+
region = contactPointsParts[0];
56+
bucket = contactPointsParts[1];
5557
} else {
5658
throw new IllegalArgumentException(
5759
"Invalid contact points format. Expected: S3_REGION/BUCKET_NAME");

0 commit comments

Comments
 (0)