Skip to content

Conversation

@ConeyLiu
Copy link
Contributor

@ConeyLiu ConeyLiu commented Nov 12, 2016

What changes were proposed in this pull request?

Small fix, fix the errors caused by lint check in Java

  • Clear unused objects and UnusedImports.
  • Add comments around the method finalize of NioBufferedFileInputStreamto turn off checkstyle.
  • Cut the line which is longer than 100 characters into two lines.

How was this patch tested?

Travis CI.

$ build/mvn -T 4 -q -DskipTests -Pyarn -Phadoop-2.3 -Pkinesis-asl -Phive -Phive-thriftserver install
$ dev/lint-java

Before:

Checkstyle checks failed at following occurrences:
[ERROR] src/main/java/org/apache/spark/network/util/TransportConf.java:[21,8] (imports) UnusedImports: Unused import - org.apache.commons.crypto.cipher.CryptoCipherFactory.
[ERROR] src/test/java/org/apache/spark/network/sasl/SparkSaslSuite.java:[516,5] (modifier) RedundantModifier: Redundant 'public' modifier.
[ERROR] src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java:[133] (coding) NoFinalizer: Avoid using finalizer method.
[ERROR] src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeMapData.java:[71] (sizes) LineLength: Line is longer than 100 characters (found 113).
[ERROR] src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeArrayData.java:[112] (sizes) LineLength: Line is longer than 100 characters (found 110).
[ERROR] src/test/java/org/apache/spark/sql/catalyst/expressions/HiveHasherSuite.java:[31,17] (modifier) ModifierOrder: 'static' modifier out of order with the JLS suggestions.
[ERROR]src/main/java/org/apache/spark/examples/ml/JavaLogisticRegressionWithElasticNetExample.java:[64] (sizes) LineLength: Line is longer than 100 characters (found 103).
[ERROR] src/main/java/org/apache/spark/examples/ml/JavaInteractionExample.java:[22,8] (imports) UnusedImports: Unused import - org.apache.spark.ml.linalg.Vectors.
[ERROR] src/main/java/org/apache/spark/examples/ml/JavaInteractionExample.java:[51] (regexp) RegexpSingleline: No trailing whitespace allowed.

After:

$ build/mvn -T 4 -q -DskipTests -Pyarn -Phadoop-2.3 -Pkinesis-asl -Phive -Phive-thriftserver install
$ dev/lint-java
Using `mvn` from path: /home/travis/build/ConeyLiu/spark/build/apache-maven-3.3.9/bin/mvn
Checkstyle checks passed.

@HyukjinKwon
Copy link
Member

Hi @ConeyLiu, It seems

[ERROR] src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java:[133] (coding) NoFinalizer: Avoid using finalizer method.

is missed. If it is a required change, I guess we should disable the lint check for the lines.

@ConeyLiu
Copy link
Contributor Author

@HyukjinKwon I'm sorry for that, I've fixed it, please take a look. Thanks a lot.

@srowen
Copy link
Member

srowen commented Nov 13, 2016

They're caused by lint right? not checkstyle? and these are only Java, because that's all that's not automatically tested. Please update the title/description with more meaningful details, including the JIRA.

Copy link
Member

Choose a reason for hiding this comment

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

Why was this removed? it needs to be here for sure

Copy link
Member

Choose a reason for hiding this comment

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

You made this non-static; that's not a style issue right? it may be OK but some of these changes don't seem to match the description

Copy link
Contributor Author

@ConeyLiu ConeyLiu Nov 13, 2016

Choose a reason for hiding this comment

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

@srowen I've updated, but It seems the hasher never used.

@ConeyLiu ConeyLiu changed the title [SPARK-18420]Fix the compile errors caused by checkstyle [SPARK-18420][SPARK][BUILD]Fix the compile errors caused by checkstyle Nov 13, 2016
@ConeyLiu
Copy link
Contributor Author

@srowen Thanks for the review, I've updated it.

@HyukjinKwon
Copy link
Member

HyukjinKwon commented Nov 14, 2016

@ConeyLiu Let us please change the title to something like [SPARK-18420][BUILD] Fix the errors caused by lint check in Java for this pull request and JIRA you opened. Also, it might be great if the descriptions in both this pull request and JIRA have more details about this.

Also, I think for the one below:

[ERROR] src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java:[133] (coding) NoFinalizer: Avoid using finalizer method.

we should disable the lint for the lines because it seems a required one. I guess you should disable the check for the lines or work around this.

Could we then remove hasher in HiveHasherSuite.java if it is not used? FWIW, I just checked that this private instance is not referred in HiveHasherSuite.java for sure.

Also, I have a link I usually refer, https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark

