Skip to content
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

[SPARK-13692][CORE][SQL] Fix trivial Coverity/Checkstyle defects #11530

Closed
wants to merge 6 commits into from
Closed

[SPARK-13692][CORE][SQL] Fix trivial Coverity/Checkstyle defects #11530

wants to merge 6 commits into from

Conversation

dongjoon-hyun
Copy link
Member

What changes were proposed in this pull request?

This issue fixes the following potential bugs and Java coding style detected by Coverity and Checkstyle.

  • Implement both null and type checking in equals functions.
  • Fix wrong type casting logic in SimpleJavaBean2.equals.
  • Add implement Cloneable to UTF8String and SortedIterator.
  • Remove dereferencing before null check in AbstractBytesToBytesMapSuite.
  • Fix coding style: Add '{}' to single for statement in mllib examples.
  • Remove unused imports in ColumnarBatch and JavaKinesisStreamSuite.
  • Remove unused fields in ChunkFetchIntegrationSuite.
  • Add stop() to prevent resource leak.

Please note that the last two checkstyle errors exist on newly added commits after SPARK-13583.

How was this patch tested?

manual via ./dev/lint-java and Coverity site.

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
This is based on Coverity reports. Could you review this please?

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-13692] Fix trivial Coverity/Checkstyle defects [SPARK-13692][CORE][SQL] Fix trivial Coverity/Checkstyle defects Mar 4, 2016
@@ -44,8 +44,9 @@ public static void main(String[] args) {
public Vector call(String s) {
String[] sarray = s.trim().split(" ");
double[] values = new double[sarray.length];
for (int i = 0; i < sarray.length; i++)
for (int i = 0; i < sarray.length; i++) {
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 fine, but it wasn't the analysis problem. A lot of the examples don't stop() the context at the end, and this was one of about 30.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I fix this since it's the error from one 'Checkstyle' (lint-java).
Up to now, this PR does not include stop() context discussed in emails.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see. That's important then.

@srowen
Copy link
Member

srowen commented Mar 5, 2016

It's looking fine; do you want to address some more of the simple ones? like identical branches of an if, unused fields, etc?

@srowen
Copy link
Member

srowen commented Mar 5, 2016

Jenkins test this please

@dongjoon-hyun
Copy link
Member Author

Thank you, @srowen .
Since Coverity was announced in mailing lists, I made this PR/JIRA quickly to avoid any potential conflicts.
I'll try to add more and let you know when I'm finished.

@SparkQA
Copy link

SparkQA commented Mar 5, 2016

Test build #52513 has finished for PR 11530 at commit 9f74e82.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • public final class SortedIterator extends UnsafeSorterIterator implements Cloneable

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen . I did the followings, too.

- Remove unused fields in `ChunkFetchIntegrationSuite`.
- Add `close()` to prevent resource leak.

Could you merge this if the test passes again?

@dongjoon-hyun
Copy link
Member Author

retest this please

2 similar comments
@dongjoon-hyun
Copy link
Member Author

retest this please

@dongjoon-hyun
Copy link
Member Author

retest this please

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
Sorry, but could you ask Jenkins to retest this PR?
I tried to ask Jenkins by asking 'retest this please' and by rebasing this PR, but it does not response for 24 hours.

@@ -390,6 +390,7 @@ public void testQueueStream() {
JavaTestUtils.attachTestOutputStream(stream);
List<List<Integer>> result = JavaTestUtils.runStreams(ssc, 3, 3);
Assert.assertEquals(expected, result);
jsc.close();
Copy link
Member

Choose a reason for hiding this comment

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

These types of changes are welcome of course but I think we need to call stop() in the examples, not close(). Or at least that's what the others do. I don't think Coverity will realize that, but that's fine, it's then a false positive we just resolve as such.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, thank you for pointing that. I will replace them all with stop.

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
I update this PR and JIRA to use close() instead of stop().

@srowen
Copy link
Member

srowen commented Mar 7, 2016

Jenkins, test this please

@SparkQA
Copy link

SparkQA commented Mar 7, 2016

Test build #52553 has finished for PR 11530 at commit bea31f9.

  • This patch fails from timeout after a configured wait of 250m.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Oh, @srowen .
There is no apparent error for me. It stops before SparkR tests and marked.

Build step 'Execute shell' marked build as failure

It seems really timeout for the whole test.

Started 6 hr 47 min ago
Took 4 hr 11 min on amp-jenkins-worker-08

Do you think we put too much thing in one PR?

@dongjoon-hyun
Copy link
Member Author

Just rebased.

@dongjoon-hyun
Copy link
Member Author

Thanks to #11564 , I can fix JavaKinesisStreamSuite too.

@dongjoon-hyun
Copy link
Member Author

retest this please

@zsxwing
Copy link
Member

zsxwing commented Mar 7, 2016

ok to test

@dongjoon-hyun
Copy link
Member Author

Thank you, @zsxwing !

@SparkQA
Copy link

SparkQA commented Mar 8, 2016

Test build #52611 has finished for PR 11530 at commit 9a0f8fa.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@zsxwing
Copy link
Member

zsxwing commented Mar 8, 2016

retest this please

@SparkQA
Copy link

SparkQA commented Mar 8, 2016

Test build #52631 has finished for PR 11530 at commit 9a0f8fa.

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

@dongjoon-hyun
Copy link
Member Author

Thank you, @zsxwing .

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
Could you merge this PR, please?
It includes JavaKinesisStreamSuite part, too.

@@ -171,5 +171,6 @@ public void call(JavaPairRDD<Double, String> happinessTopicPairs) {

jssc.start();
jssc.awaitTermination();
jssc.close();
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I just realized I misled you in my comments. For streaming examples, we should not call close() or stop(). The correct last call is awaitTermination(). If you back those out, I'll merge this. Sorry about that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, it's my fault. I'll fix right now. Thank you again.

  * Implement both null and type checking in equals functions.
  * Fix wrong type casting logic in SimpleJavaBean2.equals.
  * Add `implement Cloneable` to `UTF8String` and `SortedIterator`.
  * Remove dereferencing before null check in `AbstractBytesToBytesMapSuite`.
  * Fix coding style: Add '{}' to single `for` statement in mllib examples.
  * Remove unused imports in `ColumnarBatch`.
@dongjoon-hyun
Copy link
Member Author

Hi, @srowen . I've finished.
Let's see the result, Jenkins #52663

@SparkQA
Copy link

SparkQA commented Mar 8, 2016

Test build #52662 has finished for PR 11530 at commit cdb6077.

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

@SparkQA
Copy link

SparkQA commented Mar 8, 2016

Test build #52663 has finished for PR 11530 at commit e3c4cf0.

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

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
I'm back online now. Please let me know if there is more things to do here.
Thank you for reviewing and guiding in these days.

@srowen
Copy link
Member

srowen commented Mar 9, 2016

Merged to master

@asfgit asfgit closed this in f3201ae Mar 9, 2016
@dongjoon-hyun
Copy link
Member Author

Thank you, @srowen !

roygao94 pushed a commit to roygao94/spark that referenced this pull request Mar 22, 2016
## What changes were proposed in this pull request?

This issue fixes the following potential bugs and Java coding style detected by Coverity and Checkstyle.

- Implement both null and type checking in equals functions.
- Fix wrong type casting logic in SimpleJavaBean2.equals.
- Add `implement Cloneable` to `UTF8String` and `SortedIterator`.
- Remove dereferencing before null check in `AbstractBytesToBytesMapSuite`.
- Fix coding style: Add '{}' to single `for` statement in mllib examples.
- Remove unused imports in `ColumnarBatch` and `JavaKinesisStreamSuite`.
- Remove unused fields in `ChunkFetchIntegrationSuite`.
- Add `stop()` to prevent resource leak.

Please note that the last two checkstyle errors exist on newly added commits after [SPARK-13583](https://issues.apache.org/jira/browse/SPARK-13583).

## How was this patch tested?

manual via `./dev/lint-java` and Coverity site.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes apache#11530 from dongjoon-hyun/SPARK-13692.
@dongjoon-hyun dongjoon-hyun deleted the SPARK-13692 branch March 29, 2016 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants