YARN-9197. Add safe guard against NPE for component instance failure.

Contributed by kyungwan nam
This commit is contained in:
Eric Yang 2019-01-18 13:49:56 -05:00
parent dacc1a759e
commit 8c7f6b2d4d
1 changed files with 6 additions and 2 deletions

View File

@ -350,8 +350,10 @@ public class ComponentInstance implements EventHandler<ComponentInstanceEvent>,
// record in ATS
LOG.info("Publishing component instance status {} {} ",
event.getContainerId(), containerState);
int exitStatus = failureBeforeLaunch || event.getStatus() == null ?
ContainerExitStatus.INVALID : event.getStatus().getExitStatus();
compInstance.serviceTimelinePublisher.componentInstanceFinished(
event.getContainerId(), event.getStatus().getExitStatus(),
event.getContainerId(), exitStatus,
containerState, containerDiag);
}
@ -366,8 +368,10 @@ public class ComponentInstance implements EventHandler<ComponentInstanceEvent>,
if (compInstance.timelineServiceEnabled) {
// record in ATS
int exitStatus = failureBeforeLaunch || event.getStatus() == null ?
ContainerExitStatus.INVALID : event.getStatus().getExitStatus();
compInstance.serviceTimelinePublisher.componentInstanceFinished(
event.getContainerId(), event.getStatus().getExitStatus(),
event.getContainerId(), exitStatus,
containerState, containerDiag);
}