Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-turner committed Jun 27, 2024
2 parents 56b374d + fdd8ce3 commit f0e3849
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class Utils {
private static final byte[] ZERO_BYTE = {'0'};
private static final Logger log = LoggerFactory.getLogger(Utils.class);

/**
* Checks that a table name is only used by the specified table id or not used at all.
*/
public static void checkTableNameDoesNotExist(ServerContext context, String tableName,
TableId tableId, TableOperation operation) throws AcceptableThriftTableOperationException {

Expand All @@ -72,7 +75,7 @@ public static void checkTableNameDoesNotExist(ServerContext context, String tabl
byte[] tname = context.getZooReader().getData(zTablePath + Constants.ZTABLE_NAME);
Preconditions.checkState(tname != null, "Malformed table entry in ZooKeeper at %s",
zTablePath);
if (tableName.equals(new String(tname, UTF_8))) {
if (tableName.equals(new String(tname, UTF_8)) && !tableId.equals(TableId.of(tid))) {
throw new AcceptableThriftTableOperationException(tid, tableName, operation,
TableOperationExceptionType.EXISTS, null);
}
Expand Down

0 comments on commit f0e3849

Please sign in to comment.