Skip to content

Commit

Permalink
fix(expressions): Apparently the getMessage() of an exception can b…
Browse files Browse the repository at this point in the history
…e null

… which is bad when you then generate an NPE in the finally block of some error handling code.
  • Loading branch information
robfletcher committed Mar 23, 2018
1 parent 14d8030 commit ce9ae65
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

package com.netflix.spinnaker.orca.pipeline.expressions;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParserContext;
import org.springframework.expression.common.CompositeStringExpression;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static java.lang.String.format;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
Expand Down Expand Up @@ -100,7 +102,7 @@ public <T> T transform(T source, EvaluationContext evaluationContext, Expression
Object fields = !keys.isEmpty() ? keys : literalExpression;
String errorDescription = format("Failed to evaluate %s ", fields);
Throwable originalException = unwrapOriginalException(exception);
if (originalException == null || originalException.getMessage().contains(exception.getMessage())) {
if (originalException == null || originalException.getMessage() == null || originalException.getMessage().contains(exception.getMessage())) {
errorDescription += exception.getMessage();
} else {
errorDescription += originalException.getMessage() + " - " + exception.getMessage();
Expand Down

0 comments on commit ce9ae65

Please sign in to comment.