HDFS-6068. Disallow snapshot names that are also invalid directory names. Contributed by sathish
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1579004 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bd98fa152d
commit
02b25ce4ef
@ -415,6 +415,9 @@ Release 2.4.0 - UNRELEASED
|
||||
HDFS-6090. Use MiniDFSCluster.Builder instead of deprecated constructors.
|
||||
(Akira AJISAKA via jing9)
|
||||
|
||||
HDFS-6068. Disallow snapshot names that are also invalid directory names.
|
||||
(sathish via szetszwo)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery
|
||||
|
@ -6933,6 +6933,12 @@ String createSnapshot(String snapshotRoot, String snapshotName)
|
||||
if (snapshotName == null || snapshotName.isEmpty()) {
|
||||
snapshotName = Snapshot.generateDefaultSnapshotName();
|
||||
}
|
||||
if(snapshotName != null){
|
||||
if (!DFSUtil.isValidNameForComponent(snapshotName)) {
|
||||
throw new InvalidPathException("Invalid snapshot name: "
|
||||
+ snapshotName);
|
||||
}
|
||||
}
|
||||
dir.verifySnapshotName(snapshotName, snapshotRoot);
|
||||
dir.writeLock();
|
||||
try {
|
||||
|
@ -337,12 +337,11 @@ public void testCreateSnapshotWithIllegalName() throws Exception {
|
||||
hdfs.createSnapshot(dir, name1);
|
||||
fail("Exception expected when an illegal name is given");
|
||||
} catch (RemoteException e) {
|
||||
String errorMsg = "\"" + HdfsConstants.DOT_SNAPSHOT_DIR
|
||||
+ "\" is a reserved name.";
|
||||
String errorMsg = "Invalid path name Invalid snapshot name: " + name1;
|
||||
GenericTestUtils.assertExceptionContains(errorMsg, e);
|
||||
}
|
||||
|
||||
String errorMsg = "Snapshot name cannot contain \"" + Path.SEPARATOR + "\"";
|
||||
|
||||
final String[] badNames = new String[] { "foo" + Path.SEPARATOR,
|
||||
Path.SEPARATOR + "foo", Path.SEPARATOR, "foo" + Path.SEPARATOR + "bar" };
|
||||
for (String badName : badNames) {
|
||||
@ -350,6 +349,7 @@ public void testCreateSnapshotWithIllegalName() throws Exception {
|
||||
hdfs.createSnapshot(dir, badName);
|
||||
fail("Exception expected when an illegal name is given");
|
||||
} catch (RemoteException e) {
|
||||
String errorMsg = "Invalid path name Invalid snapshot name: " + badName ;
|
||||
GenericTestUtils.assertExceptionContains(errorMsg, e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user