From 1a49f14408fb647d3658b21bdb14479e31dce380 Mon Sep 17 00:00:00 2001 From: Vikram Bohra Date: Tue, 19 Nov 2024 10:12:29 -0800 Subject: [PATCH] Strip endpoint instead of appending during prefix comparison --- .../tables/utils/TableUUIDGenerator.java | 22 ++++++------------- .../TableUUIDGeneratorMultiStorageTest.java | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/services/tables/src/main/java/com/linkedin/openhouse/tables/utils/TableUUIDGenerator.java b/services/tables/src/main/java/com/linkedin/openhouse/tables/utils/TableUUIDGenerator.java index 8c79f6fe..1850d64c 100644 --- a/services/tables/src/main/java/com/linkedin/openhouse/tables/utils/TableUUIDGenerator.java +++ b/services/tables/src/main/java/com/linkedin/openhouse/tables/utils/TableUUIDGenerator.java @@ -193,24 +193,16 @@ private Optional extractUUIDFromRequestBody( } Storage storage = catalog.resolveStorage(TableIdentifier.of(databaseId, tableId)); - java.nio.file.Path databaseDirPath; - if (StringUtils.isNotEmpty(storage.getClient().getEndpoint())) { - databaseDirPath = - Paths.get( - storage.getClient().getEndpoint(), storage.getClient().getRootPrefix(), databaseId); - } else { - databaseDirPath = Paths.get(storage.getClient().getRootPrefix(), databaseId); - } - + java.nio.file.Path databaseDirPath = Paths.get(storage.getClient().getRootPrefix(), databaseId); + ; String manifestListKey = "manifest-list"; java.nio.file.Path manifestListPath; try { - manifestListPath = - Paths.get( - new Gson() - .fromJson(snapshotStr, JsonObject.class) - .get(manifestListKey) - .getAsString()); + String manifestListPathString = + new Gson().fromJson(snapshotStr, JsonObject.class).get(manifestListKey).getAsString(); + manifestListPathString = + StringUtils.removeStart(manifestListPathString, storage.getClient().getEndpoint()); + manifestListPath = Paths.get(manifestListPathString); } catch (Exception exception) { throw new RequestValidationFailureException( String.format( diff --git a/services/tables/src/test/java/com/linkedin/openhouse/tables/mock/uuid/TableUUIDGeneratorMultiStorageTest.java b/services/tables/src/test/java/com/linkedin/openhouse/tables/mock/uuid/TableUUIDGeneratorMultiStorageTest.java index fcf34912..c5513ba8 100644 --- a/services/tables/src/test/java/com/linkedin/openhouse/tables/mock/uuid/TableUUIDGeneratorMultiStorageTest.java +++ b/services/tables/src/test/java/com/linkedin/openhouse/tables/mock/uuid/TableUUIDGeneratorMultiStorageTest.java @@ -82,7 +82,7 @@ private String getTableLocation( String tableLocationWithoutEndpoint = String.format("%s/%s/%s-%s", rootPrefix, databaseId, tableId, tableUUID.toString()); if (StringUtils.isNotEmpty(endPoint)) { - return String.format("%s/%s", endPoint, tableLocationWithoutEndpoint); + return String.format("%s%s", endPoint, tableLocationWithoutEndpoint); } return tableLocationWithoutEndpoint;