Fix NPE on plugin specified templates (#3084)

(cherry picked from commit 2a2b55ceaf)
This commit is contained in:
Shrikant Sharat Kandula 2021-02-18 09:10:15 +05:30
parent 128444f46c
commit 60a4ddb3c1

View File

@ -58,6 +58,7 @@ import java.nio.charset.StandardCharsets;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -683,9 +684,11 @@ public class NewActionServiceImpl extends BaseService<NewActionRepository, NewAc
} else if (pluginType == PluginType.DB) { } else if (pluginType == PluginType.DB) {
requestData.putAll(Map.of( requestData.putAll(Map.of(
"query", ObjectUtils.defaultIfNull(actionConfiguration.getBody(), ""), "query", ObjectUtils.defaultIfNull(actionConfiguration.getBody(), ""),
"properties", actionConfiguration.getPluginSpecifiedTemplates() "properties", actionConfiguration.getPluginSpecifiedTemplates() == null
.stream() ? Collections.emptyMap()
.collect(Collectors.toMap(Property::getKey, Property::getValue)) : actionConfiguration.getPluginSpecifiedTemplates()
.stream()
.collect(Collectors.toMap(Property::getKey, Property::getValue))
)); ));
} }
@ -714,6 +717,10 @@ public class NewActionServiceImpl extends BaseService<NewActionRepository, NewAc
analyticsService.sendEvent(AnalyticsEvents.EXECUTE_ACTION.getEventName(), user.getUsername(), data); analyticsService.sendEvent(AnalyticsEvents.EXECUTE_ACTION.getEventName(), user.getUsername(), data);
return user; return user;
}) })
.onErrorResume(error -> {
log.warn("Error sending action execution data point", error);
return Mono.empty();
})
.then(); .then();
} }