diff --git a/CHANGES.txt b/CHANGES.txt index 24da48af1d..13e9d404db 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -76,8 +76,6 @@ Trunk (unreleased changes) HADOOP-6687. user object in the subject in UGI should be reused in case of a relogin. (jnp via boryas) - HADOOP-6796. FileStatus allows null srcPath but crashes if that's done. (Rodrigo Schmidt via eli) - HADOOP-6603. Provide workaround for issue with Kerberos not resolving cross-realm principal (Kan Zhang and Jitendra Pandey via jghoman) diff --git a/src/java/org/apache/hadoop/fs/FileStatus.java b/src/java/org/apache/hadoop/fs/FileStatus.java index 3e8d4138b9..38a4d353e2 100644 --- a/src/java/org/apache/hadoop/fs/FileStatus.java +++ b/src/java/org/apache/hadoop/fs/FileStatus.java @@ -33,19 +33,19 @@ @InterfaceStability.Stable public class FileStatus implements Writable, Comparable { - private Path path = null; - private long length = 0; - private boolean isdir = false; - private short block_replication = 0; - private long blocksize = 0; - private long modification_time = 0; - private long access_time = 0; - private FsPermission permission = null; - private String owner = null; - private String group = null; - private Path symlink = null; + private Path path; + private long length; + private boolean isdir; + private short block_replication; + private long blocksize; + private long modification_time; + private long access_time; + private FsPermission permission; + private String owner; + private String group; + private Path symlink; - public FileStatus() {} + public FileStatus() { this(0, false, 0, 0, 0, 0, null, null, null, null); } //We should deprecate this soon? public FileStatus(long length, boolean isdir, int block_replication, @@ -67,12 +67,6 @@ public FileStatus(long length, boolean isdir, access_time, permission, owner, group, null, path); } - private void stateSanityCheck() { - if (path == null) { - throw new IllegalArgumentException("path cannot be null"); - } - } - public FileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, @@ -91,7 +85,6 @@ public FileStatus(long length, boolean isdir, this.group = (group == null) ? "" : group; this.symlink = symlink; this.path = path; - stateSanityCheck(); } /** diff --git a/src/test/core/org/apache/hadoop/fs/TestFileStatus.java b/src/test/core/org/apache/hadoop/fs/TestFileStatus.java deleted file mode 100644 index d6ec99b6f8..0000000000 --- a/src/test/core/org/apache/hadoop/fs/TestFileStatus.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.fs; - -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.apache.hadoop.fs.permission.FsPermission; - -public class TestFileStatus { - - @Test - public void testFileStatusNullPath() throws Exception { - - new FileStatus(); - new FileStatus(1,false,3,3,4, new Path("/")); new FileStatus(1,false,5,3,4,5,null,null,null,new Path("/a/b")); - new FileStatus(1,false,5,3,4,5,null,null,null,null,new Path("/a/b")); - new FileStatus(1,false,5,3,4,5,new FsPermission((short) 7), - "bla","bla",new Path ("/b/c"), new Path("/a/b")); - - boolean error = false; - try{ - new FileStatus(1,false,3,3,4, null); - } catch (IllegalArgumentException exc) { - error = true; - } - - assertTrue("Accepted null path", error); - - try { - new FileStatus(1,false,5,3,4,5,null,null,null,null); - } catch (IllegalArgumentException exc) { - error = true; - } - - assertTrue("Accepted null path",error); - - try { - new FileStatus(1,false,5,3,4,5,null,null,null,null,null); - } catch (IllegalArgumentException exc) { - error = true; - } - - assertTrue("Accepted null path",error); - - try { - new FileStatus(1,false,5,3,4,5,new FsPermission((short) 7), - "bla","bla",new Path ("/b/c"), null); - } catch (IllegalArgumentException exc) { - error = true; - } - - assertTrue("Accepted null path",error); - - } -}