Skip to content

Fix thread-safety race between close() and onSecurityKeysCreated() in WiresharkKeyLogWriter#1721

Merged
kevinherron merged 2 commits intofeature/wireshark-keylogfrom
copilot/sub-pr-1720
Mar 26, 2026
Merged

Fix thread-safety race between close() and onSecurityKeysCreated() in WiresharkKeyLogWriter#1721
kevinherron merged 2 commits intofeature/wireshark-keylogfrom
copilot/sub-pr-1720

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

close() was unsynchronized while onSecurityKeysCreated() was, allowing close() to shut down the BufferedWriter mid-write — producing partial output or unexpected exceptions despite the class claiming thread-safety.

Changes

  • close() is now synchronized on the same monitor as onSecurityKeysCreated(), eliminating the race
  • Added closed flagclose() is now idempotent; onSecurityKeysCreated() silently no-ops if the writer is already closed
@Override
public synchronized void close() throws IOException {
    if (!closed) {
        closed = true;
        writer.close();
    }
}

@Override
public synchronized void onSecurityKeysCreated(SecurityKeyset keyset) {
    if (closed) {
        return;
    }
    // ... write entry
}

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

… in WiresharkKeyLogWriter

Co-authored-by: kevinherron <340273+kevinherron@users.noreply.github.com>
Agent-Logs-Url: https://github.com/eclipse-milo/milo/sessions/9c68c19c-bced-4530-970b-188f0ccdc2ac
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 26, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.eclipse.org
    • Triggering command: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.18-8/x64/bin/java /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.18-8/x64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/milo/milo org.codehaus.plexus.classworlds.launcher.Launcher -q spotless:apply (dns block)
    • Triggering command: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.18-8/x64/bin/java /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.18-8/x64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/milo/milo org.codehaus.plexus.classworlds.launcher.Launcher -q clean compile -pl opc-ua-stack/stack-core (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] [WIP] Address feedback on Wireshark key log support for OPC UA decryption Fix thread-safety race between close() and onSecurityKeysCreated() in WiresharkKeyLogWriter Mar 26, 2026
Copilot AI requested a review from kevinherron March 26, 2026 03:38
@kevinherron kevinherron marked this pull request as ready for review March 26, 2026 11:59
@kevinherron kevinherron merged commit b631b9b into feature/wireshark-keylog Mar 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants