-
Notifications
You must be signed in to change notification settings - Fork 3.9k
GH-44055: [Java] Finalize ErrorProne Warnings to be considered as Errors #44056
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: main
Are you sure you want to change the base?
Conversation
| */ | ||
| package org.apache.arrow.flight; | ||
|
|
||
| import com.google.common.base.Splitter; |
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.
Ideally we wouldn't use Guava? I suppose as long as this interface seems stable...
Is there an apache-commons equivalent we can use?
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 will take a look, this was actually suggested by the ErrorProne library, it wasn't my first choice.
| return values()[s.getNumber()]; | ||
| } | ||
|
|
||
| @SuppressWarnings("EnumOrdinal") |
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.
IMO, the right way to do this would be to add a constructor and store the Protobuf enum value in the enum instance
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.
Right, that is the ideal way. Let me track down and change the similar other instances.
| } | ||
|
|
||
| /** Per-option extensible error response container. */ | ||
| @SuppressWarnings("JavaLangClash") |
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.
What was the problem here?
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.
It's clashing with java.lang.Error https://docs.oracle.com/javase/8/docs/api/java/lang/Error.html
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.
+1 for renaming it, if it's not an external API change in some way
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 is public, it will be a breaking change.
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.
Right, the issue is as @danepitkin mentioned. Shall we leave the warning suppressed?
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, let's leave the suppression in place.
| throw new RuntimeException( | ||
| "Failed to initialize AddWritableBuffer, falling back to slow path", ex); |
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 this intentionally did not throw, as evidenced by the "falling back" message
| throw new RuntimeException( | ||
| "Failed to initialize GetReadableBuffer, falling back to slow path", e); |
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.
Same here
| final Properties resultProperty = new Properties(); | ||
| properties.forEach((k, v) -> resultProperty.put(k.toString().toLowerCase(), v)); | ||
| properties.forEach( | ||
| (k, v) -> resultProperty.put(k.toString().toLowerCase(Locale.getDefault()), v)); |
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.
let's use Locale.ROOT rather than the system locale
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("BigDecimalEquals") |
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.
| Object value = properties.get(camelName); | ||
| if (value == null) { | ||
| value = properties.get(camelName.toLowerCase()); | ||
| value = properties.get(camelName.toLowerCase(Locale.getDefault())); |
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.
Locale.ROOT
| assertThat( | ||
| e.getMessage(), | ||
| is(format("Error while executing SQL \"%s\": Query not found", badQuery))); | ||
| is( |
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.
Would prefer contains
| */ | ||
| public void setParameters(final VectorSchemaRoot parameterBindingRoot) { | ||
| if (parameterBindingRoot == this.parameterBindingRoot) { | ||
| if (parameterBindingRoot.equals(this.parameterBindingRoot)) { |
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 this was intentionally an identity 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.
Right. I will leave it as it is, and add the suppressing.
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 would recommend adding a comment alongside warning suppressions for future readers. It's not always obvious if a Warning suppression is the result of a temporary bug, laziness from the developers (not you, just in general :P), or is truly an unhelpful warning.
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.
For example, we would never want to un-suppress this warning because we want to compare object references, but for the Flatbuffers module name warning in an older PR, we want to eventually remove it once fixed.
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.
Heroic effort 👏 Nice job @vibhatha.
| */ | ||
| public void setParameters(final VectorSchemaRoot parameterBindingRoot) { | ||
| if (parameterBindingRoot == this.parameterBindingRoot) { | ||
| if (parameterBindingRoot.equals(this.parameterBindingRoot)) { |
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 would recommend adding a comment alongside warning suppressions for future readers. It's not always obvious if a Warning suppression is the result of a temporary bug, laziness from the developers (not you, just in general :P), or is truly an unhelpful warning.
| */ | ||
| public void setParameters(final VectorSchemaRoot parameterBindingRoot) { | ||
| if (parameterBindingRoot == this.parameterBindingRoot) { | ||
| if (parameterBindingRoot.equals(this.parameterBindingRoot)) { |
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.
For example, we would never want to un-suppress this warning because we want to compare object references, but for the Flatbuffers module name warning in an older PR, we want to eventually remove it once fixed.
| private final JniWrapper wrapper; | ||
| private final long moduleId; | ||
|
|
||
| @SuppressWarnings("UnusedVariable") |
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 actually looks unused. It's private, and not used after object instantiation. Should we remove it?
| private JniWrapper wrapper; | ||
| private final long moduleId; | ||
|
|
||
| @SuppressWarnings("UnusedVariable") |
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.
We can probably delete this, too.
| private JdbcConsumer<BitVector> bitConsumer; | ||
|
|
||
| private JdbcToArrowConfig config; | ||
| // private JdbcToArrowConfig config; |
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 this be deleted?
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <compilerArgs combine.children="override"> |
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.
Are we trying to override and disable warnings-as-errors for this module? If so, it should be combine.self="override".
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("VoidUsed") |
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.
You could use vector.getUnderlyingVector().accept(this, null); and get rid of the suppressed warning.
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("VoidUsed") |
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.
same here. vector.getUnderlyingVector().accept(this, null);
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("VoidUsed") |
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.
and here
|
|
||
| @ParameterizedTest | ||
| @MethodSource("data") | ||
| @SuppressWarnings("BigDecimalEquals") |
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.
use compareTo
| public int hashCode() { | ||
| return Objects.hashCode(this.name.toLowerCase(), this.returnType, this.paramTypes); | ||
| return Objects.hashCode( | ||
| this.name.toLowerCase(Locale.getDefault()), this.returnType, this.paramTypes); |
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.
Locale.ROOT
| } | ||
|
|
||
| @Override | ||
| public String getMessage() { |
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.
Why is the trivial override needed?
| assertEquals(10, node.getIntNode().getValue()); | ||
|
|
||
| n = TreeBuilder.makeLiteral(new Long(50)); | ||
| n = TreeBuilder.makeLiteral(Long.valueOf(50)); |
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.
50L doesn't work?
| assertEquals(50, node.getLongNode().getValue()); | ||
|
|
||
| Float f = new Float(2.5); | ||
| Float f = (float) 2.5; |
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.
2.5f
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.
And does it need to be boxed?
|
|
||
| // copy the first bit set | ||
| if (input1 != output) { | ||
| if (!input1.equals(output)) { |
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.
Hmm, I wonder if this was intentional or not.
| private boolean compareField(Field leftField, Field rightField) { | ||
|
|
||
| if (leftField == rightField) { | ||
| if (leftField.equals(rightField)) { |
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 this was intentional: it's a cheap "is this actually the same object" check, before doing the rest of the checks below
|
|
||
| /** Check type equals without passing IN param in VectorVisitor. */ | ||
| @SuppressWarnings("NonOverridingEquals") | ||
| public boolean equals(ValueVector left) { |
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 shoulda been named something different but it's way too late now
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { |
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 is a mutable object, I'm not sure we want it to have a hashCode...
|
|
Rationale for this change
A series of PRs have been created to mark warnings as errors in a module-based approach. As this step has been completed, moving the config back to the parent pom would be the best to keep things clean and easy to maintain.
What changes are included in this PR?
Removing the pom changes in each module and updating the parent pom with the required configurations.
Are these changes tested?
Tested from existing test cases.
Are there any user-facing changes?
N/A