Remove useless checks from evil JNA tests
This commit removes some useless empty lines checks from the evil JNA tests. These empty lines checks are useless because if the lines are actually empty, the for loop will never be entered and we will hit the fail condition at the bottom as intended anyway.
This commit is contained in:
parent
2ef0f8af38
commit
d9e0c5e2fe
|
@ -36,17 +36,15 @@ public class EvilJNANativesTests extends ESTestCase {
|
|||
public void testSetMaximumNumberOfThreads() throws IOException {
|
||||
if (Constants.LINUX) {
|
||||
final List<String> lines = Files.readAllLines(PathUtils.get("/proc/self/limits"));
|
||||
if (!lines.isEmpty()) {
|
||||
for (final String line : lines) {
|
||||
if (line != null && line.startsWith("Max processes")) {
|
||||
final String[] fields = line.split("\\s+");
|
||||
final long limit =
|
||||
"unlimited".equals(fields[2])
|
||||
? JNACLibrary.RLIM_INFINITY
|
||||
: Long.parseLong(fields[2]);
|
||||
assertThat(JNANatives.MAX_NUMBER_OF_THREADS, equalTo(limit));
|
||||
return;
|
||||
}
|
||||
for (final String line : lines) {
|
||||
if (line != null && line.startsWith("Max processes")) {
|
||||
final String[] fields = line.split("\\s+");
|
||||
final long limit =
|
||||
"unlimited".equals(fields[2])
|
||||
? JNACLibrary.RLIM_INFINITY
|
||||
: Long.parseLong(fields[2]);
|
||||
assertThat(JNANatives.MAX_NUMBER_OF_THREADS, equalTo(limit));
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail("should have read max processes from /proc/self/limits");
|
||||
|
@ -58,16 +56,14 @@ public class EvilJNANativesTests extends ESTestCase {
|
|||
public void testSetMaxSizeVirtualMemory() throws IOException {
|
||||
if (Constants.LINUX) {
|
||||
final List<String> lines = Files.readAllLines(PathUtils.get("/proc/self/limits"));
|
||||
if (!lines.isEmpty()) {
|
||||
for (final String line : lines) {
|
||||
if (line != null && line.startsWith("Max address space")) {
|
||||
final String[] fields = line.split("\\s+");
|
||||
final String limit = fields[3];
|
||||
assertThat(
|
||||
JNANatives.rlimitToString(JNANatives.MAX_SIZE_VIRTUAL_MEMORY),
|
||||
equalTo(limit));
|
||||
return;
|
||||
}
|
||||
for (final String line : lines) {
|
||||
if (line != null && line.startsWith("Max address space")) {
|
||||
final String[] fields = line.split("\\s+");
|
||||
final String limit = fields[3];
|
||||
assertThat(
|
||||
JNANatives.rlimitToString(JNANatives.MAX_SIZE_VIRTUAL_MEMORY),
|
||||
equalTo(limit));
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail("should have read max size virtual memory from /proc/self/limits");
|
||||
|
|
Loading…
Reference in New Issue