[jira] [Commented] (HADOOP-17686) Potential NPE in org.apache.hadoop.fs.obs

2021-05-11 Thread Viraj Jasani (Jira)


[ 
https://issues.apache.org/jira/browse/HADOOP-17686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17342353#comment-17342353
 ] 

Viraj Jasani commented on HADOOP-17686:
---

[~aajisaka] Would you like to take a look? It's a small fix. Thanks

> Potential NPE in org.apache.hadoop.fs.obs
> -
>
> Key: HADOOP-17686
> URL: https://issues.apache.org/jira/browse/HADOOP-17686
> Project: Hadoop Common
>  Issue Type: Bug
>  Components: fs
>Reporter: Error Reporter
>Assignee: Viraj Jasani
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hello,
> Our code analyses found a 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; <--- Null returned
> }
> {code}
>  
> {code:java}
> private static void getDirectories(final String key, final String sourceKey,
>   final Set directories) {
> Path p = new Path(key);
> Path sourcePath = new Path(sourceKey);
> // directory must add first
> if (key.endsWith("/") && p.compareTo(sourcePath) > 0) {
>   directories.add(p.toString());
> }
> while (p.compareTo(sourcePath) > 0) {
>   p = p.getParent(); <--- NPE
>   if (p.isRoot() || p.compareTo(sourcePath) == 0) {
> break;
>   }
> {code}
> Given a root path, it will lead to NPE at method getDirectories
>  
> 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. Function getParent executes and returns
> [https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java#L875]
> 3. The return value of function getParent is passed as the this pointer to 
> function isRoot (the return value of function getParent can be null)
> [https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java#L876]
> Commit: f40e3eb0590f85bb42d2471992bf5d524628fdd6



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[jira] [Commented] (HADOOP-17686) Potential NPE in org.apache.hadoop.fs.obs

2021-05-10 Thread Viraj Jasani (Jira)


[ 
https://issues.apache.org/jira/browse/HADOOP-17686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17341788#comment-17341788
 ] 

Viraj Jasani commented on HADOOP-17686:
---

[~smeng] [~tasanuma] Would you like to take a look at PR? It's a small fix.

Thanks

> Potential NPE in org.apache.hadoop.fs.obs
> -
>
> Key: HADOOP-17686
> URL: https://issues.apache.org/jira/browse/HADOOP-17686
> Project: Hadoop Common
>  Issue Type: Bug
>  Components: fs
>Reporter: Error Reporter
>Assignee: Viraj Jasani
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hello,
> Our code analyses found a 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; <--- Null returned
> }
> {code}
>  
> {code:java}
> private static void getDirectories(final String key, final String sourceKey,
>   final Set directories) {
> Path p = new Path(key);
> Path sourcePath = new Path(sourceKey);
> // directory must add first
> if (key.endsWith("/") && p.compareTo(sourcePath) > 0) {
>   directories.add(p.toString());
> }
> while (p.compareTo(sourcePath) > 0) {
>   p = p.getParent(); <--- NPE
>   if (p.isRoot() || p.compareTo(sourcePath) == 0) {
> break;
>   }
> {code}
> Given a root path, it will lead to NPE at method getDirectories
>  
> 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. Function getParent executes and returns
> [https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java#L875]
> 3. The return value of function getParent is passed as the this pointer to 
> function isRoot (the return value of function getParent can be null)
> [https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java#L876]
> Commit: f40e3eb0590f85bb42d2471992bf5d524628fdd6



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[jira] [Commented] (HADOOP-17686) Potential NPE in org.apache.hadoop.fs.obs

2021-05-09 Thread Viraj Jasani (Jira)


[ 
https://issues.apache.org/jira/browse/HADOOP-17686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17341662#comment-17341662
 ] 

Viraj Jasani commented on HADOOP-17686:
---

[~brahmareddy] [~brahma] Could you please take a look when you get time?

Thanks

> Potential NPE in org.apache.hadoop.fs.obs
> -
>
> Key: HADOOP-17686
> URL: https://issues.apache.org/jira/browse/HADOOP-17686
> Project: Hadoop Common
>  Issue Type: Bug
>  Components: fs
>Reporter: Error Reporter
>Assignee: Viraj Jasani
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hello,
> Our code analyses found a 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; <--- Null returned
> }
> {code}
>  
> {code:java}
> private static void getDirectories(final String key, final String sourceKey,
>   final Set directories) {
> Path p = new Path(key);
> Path sourcePath = new Path(sourceKey);
> // directory must add first
> if (key.endsWith("/") && p.compareTo(sourcePath) > 0) {
>   directories.add(p.toString());
> }
> while (p.compareTo(sourcePath) > 0) {
>   p = p.getParent(); <--- NPE
>   if (p.isRoot() || p.compareTo(sourcePath) == 0) {
> break;
>   }
> {code}
> Given a root path, it will lead to NPE at method getDirectories
>  
> 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. Function getParent executes and returns
> [https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java#L875]
> 3. The return value of function getParent is passed as the this pointer to 
> function isRoot (the return value of function getParent can be null)
> [https://github.com/apache/hadoop/blob/f40e3eb0590f85bb42d2471992bf5d524628fdd6/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java#L876]
> Commit: f40e3eb0590f85bb42d2471992bf5d524628fdd6



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org