[ https://issues.apache.org/jira/browse/HADOOP-16218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16804906#comment-16804906 ]
Gabor Bota edited comment on HADOOP-16218 at 3/29/19 12:31 PM: --------------------------------------------------------------- Here is my opinion and justification about the other findbugs issues: * *Null passed for non-null parameter of com.google.common.base.Preconditions.checkState(boolean, String, Object, Object, Object) in org.apache.hadoop.hdfs.qjournal.server.Journal.getPersistedPaxosData(long)* In {{org/apache/hadoop/hdfs/qjournal/server/Journal.java:1064}} we call {code:java} Preconditions.checkState(ret != null && ret.getSegmentState().getStartTxId() == segmentTxId, "Bad persisted data for segment %s: %s ; journal id: %s", segmentTxId, ret, journalId); {code} for this call findbug assumes that {{Argument 4 might be null but must not be null}}, but Guava 27.0's {{com.google.common.base.Preconditions#checkState(boolean, java.lang.String, java.lang.Object, java.lang.Object, java.lang.Object)}} is annotated like the following: {code:java} public static void checkState( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2, @Nullable Object p3) { {code} so we have {{@Nullable}} on each parameter for the method. I don't see this warning as justified, or need to be fixed. * *Null passed for non-null parameter of com.google.common.base.Preconditions.checkArgument(boolean, String, Object) in org.apache.hadoop.hdfs.qjournal.server.JournalNode.getLogDir(String, String)* In org/apache/hadoop/hdfs/qjournal/server/JournalNode.java:325 we call {code:java} Preconditions.checkArgument(jid != null && !jid.isEmpty(), "bad journal identifier: %s", jid); {code} for this call findbug assumes that {{Argument 3 might be null but must not be null}}, but Guava 27.0's {{com.google.common.base.Preconditions#checkArgument(boolean, java.lang.String, java.lang.Object)}} is annotated like the following: {code:java} public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) { {code} so we have {{@Nullable}} on argument 3, and that renders the assumption incorrect. * *Nullcheck of jid at line 346 of value previously dereferenced in org.apache.hadoop.hdfs.qjournal.server.JournalNode.getLogDir(String, String)* This is about the {{assert jid != null;}} at JournalNode.java:346. IMHO that check is for devs to inform that the variable can't be null at that point - so just for visibility. I would leave it as is, it's not a redundant check, just additional information. (I'm not a fan of using {{assert}} in production code, but if it's there we can leave it). was (Author: gabor.bota): I'm checking these findbug issues, and I don't see why the first is breaking: * *Null passed for non-null parameter of com.google.common.base.Preconditions.checkState(boolean, String, Object, Object, Object) in org.apache.hadoop.hdfs.qjournal.server.Journal.getPersistedPaxosData(long)* In {{org/apache/hadoop/hdfs/qjournal/server/Journal.java:1064}} we call {code:java} Preconditions.checkState(ret != null && ret.getSegmentState().getStartTxId() == segmentTxId, "Bad persisted data for segment %s: %s ; journal id: %s", segmentTxId, ret, journalId); {code} for this call findbug assumes that {{Argument 4 might be null but must not be null}}, but Guava 27.0's {{com.google.common.base.Preconditions#checkState(boolean, java.lang.String, java.lang.Object, java.lang.Object, java.lang.Object)}} is annotated like the following: {code:java} public static void checkState( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2, @Nullable Object p3) { {code} so we have {{@Nullable}} on each parameter for the method. I don't see this warning as justified, or need to be fixed. * *Null passed for non-null parameter of com.google.common.base.Preconditions.checkArgument(boolean, String, Object) in org.apache.hadoop.hdfs.qjournal.server.JournalNode.getLogDir(String, String)* In org/apache/hadoop/hdfs/qjournal/server/JournalNode.java:325 we call {code:java} Preconditions.checkArgument(jid != null && !jid.isEmpty(), "bad journal identifier: %s", jid); {code} for this call findbug assumes that {{Argument 3 might be null but must not be null}}, but Guava 27.0's {{com.google.common.base.Preconditions#checkArgument(boolean, java.lang.String, java.lang.Object)}} is annotated like the following: {code:java} public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) { {code} so we have {{@Nullable}} on argument 3, and that renders the assumption incorrect. * *Nullcheck of jid at line 346 of value previously dereferenced in org.apache.hadoop.hdfs.qjournal.server.JournalNode.getLogDir(String, String)* This is about the {{assert jid != null;}} at JournalNode.java:346. IMHO that check is for devs to inform that the variable can't be null at that point - so just for visibility. I would leave it as is, it's not a redundant check, just additional information. (I'm not a fan of using {{assert}} in production code, but if it's there we can leave it). > findbugs warning of null param to non-nullable method in Configuration with > Guava update > ---------------------------------------------------------------------------------------- > > Key: HADOOP-16218 > URL: https://issues.apache.org/jira/browse/HADOOP-16218 > Project: Hadoop Common > Issue Type: Sub-task > Components: build > Affects Versions: 3.3.0 > Reporter: Steve Loughran > Assignee: Steve Loughran > Priority: Minor > > Findbugs is fussing over some unchanged code in configuration > {code} > Null passed for non-null parameter of writeXml(String, Writer) in > org.apache.hadoop.conf.Configuration.writeXml(Writer) > Bug type NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS (click for details) > In class org.apache.hadoop.conf.Configuration > In method org.apache.hadoop.conf.Configuration.writeXml(Writer) > Called method org.apache.hadoop.conf.Configuration.writeXml(String, Writer) > At Configuration.java:[line 3490] > Argument 1 is definitely null but must not be null > Definite null passed to dangerous method call target > org.apache.hadoop.conf.Configuration.writeXml(String, Writer) > {code} > Code looks fine; it's invoking Guava.Strings for the check for string == > empty-or-null; maybe something changed there. > Proposed: add @Nullable in Configuration writeXml -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org