Skip to content

Commit b3086f8

Browse files
committed
HADOOP-4326. ChecksumFileSystem does not override create(...) correctly. (szetszwo)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.17@701443 13f79535-47bb-0310-9956-ffa450edef68
1 parent b9b88c5 commit b3086f8

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Release 0.17.3 - Unreleased
1212

1313
HADOOP-4318. DistCp should use absolute paths for cleanup. (szetszwo)
1414

15+
HADOOP-4326. ChecksumFileSystem does not override create(...) correctly.
16+
(szetszwo)
17+
1518
Release 0.17.2 - 2008-08-11
1619

1720
BUG FIXES

src/java/org/apache/hadoop/fs/ChecksumFileSystem.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.commons.logging.Log;
2626
import org.apache.commons.logging.LogFactory;
2727
import org.apache.hadoop.conf.Configuration;
28+
import org.apache.hadoop.fs.permission.FsPermission;
2829
import org.apache.hadoop.util.Progressable;
2930
import org.apache.hadoop.util.StringUtils;
3031

@@ -341,28 +342,22 @@ protected void writeChunk(byte[] b, int offset, int len, byte[] checksum)
341342
}
342343
}
343344

344-
/**
345-
* Opens an FSDataOutputStream at the indicated Path with write-progress
346-
* reporting.
347-
* @param f the file name to open
348-
* @param overwrite if a file with this name already exists, then if true,
349-
* the file will be overwritten, and if false an error will be thrown.
350-
* @param bufferSize the size of the buffer to be used.
351-
* @param replication required block replication for the file.
352-
*/
345+
/** {@inheritDoc} */
353346
@Override
354-
public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize,
355-
short replication, long blockSize, Progressable progress)
356-
throws IOException {
347+
public FSDataOutputStream create(Path f, FsPermission permission,
348+
boolean overwrite, int bufferSize, short replication, long blockSize,
349+
Progressable progress) throws IOException {
357350
Path parent = f.getParent();
358351
if (parent != null && !mkdirs(parent)) {
359352
throw new IOException("Mkdirs failed to create " + parent);
360353
}
361-
return new FSDataOutputStream
362-
(new ChecksumFSOutputSummer
363-
(this, f, overwrite, bufferSize, replication,
364-
blockSize, progress),
365-
null);
354+
final FSDataOutputStream out = new FSDataOutputStream(
355+
new ChecksumFSOutputSummer(this, f, overwrite, bufferSize, replication,
356+
blockSize, progress), null);
357+
if (permission != null) {
358+
setPermission(f, permission);
359+
}
360+
return out;
366361
}
367362

368363
/**

src/test/org/apache/hadoop/dfs/TestFSInputChecker.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.hadoop.fs.FileSystem;
2929
import org.apache.hadoop.fs.LocalFileSystem;
3030
import org.apache.hadoop.fs.Path;
31+
import org.apache.hadoop.fs.permission.FsPermission;
3132
import org.apache.hadoop.io.IOUtils;
3233

3334
/**
@@ -48,9 +49,9 @@ public class TestFSInputChecker extends TestCase {
4849
/* create a file */
4950
private void writeFile(FileSystem fileSys, Path name) throws IOException {
5051
// create and write a file that contains three blocks of data
51-
FSDataOutputStream stm = fileSys.create(name, true,
52-
fileSys.getConf().getInt("io.file.buffer.size", 4096),
53-
NUM_OF_DATANODES, BLOCK_SIZE);
52+
FSDataOutputStream stm = fileSys.create(name, new FsPermission((short)0777),
53+
true, fileSys.getConf().getInt("io.file.buffer.size", 4096),
54+
(short)NUM_OF_DATANODES, BLOCK_SIZE, null);
5455
stm.write(expected);
5556
stm.close();
5657
}

0 commit comments

Comments
 (0)