Skip to content

Commit

Permalink
Change file exist exception to runtime exception in PagedDoraWorker
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?

The `RuntimeException(FileAlreadyExistException)` changed to `AlreadyExistException()` in `PagedDoraWorker`

### Why are the changes needed?

`RuntimeException(FileAlreadyExistException)` seems won't be caught in `DoraWorkerClientServiceHandler` when convertin it to `AlluxioRuntimeException`, which willl cause the loss status code

### Does this PR introduce any user facing changes?

no

			pr-link: Alluxio#18337
			change-id: cid-9a520c49579847bae6da21302f484ba713eeb4d9
  • Loading branch information
voddle authored and ssz1997 committed Dec 15, 2023
1 parent dc949f1 commit 920c664
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import alluxio.conf.Configuration;
import alluxio.conf.PropertyKey;
import alluxio.exception.AccessControlException;
import alluxio.exception.FileAlreadyExistsException;
import alluxio.exception.runtime.AlluxioRuntimeException;
import alluxio.exception.runtime.FailedPreconditionRuntimeException;
import alluxio.exception.runtime.UnavailableRuntimeException;
import alluxio.exception.status.AlreadyExistsException;
import alluxio.exception.status.FailedPreconditionException;
import alluxio.grpc.Command;
import alluxio.grpc.CommandType;
Expand Down Expand Up @@ -879,9 +879,8 @@ public OpenFileHandle createFile(String path, CreateFilePOptions options)
boolean overWrite = options.hasOverwrite() ? options.getOverwrite() : false;
boolean exists = ufs.exists(path);
if (!overWrite && exists) {
throw new RuntimeException(
new FileAlreadyExistsException(
String.format("File %s already exists but no overwrite flag", path)));
throw new AlreadyExistsException(String.format("File %s already exists"
+ "but no overwrite flag", path));
} else if (overWrite) {
// client is going to overwrite this file. We need to invalidate the cached meta and data.
mMetaManager.removeFromMetaStore(path);
Expand Down Expand Up @@ -1010,11 +1009,11 @@ public void createDirectory(String path, CreateDirectoryPOptions options)
mMetaManager.loadFromUfs(path);
mMetaManager.invalidateListingCacheOfParent(path);
if (!success) {
throw new RuntimeException(
new FileAlreadyExistsException(String.format("%s already exists", path)));
throw new AlreadyExistsException(String.format("%s already exists", path));
}
} catch (IOException e) {
throw new RuntimeException(e);
// IOE would be caught by AlluxioRuntimeException
throw e;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testMkdirExisting() {
assertEquals(0, mFsShell.run("mkdir", uri.toString()));
assertEquals(-1, mFsShell.run("mkdir", uri.toString()));
assertTrue(
mOutput.toString().contains("UNKNOWN: alluxio.exception.FileAlreadyExistsException"));
mOutput.toString().contains("ALREADY_EXISTS"));
}

@Test
Expand All @@ -76,7 +76,7 @@ public void testMkdirPathWithWhiteSpaces() throws Exception {
public void testMkdirInvalidPath() {
assertEquals(-1, mFsShell.run("mkdir", ""));
assertTrue(
mOutput.toString().contains("UNKNOWN: alluxio.exception.FileAlreadyExistsException"));
mOutput.toString().contains("ALREADY_EXISTS"));
}

@Test
Expand Down

0 comments on commit 920c664

Please sign in to comment.