Skip to content

Commit

Permalink
Fixed NPE on TriggerService.find when Trigger does not exist
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Sep 22, 2021
1 parent 7e7596e commit 3b1dc4f
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -44,6 +44,7 @@
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -313,7 +314,11 @@ public Trigger find(KapuaId scopeId, KapuaId triggerId) throws KapuaException {
//
// Do find
Trigger trigger = entityManagerSession.doAction(em -> TriggerDAO.find(em, scopeId, triggerId));
adaptTrigger(trigger);

if (trigger != null) {
adaptTrigger(trigger);
}

return trigger;
}

Expand Down Expand Up @@ -431,7 +436,7 @@ private void adaptTriggerCreator(TriggerCreator triggerCreator) throws KapuaExce
* @throws KapuaException In case that {@link TriggerDefinition} is not found.
* @since 1.1.0
*/
private void adaptTrigger(Trigger trigger) throws KapuaException {
private void adaptTrigger(@NotNull Trigger trigger) throws KapuaException {
boolean converted = false;
if (trigger.getRetryInterval() != null) {
trigger.setTriggerDefinitionId(getIntervalJobTriggerDefinition().getId());
Expand Down

0 comments on commit 3b1dc4f

Please sign in to comment.