2121import java .io .DataOutput ;
2222import java .io .IOException ;
2323
24- import org .apache .commons .logging .Log ;
25- import org .apache .commons .logging .LogFactory ;
2624import org .apache .hadoop .conf .Configuration ;
2725import org .apache .hadoop .fs .CommonConfigurationKeys ;
2826import org .apache .hadoop .io .Writable ;
3331 * A class for file/directory permissions.
3432 */
3533public class FsPermission implements Writable {
36- private static final Log LOG = LogFactory .getLog (FsPermission .class );
37-
3834 static final WritableFactory FACTORY = new WritableFactory () {
3935 public Writable newInstance () { return new FsPermission (); }
4036 };
@@ -182,7 +178,8 @@ public FsPermission applyUMask(FsPermission umask) {
182178 otheraction .and (umask .otheraction .not ()));
183179 }
184180
185- /** umask property label Deprecated key may be removed in version .23 */
181+ /** umask property label deprecated key and code in getUMask method
182+ * to accommodate it may be removed in version .23 */
186183 public static final String DEPRECATED_UMASK_LABEL = "dfs.umask" ;
187184 public static final String UMASK_LABEL =
188185 CommonConfigurationKeys .FS_PERMISSIONS_UMASK_KEY ;
@@ -198,10 +195,19 @@ public static FsPermission getUMask(Configuration conf) {
198195 if (conf != null ) {
199196 String confUmask = conf .get (UMASK_LABEL );
200197 if (confUmask != null ) { // UMASK_LABEL is set
201- if (conf .deprecatedKeyWasSet (DEPRECATED_UMASK_LABEL ))
202- umask = Integer .parseInt (confUmask ); // Evaluate as decimal value
203- else
204- umask = new UmaskParser (confUmask ).getUMask ();
198+ try {
199+ if (conf .deprecatedKeyWasSet (DEPRECATED_UMASK_LABEL ))
200+ umask = Integer .parseInt (confUmask ); // Evaluate as decimal value
201+ else
202+ umask = new UmaskParser (confUmask ).getUMask ();
203+ } catch (IllegalArgumentException iae ) {
204+ // Provide more explanation for user-facing message
205+ String type = iae instanceof NumberFormatException ? "decimal"
206+ : "octal or symbolic" ;
207+
208+ throw new IllegalArgumentException ("Unable to parse " + confUmask +
209+ " as " + type + " umask." );
210+ }
205211 }
206212 }
207213
0 commit comments