Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.4.0
-
Reviewed
Description
When completing YARN-11323, I found that there is a bug in ApplicationHomeSubClusterPBImpl, which may cause a null pointer exception when getting getApplicationId
@Test public void testGetApplicationIdNullException() throws YarnException { ApplicationId appId = ApplicationId.newInstance(Time.now(), 1); ApplicationHomeSubCluster appHomeSC = ApplicationHomeSubCluster.newInstance( appId, subClusterId); System.out.println(appHomeSC.getApplicationId()); }
The test results are as follows:
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.
While modifying ApplicationHomeSubClusterImpl, I will check the pbImpl classes of all router modules to make sure all pbimpl are fixed.