Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
[fix] probably fixes spurious "too many open files" issue. #BAZEL-890…
Browse files Browse the repository at this point in the history
… fixed
  • Loading branch information
jastice authored and qodana-bot committed Mar 24, 2024
1 parent dc830f8 commit 28797b6
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,19 @@ class TargetInfoReader {

private fun <T : Message.Builder> readFromFile(path: Path, builder: T): T {
val parser = TextFormat.Parser.newBuilder().setAllowUnknownFields(true).build()
parser.merge(Files.newBufferedReader(path, StandardCharsets.UTF_8), builder)

Files.newBufferedReader(path, StandardCharsets.UTF_8).use {
parser.merge(it, builder)
}
return builder
}

private fun readTargetInfoFromFile(uri: URI): TargetInfo {
val builder = TargetInfo.newBuilder()
val parser = TextFormat.Parser.newBuilder().setAllowUnknownFields(true).build()
parser.merge(Files.newBufferedReader(Paths.get(uri), StandardCharsets.UTF_8), builder)
Files.newBufferedReader(Paths.get(uri), StandardCharsets.UTF_8).use {
parser.merge(it, builder)
}
return builder.buildPartial()
}

Expand Down

0 comments on commit 28797b6

Please sign in to comment.