Skip to content

Commit

Permalink
Avoid non-closed streams.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Jul 8, 2024
1 parent ceabf1d commit 5ad487e
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,13 @@ public int getOwnerIdOf(File file) {
file.getAbsolutePath()});
int attempts = this.attempts;
boolean exited = false;
String line = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8")).readLine();
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
try {
line = reader.readLine();
} finally {
reader.close();
}
do {
try {
if (process.exitValue() != 0) {
Expand Down Expand Up @@ -2479,11 +2485,15 @@ public int getOwnerIdOf(File file) {
Process process = Runtime.getRuntime().exec(new String[]{"istat", file.getAbsolutePath()});
int attempts = this.attempts;
boolean exited = false;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
StringBuilder output = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
output.append(line).append("\n");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
try {
String line;
while ((line = reader.readLine()) != null) {
output.append(line).append("\n");
}
} finally {
reader.close();
}
do {
try {
Expand Down Expand Up @@ -2563,7 +2573,13 @@ public int getOwnerIdOf(File file) {
file.getAbsolutePath()});
int attempts = this.attempts;
boolean exited = false;
String line = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8")).readLine();
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
try {
line = reader.readLine();
} finally {
reader.close();
}
do {
try {
if (process.exitValue() != 0) {
Expand Down

0 comments on commit 5ad487e

Please sign in to comment.