You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "timveil (via GitHub)" <gi...@apache.org> on 2023/12/08 21:37:47 UTC
[PR] insuring opened `Channel` instances are properly closed Fix for #12119 [pinot]
timveil opened a new pull request, #12130:
URL: https://github.com/apache/pinot/pull/12130
This commit modifies several classes to use a try-with-resource block for file operations, conforming with best practices for Java resource management. Previously, file resources such as RandomAccessFile and FileOutputStream were not included in a try-with-resource statement, which could lead to resource leaks if exceptions occurred. The changes ensure these resources are properly closed after usage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12129 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #12130:
URL: https://github.com/apache/pinot/pull/12130#discussion_r1423121540
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/RangeIndexCreator.java:
##########
@@ -321,6 +322,7 @@ public void seal()
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_rangeIndexFile));
DataOutputStream header = new DataOutputStream(bos);
FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
+ FileChannel channel = fos.getChannel();
Review Comment:
File channel is actually closed along with the output stream, but it is benign to explicitly close it
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/RangeIndexCreator.java:
##########
@@ -321,6 +322,7 @@ public void seal()
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_rangeIndexFile));
DataOutputStream header = new DataOutputStream(bos);
FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
Review Comment:
Not introduced in this PR, but `FileOutputStream` is opened twice, is this intentional?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12129 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "timveil (via GitHub)" <gi...@apache.org>.
timveil commented on code in PR #12130:
URL: https://github.com/apache/pinot/pull/12130#discussion_r1425611488
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/RangeIndexCreator.java:
##########
@@ -321,6 +322,7 @@ public void seal()
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_rangeIndexFile));
DataOutputStream header = new DataOutputStream(bos);
FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
Review Comment:
@Jackie-Jiang wouldn't something like this be more sensible?
```
try (FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
DataOutputStream header = new DataOutputStream(bos);
DataOutputStream dataOutputStream = new DataOutputStream(bos)) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12119 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #12130:
URL: https://github.com/apache/pinot/pull/12130#issuecomment-1847909613
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/12130?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: `2 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`56ecafc`)](https://app.codecov.io/gh/apache/pinot/commit/56ecafc17e141b4cd9404255452b654231cc1247?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 61.60% compared to head [(`1f777b2`)](https://app.codecov.io/gh/apache/pinot/pull/12130?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 34.83%.
| [Files](https://app.codecov.io/gh/apache/pinot/pull/12130?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...al/segment/creator/impl/inv/RangeIndexCreator.java](https://app.codecov.io/gh/apache/pinot/pull/12130?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9zZWdtZW50L2NyZWF0b3IvaW1wbC9pbnYvUmFuZ2VJbmRleENyZWF0b3IuamF2YQ==) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/12130?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #12130 +/- ##
=============================================
- Coverage 61.60% 34.83% -26.77%
+ Complexity 1152 946 -206
=============================================
Files 2406 2330 -76
Lines 130859 127113 -3746
Branches 20218 19660 -558
=============================================
- Hits 80611 44276 -36335
- Misses 44373 79690 +35317
+ Partials 5875 3147 -2728
```
| [Flag](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <0.00%> (-0.01%)` | :arrow_down: |
| [integration1](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration2](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <0.00%> (ø)` | |
| [java-11](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-21](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.83% <60.00%> (-26.65%)` | :arrow_down: |
| [skip-bytebuffers-false](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.81% <60.00%> (-26.78%)` | :arrow_down: |
| [skip-bytebuffers-true](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `46.50% <60.00%> (-14.96%)` | :arrow_down: |
| [temurin](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.83% <60.00%> (-26.77%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `46.54% <60.00%> (-15.06%)` | :arrow_down: |
| [unittests1](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `46.54% <60.00%> (-0.17%)` | :arrow_down: |
| [unittests2](https://app.codecov.io/gh/apache/pinot/pull/12130/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/12130?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12129 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang merged PR #12130:
URL: https://github.com/apache/pinot/pull/12130
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12129 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "timveil (via GitHub)" <gi...@apache.org>.
timveil commented on code in PR #12130:
URL: https://github.com/apache/pinot/pull/12130#discussion_r1425617914
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/RangeIndexCreator.java:
##########
@@ -321,6 +322,7 @@ public void seal()
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_rangeIndexFile));
DataOutputStream header = new DataOutputStream(bos);
FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
Review Comment:
its not clear to me if these `DataOutputStream` instances require their own `bos`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12129 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "timveil (via GitHub)" <gi...@apache.org>.
timveil commented on code in PR #12130:
URL: https://github.com/apache/pinot/pull/12130#discussion_r1424689833
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/RangeIndexCreator.java:
##########
@@ -321,6 +322,7 @@ public void seal()
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_rangeIndexFile));
DataOutputStream header = new DataOutputStream(bos);
FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
+ FileChannel channel = fos.getChannel();
Review Comment:
you are right. i try to be good about closing these things as its easy to miss and IntelliJ makes a fuss if you dont.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12129 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #12130:
URL: https://github.com/apache/pinot/pull/12130#discussion_r1427197447
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/RangeIndexCreator.java:
##########
@@ -321,6 +322,7 @@ public void seal()
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_rangeIndexFile));
DataOutputStream header = new DataOutputStream(bos);
FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
Review Comment:
Going over the code again, and seems we need to maintain 2 offsets
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] PR for issue #12129 - insuring opened `Channel` instances are properly closed [pinot]
Posted by "timveil (via GitHub)" <gi...@apache.org>.
timveil commented on code in PR #12130:
URL: https://github.com/apache/pinot/pull/12130#discussion_r1425611488
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/RangeIndexCreator.java:
##########
@@ -321,6 +322,7 @@ public void seal()
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_rangeIndexFile));
DataOutputStream header = new DataOutputStream(bos);
FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
Review Comment:
@Jackie-Jiang wouldn't something like this be more sensible?
```
try (FileOutputStream fos = new FileOutputStream(_rangeIndexFile);
FileChannel channel = fos.getChannel();
BufferedOutputStream bos = new BufferedOutputStream(fos);
DataOutputStream header = new DataOutputStream(bos);
DataOutputStream dataOutputStream = new DataOutputStream(bos)) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org