Skip to content

Commit

Permalink
AnsibleRunnerClient: make 'mapper' a scoped object
Browse files Browse the repository at this point in the history
There's no reason to keep the 'mapper' as part of 'AnsibleRunnerClient's
state - let's make it a local var.

Signed-off-by: Marcin Sobczyk <msobczyk@redhat.com>
  • Loading branch information
tinez committed Jul 21, 2022
1 parent f0051f4 commit 060d482
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@
@Singleton
public class AnsibleRunnerClient {
private static Logger log = LoggerFactory.getLogger(AnsibleRunnerClient.class);
private ObjectMapper mapper;
private AnsibleRunnerLogger runnerLogger;
private String lastEvent = "";
private static final int POLL_INTERVAL = 3000;
private AnsibleReturnValue returnValue;

public AnsibleRunnerClient() {
this.mapper = JsonMapper
.builder()
.findAndAddModules()
.build()
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
this.returnValue = new AnsibleReturnValue(AnsibleReturnCode.ERROR);
}

Expand Down Expand Up @@ -253,6 +247,11 @@ public void runPlaybook(List<String> command, int timeout, String uuid) throws E
protected String formatCommandVariables(Map<String, Object> variables, String playAction) {
String result;
try {
ObjectMapper mapper = JsonMapper
.builder()
.findAndAddModules()
.build()
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
result = mapper.writeValueAsString(variables);
} catch (IOException ex) {
throw new AnsibleRunnerCallException("Failed to create host deploy variables mapper", ex);
Expand Down

0 comments on commit 060d482

Please sign in to comment.