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

Commit 548ec37

Browse files
mykola-semkofacebook-github-bot
authored andcommitted
java binary: pass MaxFDLimit option
Summary: ^ Reviewed By: jiawei-lyu fbshipit-source-id: b18f3de245adc7f1d5b33750c4b59bd6130912c4
1 parent 613b454 commit 548ec37

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/com/facebook/buck/jvm/java/JavaBinary.java

+3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ public Tool getExecutableCommand(OutputLabel outputLabel) {
239239
getBuildTarget());
240240

241241
return new CommandTool.Builder(javaRuntimeLauncher)
242+
// Directs the VM to refrain from setting the file descriptor limit to the default maximum.
243+
// https://stackoverflow.com/a/16535804/5208808
244+
.addArg("-XX:-MaxFDLimit")
242245
.addArg("-jar")
243246
.addArg(SourcePathArg.of(getSourcePathToOutput()))
244247
.build();

test/com/facebook/buck/downwardapi/processexecutor/DownwardApiProcessExecutorTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void afterTest() {
139139
}
140140
}
141141

142-
@Rule public Timeout globalTestTimeout = Timeout.seconds(10);
142+
@Rule public Timeout globalTestTimeout = Timeout.seconds(30);
143143
@Rule public TestName testName = new TestName();
144144

145145
@Rule public TestLogSink testToolLogSink = new TestLogSink(TEST_LOGGER_NAME);

test/com/facebook/buck/jvm/java/JavaBinaryTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ public void testGetExecutableCommand() {
108108
basePath + pathResolver.getCellUnsafeRelPath(javaBinary.getSourcePathToOutput());
109109

110110
List<String> expectedCommand =
111-
ImmutableList.of(JavaRuntimeUtils.getBucksJavaBinCommand(), "-jar", expectedClasspath);
111+
ImmutableList.of(
112+
JavaRuntimeUtils.getBucksJavaBinCommand(),
113+
"-XX:-MaxFDLimit",
114+
"-jar",
115+
expectedClasspath);
112116
assertEquals(
113117
expectedCommand,
114118
javaBinary.getExecutableCommand(OutputLabel.defaultLabel()).getCommandPrefix(pathResolver));

test/com/facebook/buck/rules/macros/ExecutableMacroExpanderTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public void testReplaceBinaryBuildRuleRefsInCmd() throws Exception {
9999
.toAbsolutePath();
100100
String expectedCmd =
101101
String.format(
102-
"%s -jar %s $OUT", JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
102+
"%s -XX:-MaxFDLimit -jar %s $OUT",
103+
JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
103104
assertEquals(expectedCmd, transformedString);
104105
}
105106

@@ -121,7 +122,8 @@ public void testReplaceRelativeBinaryBuildRuleRefsInCmd() throws Exception {
121122
.toAbsolutePath();
122123
String expectedCmd =
123124
String.format(
124-
"%s -jar %s $OUT", JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
125+
"%s -XX:-MaxFDLimit -jar %s $OUT",
126+
JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
125127
assertEquals(expectedCmd, transformedString);
126128
}
127129

@@ -144,7 +146,8 @@ public void testDepsGenrule() throws Exception {
144146
.toAbsolutePath();
145147
String expectedCmd =
146148
String.format(
147-
"%s -jar %s $OUT", JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
149+
"%s -XX:-MaxFDLimit -jar %s $OUT",
150+
JavaRuntimeUtils.getBucksJavaBinCommand(), expectedClasspath);
148151
assertEquals(expectedCmd, transformedString);
149152
}
150153

0 commit comments

Comments
 (0)