[ 
https://issues.apache.org/jira/browse/SLIDER-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15378959#comment-15378959
 ] 

Gour Saha commented on SLIDER-1153:
-----------------------------------

[~jianhe] I think we should take care of these.

{code}
819          ProviderRole dynamicRole = createDynamicProviderRole(newName, 
name, component);
{code}
The above can throw NPE, since component can be null in the previous 
_resources.getComponent_ call. We just have to check for null before this call 
and throw a _BadConfigException_.

{code}
 836        roleHistory.addNewRole(roleStatus);
{code}
For this also we should check if _*roleHistory != null*_ just like in the if 
block in line 823. See the method _buildRoleRequirementsFromResources_ is being 
called by method _buildInstance_ in line 552 but _roleHistory_ actually gets 
initialized much later in line 571. So NPE can occur.

{code}
3795      Path subPath = new Path(path1, appReport.getApplicationId().toString()
3796          + "/agent");
{code}
We need to take care of this in _SliderClient.java_ just like you did it for 
the other one in line 3679.


> Code issues - 14 null pointer deferences found
> ----------------------------------------------
>
>                 Key: SLIDER-1153
>                 URL: https://issues.apache.org/jira/browse/SLIDER-1153
>             Project: Slider
>          Issue Type: Bug
>          Components: other
>    Affects Versions: Slider 0.91
>            Reporter: Gour Saha
>            Assignee: Jian He
>             Fix For: Slider 1.0.0
>
>         Attachments: SLIDER-1153.1.patch
>
>
> Following possible null pointer dereferences found in the code needs to be 
> fixed.
> h6. 
> slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
> {code}
> 819          ProviderRole dynamicRole = createDynamicProviderRole(newName, 
> name, component);
> {code}
> dereference: Dereferencing a pointer that might be null component when 
> calling createDynamicProviderRole
> {code}
>  836        roleHistory.addNewRole(roleStatus);
> {code}
> null_method_call: Calling a method on null object roleHistory
> {code}
> 1290      return roleHistory.requestContainerForRole(role).getIssuedRequest();
> {code}
> null_method_call: Calling a method on null object 
> roleHistory.requestContainerForRole(role)
> h6. slider-core/src/main/java/org/apache/slider/client/SliderClient.java
> {code}
> 960      char[] newPassword2 = br.readLine().toCharArray();
> {code}
> null_method_call: Calling a method on null object br.readLine()
> {code}
> 3679        Path subPath = new Path(path1, 
> appReport.getApplicationId().toString()
> 3680            + "/agent");
> {code}
> null_method_call: Calling a method on null object appReport.
> {code}
> 3795      Path subPath = new Path(path1, 
> appReport.getApplicationId().toString()
> 3796          + "/agent");
> 3797      imagePath = subPath.toString();
> {code}
> null_method_call: Calling a method on null object appReport.
> h6. slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
> {code}
> 1035    return !(address.getHostString().equals("0.0.0.0"));
> {code}
> null_method_call: Calling a method on null object address.getHostString()
> {code}
> 1422    for (String entry : confDirEntries) {
> {code}
> null_array_length: Accessing length of null array confDirEntries
> h6. 
> slider-core/src/main/java/org/apache/slider/common/tools/CoreFileSystem.java
> {code}
> 682      Path[] localFilePaths = new Path[localFiles.length];
> {code}
> null_array_length: Accessing length of null array localFiles
> h6. 
> slider-core/src/main/java/org/apache/slider/server/services/security/FsDelegationTokenManager.java
> {code}
> 159            tokenExpiryTime = CredentialUtils.getTokenExpiryTime(token);
> {code}
> dereference: Dereferencing a pointer that might be null token when calling 
> getTokenExpiryTime
> {code}
> 237        currentUser.addToken(token.getService(), token);
> {code}
> null_method_call: Calling a method on null object token
> h6. 
> slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java
> {code}
> 237    result = cd.toJsonString();
> {code}
> null_method_call: Calling a method on null object cd
> h6. 
> slider-core/src/main/java/org/apache/slider/server/appmaster/actions/RenewingAction.java
> {code}
>  66    Preconditions.checkArgument(action != null, "null actions");
> {code}
> check_after_deref: Null-checking action suggests that it may be null, but it 
> has already been dereferenced on all paths leading to the check.
> h6. 
> slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java
> {code}
> 70    this.applicationAttemptId = 
> report.getCurrentApplicationAttemptId().toString();
> {code}
> null_method_call: Calling a method on null object 
> report.getCurrentApplicationAttemptId()



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to