Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions server/src/main/java/com/cloud/api/ApiServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,14 @@

final Long snapshotLimit = ConcurrentSnapshotsThresholdPerHost.value();
if (snapshotLimit == null || snapshotLimit <= 0) {
logger.debug("Global concurrent snapshot config parameter " + ConcurrentSnapshotsThresholdPerHost.value() + " is less or equal 0; defaulting to unlimited");
logger.debug("Global concurrent snapshot config parameter {} is less or equal 0; defaulting to unlimited", ConcurrentSnapshotsThresholdPerHost.value());

Check warning on line 456 in server/src/main/java/com/cloud/api/ApiServer.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/ApiServer.java#L456

Added line #L456 was not covered by tests
} else {
dispatcher.setCreateSnapshotQueueSizeLimit(snapshotLimit);
}

final Long migrationLimit = VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value();
if (migrationLimit == null || migrationLimit <= 0) {
logger.debug("Global concurrent migration config parameter " + VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value() + " is less or equal 0; defaulting to unlimited");
logger.debug("Global concurrent migration config parameter {} is less or equal 0; defaulting to unlimited", VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value());

Check warning on line 463 in server/src/main/java/com/cloud/api/ApiServer.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/ApiServer.java#L463

Added line #L463 was not covered by tests
} else {
dispatcher.setMigrateQueueSizeLimit(migrationLimit);
}
Expand Down Expand Up @@ -626,7 +626,7 @@
for (final Object key : params.keySet()) {
final String keyStr = (String)key;
final String[] value = (String[])params.get(key);
logger.trace(" key: " + keyStr + ", value: " + ((value == null) ? "'null'" : value[0]));
logger.trace(" key: {}, value: {}", keyStr, (value == null) ? "'null'" : value[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.trace(" key: {}, value: {}", keyStr, (value == null) ? "'null'" : value[0]);
logger.trace(" key: {}, value: {}", keyStr, () -> (value == null) ? "'null'" : value[0]);

Since this is on trace (rarely used) It would be better to pass a lambda function that will me evaluated only if trace is on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! Just to confirm, I saw we are using Log4j 2.19.0, it doesn't support lambda directly, but it does support Supplier, which should work the same.

}
}
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "Invalid request, no command sent");
Expand Down Expand Up @@ -686,7 +686,7 @@
buf.append(obj.getUuid());
buf.append(" ");
}
logger.info("PermissionDenied: " + ex.getMessage() + " on objs: [" + buf + "]");
logger.info("PermissionDenied: {} on objs: [{}]", ex.getMessage(), buf);

Check warning on line 689 in server/src/main/java/com/cloud/api/ApiServer.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/ApiServer.java#L689

Added line #L689 was not covered by tests
} else {
logger.info("PermissionDenied: {}", ex.getMessage());
}
Expand Down Expand Up @@ -1011,7 +1011,7 @@

// if api/secret key are passed to the parameters
if ((signature == null) || (apiKey == null)) {
logger.debug("Expired session, missing signature, or missing apiKey -- ignoring request. Signature: " + signature + ", apiKey: " + apiKey);
logger.debug("Expired session, missing signature, or missing apiKey -- ignoring request. Signature: {}, apiKey: {}", signature, apiKey);

Check warning on line 1014 in server/src/main/java/com/cloud/api/ApiServer.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/ApiServer.java#L1014

Added line #L1014 was not covered by tests
return false; // no signature, bad request
}

Expand Down Expand Up @@ -1234,7 +1234,7 @@
float offsetInHrs = 0f;
if (timezone != null) {
final TimeZone t = TimeZone.getTimeZone(timezone);
logger.info("Current user logged in under " + timezone + " timezone");
logger.info("Current user logged in under {} timezone", timezone);

Check warning on line 1237 in server/src/main/java/com/cloud/api/ApiServer.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/ApiServer.java#L1237

Added line #L1237 was not covered by tests

final java.util.Date date = new java.util.Date();
final long longDate = date.getTime();
Expand Down Expand Up @@ -1386,9 +1386,9 @@
final Boolean apiSourceCidrChecksEnabled = ApiServiceConfiguration.ApiSourceCidrChecksEnabled.value();

if (apiSourceCidrChecksEnabled) {
logger.debug("CIDRs from which account '" + account.toString() + "' is allowed to perform API calls: " + accessAllowedCidrs);
logger.debug("CIDRs from which account '{}' is allowed to perform API calls: {}", account.toString(), accessAllowedCidrs);

Check warning on line 1389 in server/src/main/java/com/cloud/api/ApiServer.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/ApiServer.java#L1389

Added line #L1389 was not covered by tests
if (!NetUtils.isIpInCidrList(remoteAddress, accessAllowedCidrs.split(","))) {
logger.warn("Request by account '" + account.toString() + "' was denied since " + remoteAddress + " does not match " + accessAllowedCidrs);
logger.warn("Request by account '{}' was denied since {} does not match {}", account.toString(), remoteAddress, accessAllowedCidrs);

Check warning on line 1391 in server/src/main/java/com/cloud/api/ApiServer.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/ApiServer.java#L1391

Added line #L1391 was not covered by tests
throw new OriginDeniedException("Calls from disallowed origin", account, remoteAddress);
}
}
Expand Down
Loading