} else {
environmentMap.put(portVar, Long.toString(port));
environmentMap.put(dynamicVar, Boolean.toString(false));
}
taskBuilder = updatePort(taskBuilder, brokerConfig);
<BUG>cmdBuilder.clearEnvironment();
final List<Variable> newEnvironmentVariables = EnvironmentBuilder.createEnvironment(environmentMap);
cmdBuilder.setEnvironment(Environment.newBuilder().addAllVariables(newEnvironmentVariables));</BUG>
taskBuilder.setData(cmdBuilder.build().toByteString());
TaskInfo updatedTaskInfo = taskBuilder.build();

} else {
port = Long.parseLong(environmentMap.get(portVar));
}
environmentMap.put(dynamicVar, Boolean.toString(true));
brokerConfig.setPort(port);
} else {
environmentMap.put(portVar, Long.toString(port));
environmentMap.put(dynamicVar, Boolean.toString(false));
}
taskBuilder = updatePort(taskBuilder, brokerConfig);
cmdBuilder.clearEnvironment();
cmdBuilder.setEnvironment(environment(environmentMap));
taskBuilder.setData(cmdBuilder.build().toByteString());
TaskInfo updatedTaskInfo = taskBuilder.build();
