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

fix: pass DCN_NULLPOINTER_EXCEPTION spotbugs error #8775

Merged
merged 1 commit into from
Feb 16, 2022
Merged
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 @@ -29,7 +29,6 @@
import java.io.InputStream;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.Random;
Expand Down Expand Up @@ -364,14 +363,20 @@ Arguments build() {
timestampColumnName = Optional.ofNullable(timestampColumnName).orElse(null);
}

try {
Objects.requireNonNull(schemaFile, "Schema file not provided");
Objects.requireNonNull(keyFormat, "Message key format not provided");
Objects.requireNonNull(valueFormat, "Message value format not provided");
Objects.requireNonNull(topicName, "Kafka topic name not provided");
Objects.requireNonNull(keyName, "Name of key column not provided");
} catch (final NullPointerException exception) {
throw new ArgumentParseException(exception.getMessage());
if (schemaFile == null) {
throw new ArgumentParseException("Schema file not provided");
}
if (keyFormat == null) {
throw new ArgumentParseException("Message key format not provided");
}
if (valueFormat == null) {
throw new ArgumentParseException("Message value format not provided");
}
if (topicName == null) {
throw new ArgumentParseException("Kafka topic name not provided");
}
if (keyName == null) {
throw new ArgumentParseException("Name of key column not provided");
Comment on lines +366 to +379
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to deduplicate code by having a method like

void requireArgumentsNotNull(final Object argument, final String errorMessage) {
    if (argument == null) {
        throw new ArgumentParseException(errorMessage);
    }
}

But I am also fine with this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll land this and follow up separately

}
return new Arguments(
help,
Expand Down