-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-27206 Clean up error-prone findings in hbase-common #4645
Conversation
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Left a few comments.
Thanks @apurtell for the hard work!
hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java
Outdated
Show resolved
Hide resolved
hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java
Outdated
Show resolved
Hide resolved
hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
Show resolved
Hide resolved
private byte[] keyOnlyBuffer; | ||
private short rowLength; | ||
private int familyOffset; | ||
private byte familyLength; | ||
private int qualifierOffset; | ||
private int qualifierLength; | ||
private long timestamp; | ||
private long timeStamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think timestamp is a valid word in English?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an instance of the error-prone warning about inconsistent caps with respect to the field name and getter/setter or constructor parameter name. https://github.com/google/error-prone/blob/master/docs/bugpattern/InconsistentCapitalization.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Searched our code base, there are bunch of mixed TimeStamp and Timestamp usages... We even have code like this:
.setTimestampsOfLastAppliedOp(rls.getTimeStampsOfLastAppliedOp())
And in the same protobuf message, we have mixed style of timestamps...
message ReplicationLoadSink {
required uint64 ageOfLastAppliedOp = 1;
required uint64 timeStampsOfLastAppliedOp = 2;
// The below two were added after hbase-2.0.0 went out. They have to be added as 'optional' else
// we break upgrades; old RegionServers reporting in w/ old forms of this message will fail to
// deserialize on the new Master. See HBASE-25234
optional uint64 timestampStarted = 3;
optional uint64 totalOpsProcessed = 4;
}
So I tend to leave it as it for now. Maybe we should start a discussion thread on the dev list on how to better fix these problems...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not change the public method declaration I think it is fine. Can discuss this later.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.java
Show resolved
Hide resolved
hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractByteRange.java
Outdated
Show resolved
Hide resolved
hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java
Outdated
Show resolved
Hide resolved
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Pair.java
Outdated
Show resolved
Hide resolved
hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java
Show resolved
Hide resolved
hbase-common/src/main/java/org/apache/hadoop/hbase/util/WindowMovingAverage.java
Show resolved
Hide resolved
Rebase. Address review feedback. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
hbase-server results here are probably not related, but it is a bit hard to say. There are two tracing related flakes. /cc @ndimiduk There was a timed out test, but I don't know which one, but I did disable a known hang just today so another run might be cleaner. |
Let me rebase and push to trigger another run. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Thanks for pointing these out, I see the logs. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@@ -2345,7 +2342,7 @@ public static void setTimestamp(Cell cell, long ts) throws IOException { | |||
} | |||
|
|||
/** | |||
* Sets the given timestamp to the cell. n * @param ts buffer containing the timestamp value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that these comment lines starting with n
are left-overs from the auto-formatting tool getting confused by newline characters.
@@ -519,6 +519,7 @@ protected OffheapDecodedExtendedCell(ByteBuffer keyBuffer, short rowLength, int | |||
} | |||
|
|||
@Override | |||
@SuppressWarnings("ByteBufferBackingArray") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with ErrorProne that this use of a ByteBuffer
is problematic. We're leaving it to the caller to perform bounds checking but they don't have the underlying keyBuffer
.
Keep the warnings so that we don't lose track of this issue?
@@ -31,6 +31,7 @@ | |||
* The values in the enum appear in the order they appear in a version 2 HFile. | |||
*/ | |||
@InterfaceAudience.Private | |||
@SuppressWarnings("ImmutableEnumChecker") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the warning specify the point of mutability? A quick scan here and I don't see any state mutations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is because the 'magic' field. It is a byte array, the content can be changed at runtime.
@@ -38,6 +38,7 @@ | |||
*/ | |||
@InterfaceAudience.Private | |||
@InterfaceStability.Stable | |||
@SuppressWarnings({ "unchecked", "rawtypes", "hiding", "TypeParameterShadowing" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes!
@@ -58,6 +58,7 @@ | |||
@edu.umd.cs.findbugs.annotations.SuppressWarnings( | |||
value = "EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS", | |||
justification = "It has been like this forever") | |||
@SuppressWarnings("MixedMutabilityReturnType") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method returns both mutable and immutable collections or maps from different paths. This may be confusing for users of the method.
Yeah, that's a fair description.
// using linux bash commands to retrieve info | ||
Process p = Runtime.getRuntime() | ||
.exec(new String[] { "bash", "-c", "ls /proc/" + pidhost[0] + "/fdinfo | wc -l" }); | ||
.exec(new String[] { "bash", "-c", "ls /proc/" + pidhost.next() + "/fdinfo | wc -l" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be looking under /proc/self
instead of parsing the pid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done as a separated issue, not an error prone related problem.
Thanks for putting time into this cleanup, @apurtell . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blocker then. Let's get this merged first.
Thanks @apurtell for taking care of this!
private byte[] keyOnlyBuffer; | ||
private short rowLength; | ||
private int familyOffset; | ||
private byte familyLength; | ||
private int qualifierOffset; | ||
private int qualifierLength; | ||
private long timestamp; | ||
private long timeStamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not change the public method declaration I think it is fine. Can discuss this later.
@@ -31,6 +31,7 @@ | |||
* The values in the enum appear in the order they appear in a version 2 HFile. | |||
*/ | |||
@InterfaceAudience.Private | |||
@SuppressWarnings("ImmutableEnumChecker") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is because the 'magic' field. It is a byte array, the content can be changed at runtime.
// using linux bash commands to retrieve info | ||
Process p = Runtime.getRuntime() | ||
.exec(new String[] { "bash", "-c", "ls /proc/" + pidhost[0] + "/fdinfo | wc -l" }); | ||
.exec(new String[] { "bash", "-c", "ls /proc/" + pidhost.next() + "/fdinfo | wc -l" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done as a separated issue, not an error prone related problem.
try { | ||
for (Cell k : set) { | ||
assertTrue("count=" + count + ", " + k.toString(), count++ == k.getTimestamp()); | ||
for (Cell k : set) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could try to use assertThrows in the future. Not a blocker.
expectedAssert(() -> testReadAndWrite(array, 4096, cap - 4096 + 1, (byte) 16)); | ||
|
||
// XXX: These cases were apparently expected to assert but expectedAssert() was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops.
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit fbe3b90) Conflicts: hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestOrderedFloat32.java
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit fbe3b90) Conflicts: hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestOrderedFloat32.java
No description provided.