diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index e6d560a3579..c01e3d64e77 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -970,6 +970,9 @@ Release 2.7.0 - UNRELEASED HADOOP-11545. ArrayIndexOutOfBoundsException is thrown with "hadoop credential list -provider". (Brahma Reddy Battula via aajisaka) + HADOOP-11595. Add default implementation for AbstractFileSystem#truncate. + (yliu) + Release 2.6.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java index 975cc3cc87a..959d9d57e4d 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java @@ -642,9 +642,12 @@ public abstract class AbstractFileSystem { * {@link FileContext#truncate(Path, long)} except that Path f must be for * this file system. */ - public abstract boolean truncate(Path f, long newLength) + public boolean truncate(Path f, long newLength) throws AccessControlException, FileNotFoundException, - UnresolvedLinkException, IOException; + UnresolvedLinkException, IOException { + throw new UnsupportedOperationException(getClass().getSimpleName() + + " doesn't support truncate"); + } /** * The specification of this method matches that of diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAfsCheckPath.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAfsCheckPath.java index 6b9378d90aa..3bd14f1495a 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAfsCheckPath.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAfsCheckPath.java @@ -140,12 +140,6 @@ public class TestAfsCheckPath { return null; } - @Override - public boolean truncate(Path f, long newLength) throws IOException { - // deliberately empty - return false; - } - @Override public void renameInternal(Path src, Path dst) throws IOException { // deliberately empty