Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop throwing errors on blank log messages #17058

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,21 @@ private void validateGELFMessage(JsonNode jsonNode, UUID id, ResolvableInetSocke

final JsonNode shortMessageNode = jsonNode.path("short_message");
final JsonNode messageNode = jsonNode.path("message");
String message = shortMessageNode.asText();

Choose a reason for hiding this comment

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

This line can be removed, as far as I can see.

if (!shortMessageNode.isMissingNode()) {
if (!shortMessageNode.isTextual()) {
throw new IllegalArgumentException(prefix + "has invalid \"short_message\": " + shortMessageNode.asText());
}
if (StringUtils.isBlank(shortMessageNode.asText()) && StringUtils.isBlank(messageNode.asText())) {
throw new IllegalArgumentException(prefix + "has empty mandatory \"short_message\" field.");
String shortMessage = shortMessageNode.asText();

Choose a reason for hiding this comment

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

This is the same as message, isn't it? And, can it be null now we know that shortMessageNode is textual?

if (shortMessage == null && message == null) {
throw new IllegalArgumentException(prefix + "mandatory \"short_message\" field is null.");
}
} else if (!messageNode.isMissingNode()) {
if (!messageNode.isTextual()) {
throw new IllegalArgumentException(prefix + "has invalid \"message\": " + messageNode.asText());
}
if (StringUtils.isBlank(messageNode.asText())) {
throw new IllegalArgumentException(prefix + "has empty mandatory \"message\" field.");
if (message == null) {

Choose a reason for hiding this comment

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

Should this not be if (messageNode.asText() == null)? And, can it be null at all now we know messageNode is textual?

throw new IllegalArgumentException(prefix + "mandatory \"message\" field is null.");
}
} else {
throw new IllegalArgumentException(prefix + "is missing mandatory \"short_message\" or \"message\" field.");
Expand Down