Skip to content

Conversation

@vibhatha
Copy link
Collaborator

@vibhatha vibhatha commented Sep 11, 2024

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

@vibhatha vibhatha changed the title [Java] Finalize ErrorProne Warnings to be considered as Errors #44055 GH-44055: [Java] Finalize ErrorProne Warnings to be considered as Errors Sep 11, 2024
@github-actions github-actions bot added the awaiting review Awaiting review label Sep 11, 2024
@vibhatha vibhatha marked this pull request as ready for review September 13, 2024 08:29
@vibhatha vibhatha requested a review from lidavidm as a code owner September 13, 2024 08:29
*/
package org.apache.arrow.flight;

import com.google.common.base.Splitter;
Copy link
Member

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?

Copy link
Collaborator Author

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")
Copy link
Member

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

Copy link
Collaborator Author

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")
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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

Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Member

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.

Comment on lines +73 to +74
throw new RuntimeException(
"Failed to initialize AddWritableBuffer, falling back to slow path", ex);
Copy link
Member

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

Comment on lines +50 to +51
throw new RuntimeException(
"Failed to initialize GetReadableBuffer, falling back to slow path", e);
Copy link
Member

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));
Copy link
Member

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")
Copy link
Member

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()));
Copy link
Member

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(
Copy link
Member

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)) {
Copy link
Member

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

Copy link
Collaborator Author

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.

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 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.

Copy link
Member

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.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Sep 13, 2024
Copy link
Member

@danepitkin danepitkin left a 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)) {
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 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)) {
Copy link
Member

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")
Copy link
Member

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")
Copy link
Member

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;
Copy link
Member

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">
Copy link
Member

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")
Copy link
Member

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")
Copy link
Member

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")
Copy link
Member

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")
Copy link
Member

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);
Copy link
Member

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() {
Copy link
Member

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));
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

2.5f

Copy link
Member

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)) {
Copy link
Member

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)) {
Copy link
Member

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) {
Copy link
Member

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() {
Copy link
Member

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...

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Sep 15, 2024
@github-actions
Copy link

⚠️ GitHub issue #44055 has no components, please add labels for components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants