[
https://issues.apache.org/jira/browse/HADOOP-17689?focusedWorklogId=595235&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-595235
]
ASF GitHub Bot logged work on HADOOP-17689:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 12/May/21 11:52
Start Date: 12/May/21 11:52
Worklog Time Spent: 10m
Work Description: virajjasani opened a new pull request #3008:
URL: https://github.com/apache/hadoop/pull/3008
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 595235)
Remaining Estimate: 0h
Time Spent: 10m
> Avoid Potential NPE in org.apache.hadoop.fs
> -------------------------------------------
>
> Key: HADOOP-17689
> URL: https://issues.apache.org/jira/browse/HADOOP-17689
> Project: Hadoop Common
> Issue Type: Bug
> Components: fs
> Reporter: Error Reporter
> Assignee: Viraj Jasani
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/
> Hello,
> Our code analyses found the following potential NPE:
>
> {code:java}
> public Path getParent() {
> String path = uri.getPath();
> int lastSlash = path.lastIndexOf('/');
> int start = startPositionWithoutWindowsDrive(path);
> if ((path.length() == start) || // empty path
> (lastSlash == start && path.length() == start+1)) { // at root
> return null;
> }
> {code}
>
> {code:java}
> public FSDataOutputStream createInternal (Path f,
> EnumSet<CreateFlag> flag, FsPermission absolutePermission, int
> bufferSize,
> short replication, long blockSize, Progressable progress,
> ChecksumOpt checksumOpt, boolean createParent) throws IOException {
> checkPath(f);
>
> // Default impl assumes that permissions do not matter
> // calling the regular create is good enough.
> // FSs that implement permissions should override this. if
> (!createParent) { // parent must exist.
> // since this.create makes parent dirs automatically
> // we must throw exception if parent does not exist.
> final FileStatus stat = getFileStatus(f.getParent()); // NPE!
> if (stat == null) {
> throw new FileNotFoundException("Missing parent:" + f);
> }
> {code}
> Full Trace:
> 1. Return null to caller
> https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java#L432
> 2. The return value of function getParent is used as the 1st parameter in
> function getFileStatus (the return value of function getParent can be null)
> https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java#L93
> 3. f is used as the 1st parameter in function checkPath (f can be null)
> https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java#L127
> 4. path is passed as the this pointer to function toUri (path can be null)
> https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L369
> Commit: f40e3eb0590f85bb42d2471992bf5d524628fdd6
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]