You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/07/31 07:26:44 UTC
[GitHub] [ozone] sky76093016 opened a new pull request #2481: HDDS-5524. Use try-with-resources to properly close resources in DirectoryServerSource.java
sky76093016 opened a new pull request #2481:
URL: https://github.com/apache/ozone/pull/2481
## What changes were proposed in this pull request?
Resources should be closed.Failure to properly close resources will result in a resource leak.
Resource should be created using `try-with-resources` pattern and will be closed automatically.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/projects/HDDS/issues/HDDS-5524
## How was this patch tested?
No need.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] adoroszlai merged pull request #2481: HDDS-5524. Use try-with-resources to properly close resources in DirectoryServerSource.java
Posted by GitBox <gi...@apache.org>.
adoroszlai merged pull request #2481:
URL: https://github.com/apache/ozone/pull/2481
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] sky76093016 commented on a change in pull request #2481: HDDS-5524. Use try-with-resources to properly close resources in DirectoryServerSource.java
Posted by GitBox <gi...@apache.org>.
sky76093016 commented on a change in pull request #2481:
URL: https://github.com/apache/ozone/pull/2481#discussion_r680329295
##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/DirectoryServerSource.java
##########
@@ -41,18 +42,19 @@ public DirectoryServerSource(Path root) {
* @param id name of the subdirectory to replitace relative to root.
*/
public Map<String, Path> getFilesToStream(String id)
- throws InterruptedException {
+ throws InterruptedException {
Map<String, Path> files = new HashMap<>();
final Path streamingDir = root.resolve(id);
try {
- Files.walk(streamingDir)
- .filter(Files::isRegularFile)
- .forEach(path -> {
- files.put(root.relativize(path).toString(), path);
- });
+ try (Stream<Path> list = Files.walk(streamingDir)
Review comment:
Thanks @adoroszlai for reviewing, I have fixed it.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] adoroszlai commented on a change in pull request #2481: HDDS-5524. Use try-with-resources to properly close resources in DirectoryServerSource.java
Posted by GitBox <gi...@apache.org>.
adoroszlai commented on a change in pull request #2481:
URL: https://github.com/apache/ozone/pull/2481#discussion_r680327506
##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/DirectoryServerSource.java
##########
@@ -41,18 +42,19 @@ public DirectoryServerSource(Path root) {
* @param id name of the subdirectory to replitace relative to root.
*/
public Map<String, Path> getFilesToStream(String id)
- throws InterruptedException {
+ throws InterruptedException {
Map<String, Path> files = new HashMap<>();
final Path streamingDir = root.resolve(id);
try {
- Files.walk(streamingDir)
- .filter(Files::isRegularFile)
- .forEach(path -> {
- files.put(root.relativize(path).toString(), path);
- });
+ try (Stream<Path> list = Files.walk(streamingDir)
+ .filter(Files::isRegularFile)) {
+ list.forEach(path -> {
+ files.put(root.relativize(path).toString(), path);
+ });
+ }
} catch (IOException e) {
throw new StreamingException("Couldn't read directory for streaming: " +
- streamingDir, e);
+ streamingDir, e);
Review comment:
Nit: unnecessary whitespace change.
##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/DirectoryServerSource.java
##########
@@ -41,18 +42,19 @@ public DirectoryServerSource(Path root) {
* @param id name of the subdirectory to replitace relative to root.
*/
public Map<String, Path> getFilesToStream(String id)
- throws InterruptedException {
+ throws InterruptedException {
Review comment:
Nit: unnecessary whitespace change.
##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/DirectoryServerSource.java
##########
@@ -41,18 +42,19 @@ public DirectoryServerSource(Path root) {
* @param id name of the subdirectory to replitace relative to root.
*/
public Map<String, Path> getFilesToStream(String id)
- throws InterruptedException {
+ throws InterruptedException {
Map<String, Path> files = new HashMap<>();
final Path streamingDir = root.resolve(id);
try {
- Files.walk(streamingDir)
- .filter(Files::isRegularFile)
- .forEach(path -> {
- files.put(root.relativize(path).toString(), path);
- });
+ try (Stream<Path> list = Files.walk(streamingDir)
Review comment:
Can you please merge these two `try` blocks?
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] sky76093016 commented on pull request #2481: HDDS-5524. Use try-with-resources to properly close resources in DirectoryServerSource.java
Posted by GitBox <gi...@apache.org>.
sky76093016 commented on pull request #2481:
URL: https://github.com/apache/ozone/pull/2481#issuecomment-890708778
Thanks @cku328 for reviewing,I will fix those issues in the future.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org