Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
java binary: pass MaxFDLimit option
Browse files Browse the repository at this point in the history
Summary: ^

Reviewed By: jiawei-lyu

fbshipit-source-id: b18f3de245adc7f1d5b33750c4b59bd6130912c4
  • Loading branch information
mykola-semko authored and facebook-github-bot committed Sep 27, 2021
1 parent 613b454 commit 548ec37
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/com/facebook/buck/jvm/java/JavaBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ public Tool getExecutableCommand(OutputLabel outputLabel) {
getBuildTarget());

return new CommandTool.Builder(javaRuntimeLauncher)
// Directs the VM to refrain from setting the file descriptor limit to the default maximum.
// https://stackoverflow.com/a/16535804/5208808
.addArg("-XX:-MaxFDLimit")
.addArg("-jar")
.addArg(SourcePathArg.of(getSourcePathToOutput()))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void afterTest() {
}
}

@Rule public Timeout globalTestTimeout = Timeout.seconds(10);
@Rule public Timeout globalTestTimeout = Timeout.seconds(30);
@Rule public TestName testName = new TestName();

@Rule public TestLogSink testToolLogSink = new TestLogSink(TEST_LOGGER_NAME);
Expand Down
6 changes: 5 additions & 1 deletion test/com/facebook/buck/jvm/java/JavaBinaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ public void testGetExecutableCommand() {
basePath + pathResolver.getCellUnsafeRelPath(javaBinary.getSourcePathToOutput());

List<String> expectedCommand =
ImmutableList.of(JavaRuntimeUtils.getBucksJavaBinCommand(), "-jar", expectedClasspath);
ImmutableList.of(
JavaRuntimeUtils.getBucksJavaBinCommand(),
"-XX:-MaxFDLimit",
"-jar",
expectedClasspath);
assertEquals(
expectedCommand,
javaBinary.getExecutableCommand(OutputLabel.defaultLabel()).getCommandPrefix(pathResolver));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public void testReplaceBinaryBuildRuleRefsInCmd() throws Exception {
.toAbsolutePath();
String expectedCmd =
String.format(
"%s -jar %s $OUT", JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
"%s -XX:-MaxFDLimit -jar %s $OUT",
JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
assertEquals(expectedCmd, transformedString);
}

Expand All @@ -121,7 +122,8 @@ public void testReplaceRelativeBinaryBuildRuleRefsInCmd() throws Exception {
.toAbsolutePath();
String expectedCmd =
String.format(
"%s -jar %s $OUT", JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
"%s -XX:-MaxFDLimit -jar %s $OUT",
JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
assertEquals(expectedCmd, transformedString);
}

Expand All @@ -144,7 +146,8 @@ public void testDepsGenrule() throws Exception {
.toAbsolutePath();
String expectedCmd =
String.format(
"%s -jar %s $OUT", JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
"%s -XX:-MaxFDLimit -jar %s $OUT",
JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
assertEquals(expectedCmd, transformedString);
}

Expand Down

0 comments on commit 548ec37

Please sign in to comment.