garydgregory commented on a change in pull request #114:
URL: https://github.com/apache/commons-vfs/pull/114#discussion_r477545412
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileObject.java
##########
@@ -67,7 +70,27 @@ protected HdfsFileObject(final AbstractFileName name, final
HdfsFileSystem fs, f
*/
@Override
public boolean canRenameTo(final FileObject newfile) {
- throw new UnsupportedOperationException();
+ if (!super.canRenameTo(newfile)) {
+ return false;
+ }
+
+ FileStatus newfileStat = null;
+ try {
+ newfileStat = this.hdfs.getFileStatus(new
Path(newfile.getName().getPath()));
+ } catch (final FileNotFoundException e) {
+ // do nothing
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
Review comment:
Throwing `RuntimeException` is an anti-pattern. Use
`IllegalArgumentException` or `IllegalStateException`.
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileObject.java
##########
@@ -67,7 +70,27 @@ protected HdfsFileObject(final AbstractFileName name, final
HdfsFileSystem fs, f
*/
@Override
public boolean canRenameTo(final FileObject newfile) {
- throw new UnsupportedOperationException();
+ if (!super.canRenameTo(newfile)) {
+ return false;
+ }
+
+ FileStatus newfileStat = null;
+ try {
+ newfileStat = this.hdfs.getFileStatus(new
Path(newfile.getName().getPath()));
+ } catch (final FileNotFoundException e) {
+ // do nothing
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
Review comment:
Why do this? Why not let it percolate up?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]