fanshilun created YARN-11324:
--------------------------------

             Summary: [Federation] Fix some PBImpl classes may have null 
pointer exception.
                 Key: YARN-11324
                 URL: https://issues.apache.org/jira/browse/YARN-11324
             Project: Hadoop YARN
          Issue Type: Bug
          Components: federation, router, yarn
    Affects Versions: 3.4.0
            Reporter: fanshilun
            Assignee: fanshilun
         Attachments: image-2022-09-30-16-52-25-031.png

When completing YARN-11323, I found that there is a bug in 
ApplicationHomeSubClusterPBImpl, which may cause a null pointer exception when 
getting getApplicationId
{code:java}
@Test
public void testGetApplicationIdNullException() throws YarnException {
  ApplicationId appId = ApplicationId.newInstance(Time.now(), 1);
  ApplicationHomeSubCluster appHomeSC = ApplicationHomeSubCluster.newInstance(
      appId, subClusterId);
  System.out.println(appHomeSC.getApplicationId());
} {code}
The test results are as follows:

!image-2022-09-30-16-52-25-031.png|width=818,height=271!

 

After we set the ApplicationId, direct get will get a null value.

*Why this problem occurs?*

The reason for this problem is because we did not set a value for 
ApplicationHomeSubClusterProtoOrBuilder when we setApplication

*Improve the code:*

1.set a value for ApplicationHomeSubClusterProtoOrBuilder when we 
setApplication.

2. At the same time, in order to improve the access efficiency, we should first 
check whether the internal property is empty when getApplication. If it is not 
empty, we can return it directly. If it is empty, we convert it from the proto 
object.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to