Maybe, this pull request and JIRA can be nicer if both follow the guild lines.

@ConeyLiu ConeyLiu changed the title [SPARK-18420][SPARK][BUILD]Fix the compile errors caused by checkstyle [SPARK-18420][BUILD] Fix the errors caused by lint check in Java Nov 14, 2016
@ConeyLiu
Copy link
Contributor Author

@HyukjinKwon Thanks for the review and suggestion, I've updated it. Clear the unused object hasher and add suppression rules for the method finalize of NioBufferedFileInputStream. Please take a look, thanks a lot.

Copy link
Member

@HyukjinKwon HyukjinKwon Nov 14, 2016

Choose a reason for hiding this comment

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

Ah, I thought we could disable it only for some lines like Scala/Python/R. I am fine with this if it is only the way.

Copy link
Contributor Author

@ConeyLiu ConeyLiu Nov 14, 2016

Choose a reason for hiding this comment

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

@HyukjinKwon Also we could try // style:off ... // style:on. I'll test this way.

@SparkQA
Copy link

SparkQA commented Nov 14, 2016

Test build #3425 has finished for PR 15865 at commit 39c2a85.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @ConeyLiu, it is a super minor but it seems we should make the indentation for this (and the same instances here) double-spaced. I at least could find some examples for this such as in UnsafeMemoryAllocator

    assert (memory.obj == null) :
      "baseObject not null; are you trying to use the off-heap allocator to free on-heap memory?";

or in ShuffleSortDataFormat

    assert (length <= buffer.size()) :
      "the buffer is smaller than required: " + buffer.size() + " < " + length;

Copy link
Member

Choose a reason for hiding this comment

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

If you are supposed to push more commits, let us revert this extra newline removal. I guess some guys don't like such changes. At least I was told twice before.

@HyukjinKwon
Copy link
Member

For sure, I ran

$ ./dev/lint-java
Using `mvn` from path: .../mvn
Checkstyle checks passed.

It seems fine. It looks good to me for few minor comments above.

@ConeyLiu
Copy link
Contributor Author

@HyukjinKwon I'm sorry for so late reply. I update the code and style followed by your suggestion, that's so useful. And also I change the method of disabling the check around finalize. Please take a loot or give some suggestion. Thanks a lot.

<property name="onCommentFormat" value="checkstyle.on\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>

Copy link
Member

@HyukjinKwon HyukjinKwon Nov 15, 2016

Choose a reason for hiding this comment

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

Ah, I am sorry @ConeyLiu. I should have taken a look ahead first. I actually rather meant agreeing with the previous state if we should introduce such new property... Although I (as just one of contributors) think this might be worth, maybe this should be handled in a different PR.

Maybe, I think we could keep this change and then propose a new separate PR later if other people also agree with this.

Let us maybe please revert this change back and move back to the state which Sean approved for sure (but including the indentation fixes and newline fix). I will try to run the lint for sure as soon as you do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, maybe we need more advices.

Copy link
Member

Choose a reason for hiding this comment

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

Ah OK, this is needed in order to implement a checkstyle:off for Java like we use scalastyle:off for Scala? that's fine to do here if so, because it seems like we need it to get past the finalizer issue. I think that's a fine general mechanism to enable.

@ConeyLiu
Copy link
Contributor Author

@srowen hi owen, Can you give me some advice, and if so, what a great thing.

<module name="UnusedImports"/>
<module name="RedundantImport"/>
<module name="RedundantModifier"/>
<module name="FileContentsHolder"/>
Copy link
Member

Choose a reason for hiding this comment

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

What is this needed for, the checkstyle:off mechanism?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HyukjinKwon
Copy link
Member

I just checked for sure.

$ ./dev/lint-java
Using `mvn` from path: .../mvn
Checkstyle checks passed.

@ConeyLiu
Copy link
Contributor Author

@HyukjinKwon @srowen Thank you very much.

@asfgit asfgit closed this in 7569cf6 Nov 16, 2016
asfgit pushed a commit that referenced this pull request Nov 16, 2016
Small fix, fix the errors caused by lint check in Java

- Clear unused objects and `UnusedImports`.
- Add comments around the method `finalize` of `NioBufferedFileInputStream`to turn off checkstyle.
- Cut the line which is longer than 100 characters into two lines.

