Skip to content

Commit 191245d

Browse files
author
klaus.freitas.scclouds
committed
fixing log refactor lambdas
1 parent c552c97 commit 191245d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.apache.cloudstack.utils.security.KeyStoreUtils;
5656
import org.apache.commons.collections.CollectionUtils;
5757
import org.apache.commons.io.FileUtils;
58+
import org.apache.commons.lang.ObjectUtils;
5859
import org.apache.commons.lang3.StringUtils;
5960
import org.apache.logging.log4j.Logger;
6061
import org.apache.logging.log4j.LogManager;
@@ -182,7 +183,7 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour
182183

183184
final String value = _shell.getPersistentProperty(getResourceName(), "id");
184185
_id = value != null ? Long.parseLong(value) : null;
185-
logger.info("id is {}", () -> (_id != null ? _id : ""));
186+
logger.info("id is {}", ObjectUtils.defaultIfNull(_id, ""));
186187

187188
final Map<String, Object> params = new HashMap<>();
188189

@@ -211,8 +212,8 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour
211212
new ThreadPoolExecutor(_shell.getWorkers(), 5 * _shell.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(
212213
"agentRequest-Handler"));
213214

214-
logger.info("Agent [id = {} : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}", () -> (_id != null ? _id : "new"), () -> getResourceName(),
215-
() -> _shell.getZone(), () -> _shell.getPod(), () -> _shell.getWorkers(), () -> host, () -> _shell.getPort());
215+
logger.info("Agent [id = {} : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}", ObjectUtils.defaultIfNull(_id, "new"), getResourceName(),
216+
_shell.getZone(), _shell.getPod(), _shell.getWorkers(), host, _shell.getPort());
216217
}
217218

218219
public String getVersion() {
@@ -312,7 +313,7 @@ public void start() {
312313
}
313314

314315
public void stop(final String reason, final String detail) {
315-
logger.info("Stopping the agent: Reason = {}", () -> reason + (detail != null ? ": Detail = " + detail : ""));
316+
logger.info("Stopping the agent: Reason = {}", reason + ObjectUtils.defaultIfNull(": Detail = " + detail, ""));
316317
_reconnectAllowed = false;
317318
if (_connection != null) {
318319
final ShutdownCommand cmd = new ShutdownCommand(reason, detail);
@@ -1034,7 +1035,7 @@ public WatchTask(final Link link, final Request request, final Agent agent) {
10341035

10351036
@Override
10361037
protected void runInContext() {
1037-
logger.trace("Scheduling {}", () -> (_request instanceof Response ? "Ping" : "Watch Task"));
1038+
logger.trace("Scheduling {}", (_request instanceof Response ? "Ping" : "Watch Task"));
10381039
try {
10391040
if (_request instanceof Response) {
10401041
_ugentTaskPool.submit(new ServerHandler(Task.Type.OTHER, _link, _request));

0 commit comments

Comments
 (0)