-
Notifications
You must be signed in to change notification settings - Fork 4.7k
HIVE-28888: Fix spotbugs issues in hive-storage-api and hive-service-rpc with spotbugs-maven-plugin 4.8.6.6 #5754
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
base: master
Are you sure you want to change the base?
Conversation
…y found spotbugs in the active modules
…en-plugin 4.8.6.6
7f9a0c9
to
8471979
Compare
1dce396
to
156ef37
Compare
…en-plugin 4.8.6.6
f88d053
to
4754a6c
Compare
public static ValidReadTxnList fromValue(String value) { | ||
ValidReadTxnList txnList = new ValidReadTxnList(); | ||
txnList.readFromString(value); | ||
return txnList; |
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 assume this is for CT_CONSTRUCTOR_THROW, as far as I tested it locally
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.
Yes, this change is as well to address CT_CONSTRUCTOR_THROW spotbug.
Jenkinsfile
Outdated
@@ -267,7 +264,7 @@ if [ $n != 0 ]; then | |||
exit 1 | |||
fi | |||
''' | |||
buildHive("-Pspotbugs -pl " + spotbugsProjects.join(",") + " -am test-compile com.github.spotbugs:spotbugs-maven-plugin:4.0.0:check") | |||
buildHive("-Pspotbugs -pl " + spotbugsProjects.join(",") + " -am test-compile com.github.spotbugs:spotbugs-maven-plugin:4.8.6.6:check") |
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.
buildHive("-Pspotbugs -pl " + spotbugsProjects.join(",") + " -am test-compile com.github.spotbugs:spotbugs-maven-plugin:4.8.6.6:check") | |
buildHive("-Pspotbugs -pl " + spotbugsProjects.join(",") + " -am test-compile com.github.spotbugs:spotbugs-maven-plugin:4.8.6.6:check") |
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.
Thanks for pointing this out, made this change in be7e285
Jenkinsfile
Outdated
":hive-storage-api", | ||
":hive-service-rpc" |
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.
":hive-storage-api", | |
":hive-service-rpc" | |
":hive-storage-api", | |
":hive-service-rpc" |
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.
Thanks for pointing this out as well, made this change in be7e285
@@ -329,20 +331,19 @@ public static void mergeBloomFilterBytes( | |||
* for index bounds nor expand the bit set size if the specified index is greater than the size. | |||
*/ | |||
static class BitSet { | |||
private final long[] data; |
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 we can keep this final. The new Spot bugs fail if the constructor might fail. If it never fails, it is ok.
// make it private
private BitSet(long[] data) {
this.data = data; // without assert here
}
public static BitSet build(long[] data) {
assert data.length > 0 : "data length is zero!";
return new BitSet(data);
}
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.
Yes. This is definitely a better approach to solve this spotbug. Thanks for the suggestion. i have made the change in be7e285
@@ -59,32 +60,44 @@ private static void checkArgument(boolean expression, String message) { | |||
} | |||
} | |||
|
|||
public BloomKFilter(long maxNumEntries) { | |||
public BloomKFilter(int k, long m, int totalBlockCount, long[] arr) { |
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.
public BloomKFilter(int k, long m, int totalBlockCount, long[] arr) { | |
private BloomKFilter(int k, long m, int totalBlockCount, long[] arr) { |
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.
Made it private in be7e285
@@ -397,21 +410,14 @@ public static byte[] getInitialBytes(long expectedEntries) { | |||
* for index bounds nor expand the bit set size if the specified index is greater than the size. | |||
*/ | |||
public static class BitSet { | |||
private final long[] data; | |||
private long[] data; |
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 can be final maybe
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.
Yes. Made the field private as well as changed the constructor/build method similar to your suggested change for BloomFilter Bitset class. Change made in be7e285
Thanks. From my point of view, we'll have to do the following things when we close this pull request.
I assume this PR includes HIVE-28888, HIVE-28889 and HIVE-28893. I expect the remaining tickets, meaning HIVE-28890, HIVE-28891, and HIVE-28892, not to be included. I am thinking of consolidating tickets like below, keeping 1-1 mapping between PR and JIRA[1].
Also, I added some minor comments. I ran spot bugs on my local machine with this change, and I've not seen any issues so far. Thanks!
|
@okumin |
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.
@tanishq-chugh Thank you! Only one point. Could you please remove the unused import, import java.util.BitSet;
? SonarCloud reported the issue.
I speculatively give this PR +1. I will merge it once the code style issue is resolved and also CI succeeds.
@@ -26,6 +26,7 @@ | |||
import java.io.OutputStream; | |||
import java.nio.charset.StandardCharsets; | |||
import java.util.Arrays; | |||
import java.util.BitSet; |
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.
import java.util.BitSet; |
It looks like this is not used.
https://sonarcloud.io/project/issues?pullRequest=5754&open=AZYgu6tSMQfuFZWXHEBO&id=apache_hive
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 has been addressed in 3ab7cae
this.totalBlockCount = bitSet.data.length / DEFAULT_BLOCK_SIZE; | ||
} | ||
public static BloomKFilter build(long[] bits, int numFuncs) { | ||
checkArgument((bits.length % DEFAULT_BLOCK_SIZE) == 0, "bitSet has to be block aligned"); | ||
return new BloomKFilter(bits,numFuncs); |
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.
return new BloomKFilter(bits,numFuncs); | |
return new BloomKFilter(bits, numFuncs); |
Just align the style with other lines
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 has been addressed in 3ab7cae
|
What changes were proposed in this pull request?
Upgrade spotbugs-maven-plugin to 4.8.6.6
Why are the changes needed?
Upgraded plugin introduces new rules to identify potential bugs.
Does this PR introduce any user-facing change?
No
Is the change a dependency upgrade?
No, it is a plugin version upgrade.
How was this patch tested?
Locally, running spotbugs check and fixing the bugs, followed by running basic manual test on hive by building locally and running queries.