Prevent NullPointerException in assertExceptionMessage
@@ -44,6 +44,7 @@ import java.util.OptionalLong;
import static com.facebook.presto.sql.SqlFormatter.formatSql;
import static com.facebook.presto.transaction.TransactionBuilder.transaction;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.airlift.testing.Closeables.closeAllRuntimeException;
import static java.lang.String.format;
@@ -243,7 +244,7 @@ public abstract class AbstractTestQueryFramework
private static void assertExceptionMessage(String sql, Exception exception, @Language("RegExp") String regex)
{
- if (!exception.getMessage().matches(regex)) {
+ if (!nullToEmpty(exception.getMessage()).matches(regex)) {
fail(format("Expected exception message '%s' to match '%s' for query: %s", exception.getMessage(), regex, sql), exception);
}
}
