GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: common: Fix flaky FinalizeTest · kohlschutter/junixsocket@7d896b1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • junixsocket-common/src/test/java/org/newsclub/net/unix
    • FinalizeTestClient.java
    • domain
      • FinalizeTest.java
  • src/site/markdown
    • changelog.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎junixsocket-common/src/test/java/org/newsclub/net/unix/FinalizeTestClient.java‎

Copy file name to clipboardExpand all lines: junixsocket-common/src/test/java/org/newsclub/net/unix/FinalizeTestClient.java
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ public static void main(String[] args) throws Exception {
6262

6363
// create some pressure on GC
6464
List<String> list = new ArrayList<>();
65+
long nextGc = System.currentTimeMillis() + 500;
6566
while (true) {
6667
list.add(new String("junixsocket".getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8));
68+
long now = System.currentTimeMillis();
69+
if (now >= nextGc) {
70+
nextGc = now + 500;
71+
System.gc(); // NOPMD
72+
}
6773
}
6874
}
6975
}
Collapse file

‎junixsocket-common/src/test/java/org/newsclub/net/unix/domain/FinalizeTest.java‎

Copy file name to clipboardExpand all lines: junixsocket-common/src/test/java/org/newsclub/net/unix/domain/FinalizeTest.java
+20-5Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.newsclub.net.unix.domain;
1919

2020
import static org.junit.jupiter.api.Assertions.assertTrue;
21-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
2221
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2322

2423
import java.io.BufferedReader;
@@ -27,8 +26,8 @@
2726
import java.nio.charset.Charset;
2827
import java.util.ArrayList;
2928
import java.util.Collections;
29+
import java.util.Iterator;
3030
import java.util.List;
31-
import java.util.Objects;
3231

3332
import org.newsclub.net.unix.AFSocketCapability;
3433
import org.newsclub.net.unix.AFSocketCapabilityRequirement;
@@ -67,12 +66,29 @@ private static List<String> lsofUnixSockets(long pid) throws IOException, TestAb
6766
try (BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream(), Charset
6867
.defaultCharset()))) {
6968
String l;
69+
70+
boolean hasUnix = false;
71+
7072
while ((l = in.readLine()) != null) {
7173
lines.add(l);
74+
if (!hasUnix && l.contains("unix")) {
75+
hasUnix = true;
76+
}
7277
if (l.contains("busybox")) {
7378
assumeTrue(false, "incompatible lsof binary");
7479
}
7580
}
81+
82+
if (hasUnix) {
83+
// if "lsof" returns a "unix" identifier, focus on those lines specifically.
84+
for (Iterator<String> it = lines.iterator(); it.hasNext();) {
85+
String line = it.next();
86+
if (!line.contains("unix")) {
87+
it.remove();
88+
}
89+
}
90+
}
91+
7692
p.waitFor();
7793
} finally {
7894
p.destroy();
@@ -114,9 +130,8 @@ protected void postRunCheck(Process process, Object linesBeforeObj) throws TestA
114130
}
115131
}
116132

117-
assumeFalse(Objects.requireNonNull(linesAfter).isEmpty(), "lsof may fail to return anything");
118-
119-
if (linesAfter != null && linesBefore != null) {
133+
if (linesAfter != null && linesBefore != null && !linesBefore.isEmpty() && !linesAfter
134+
.isEmpty()) {
120135
if (linesAfter.size() >= linesBefore.size()) {
121136
System.err.println("lsof: Unexpected output");
122137
System.err.println("lsof: Output before: " + linesBefore);
Collapse file

‎src/site/markdown/changelog.md‎

Copy file name to clipboardExpand all lines: src/site/markdown/changelog.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ artifact (`<type>pom</type>`); see [Add junixsocket to your project](dependency.
1818
- Fix duplicate file descriptors being received sporadically for non-blocking sockets and upon error
1919
- Fix a flaky selftest when VSOCK is not supported
2020
- Fix a flaky selftest with GraalvM 17
21+
- Fix a flaky selftest with old-style finalizers
2122
- Improve interoperability with exotic Linux/Java combinations
2223
- Add support for loongarch64 Linux
2324
- Add more tests

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.