Travis CI.
```
$ build/mvn -T 4 -q -DskipTests -Pyarn -Phadoop-2.3 -Pkinesis-asl -Phive -Phive-thriftserver install
$ dev/lint-java
```
Before:
```
Checkstyle checks failed at following occurrences:
[ERROR] src/main/java/org/apache/spark/network/util/TransportConf.java:[21,8] (imports) UnusedImports: Unused import - org.apache.commons.crypto.cipher.CryptoCipherFactory.
[ERROR] src/test/java/org/apache/spark/network/sasl/SparkSaslSuite.java:[516,5] (modifier) RedundantModifier: Redundant 'public' modifier.
[ERROR] src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java:[133] (coding) NoFinalizer: Avoid using finalizer method.
[ERROR] src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeMapData.java:[71] (sizes) LineLength: Line is longer than 100 characters (found 113).
[ERROR] src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeArrayData.java:[112] (sizes) LineLength: Line is longer than 100 characters (found 110).
[ERROR] src/test/java/org/apache/spark/sql/catalyst/expressions/HiveHasherSuite.java:[31,17] (modifier) ModifierOrder: 'static' modifier out of order with the JLS suggestions.
[ERROR]src/main/java/org/apache/spark/examples/ml/JavaLogisticRegressionWithElasticNetExample.java:[64] (sizes) LineLength: Line is longer than 100 characters (found 103).
[ERROR] src/main/java/org/apache/spark/examples/ml/JavaInteractionExample.java:[22,8] (imports) UnusedImports: Unused import - org.apache.spark.ml.linalg.Vectors.
[ERROR] src/main/java/org/apache/spark/examples/ml/JavaInteractionExample.java:[51] (regexp) RegexpSingleline: No trailing whitespace allowed.
```

After:
```
$ build/mvn -T 4 -q -DskipTests -Pyarn -Phadoop-2.3 -Pkinesis-asl -Phive -Phive-thriftserver install
$ dev/lint-java
Using `mvn` from path: /home/travis/build/ConeyLiu/spark/build/apache-maven-3.3.9/bin/mvn
Checkstyle checks passed.
```

Author: Xianyang Liu <[email protected]>

Closes #15865 from ConeyLiu/master.

(cherry picked from commit 7569cf6)
Signed-off-by: Sean Owen <[email protected]>
@srowen
Copy link
Member

srowen commented Nov 16, 2016

Merged to master/2.1

uzadude pushed a commit to uzadude/spark that referenced this pull request Jan 27, 2017
## What changes were proposed in this pull request?

Small fix, fix the errors caused by lint check in Java

- Clear unused objects and `UnusedImports`.
- Add comments around the method `finalize` of `NioBufferedFileInputStream`to turn off checkstyle.
- Cut the line which is longer than 100 characters into two lines.

## How was this patch tested?
Travis CI.
```
$ build/mvn -T 4 -q -DskipTests -Pyarn -Phadoop-2.3 -Pkinesis-asl -Phive -Phive-thriftserver install
$ dev/lint-java
```
Before:
```
Checkstyle checks failed at following occurrences:
[ERROR] src/main/java/org/apache/spark/network/util/TransportConf.java:[21,8] (imports) UnusedImports: Unused import - org.apache.commons.crypto.cipher.CryptoCipherFactory.
[ERROR] src/test/java/org/apache/spark/network/sasl/SparkSaslSuite.java:[516,5] (modifier) RedundantModifier: Redundant 'public' modifier.
[ERROR] src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java:[133] (coding) NoFinalizer: Avoid using finalizer method.
[ERROR] src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeMapData.java:[71] (sizes) LineLength: Line is longer than 100 characters (found 113).
[ERROR] src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeArrayData.java:[112] (sizes) LineLength: Line is longer than 100 characters (found 110).
[ERROR] src/test/java/org/apache/spark/sql/catalyst/expressions/HiveHasherSuite.java:[31,17] (modifier) ModifierOrder: 'static' modifier out of order with the JLS suggestions.
[ERROR]src/main/java/org/apache/spark/examples/ml/JavaLogisticRegressionWithElasticNetExample.java:[64] (sizes) LineLength: Line is longer than 100 characters (found 103).
[ERROR] src/main/java/org/apache/spark/examples/ml/JavaInteractionExample.java:[22,8] (imports) UnusedImports: Unused import - org.apache.spark.ml.linalg.Vectors.
[ERROR] src/main/java/org/apache/spark/examples/ml/JavaInteractionExample.java:[51] (regexp) RegexpSingleline: No trailing whitespace allowed.
```

After:
```
$ build/mvn -T 4 -q -DskipTests -Pyarn -Phadoop-2.3 -Pkinesis-asl -Phive -Phive-thriftserver install
$ dev/lint-java
Using `mvn` from path: /home/travis/build/ConeyLiu/spark/build/apache-maven-3.3.9/bin/mvn
Checkstyle checks passed.
```

Author: Xianyang Liu <[email protected]>

Closes apache#15865 from ConeyLiu/master.
@ConeyLiu ConeyLiu deleted the master branch March 10, 2017 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants