Call reachabilityFence inside finally blocks (#7001)

This commit is contained in:
David Vo
2024-08-24 23:49:46 +10:00
committed by GitHub
parent 36ff22a439
commit 88fc46da22
2 changed files with 36 additions and 30 deletions

View File

@@ -74,13 +74,16 @@ public class AnalogTrigger implements Sendable, AutoCloseable {
@Override
public void close() {
SendableRegistry.remove(this);
AnalogJNI.cleanAnalogTrigger(m_port);
m_port = 0;
if (m_ownsAnalog && m_analogInput != null) {
m_analogInput.close();
try {
SendableRegistry.remove(this);
AnalogJNI.cleanAnalogTrigger(m_port);
m_port = 0;
if (m_ownsAnalog && m_analogInput != null) {
m_analogInput.close();
}
} finally {
Reference.reachabilityFence(m_dutyCycle);
}
Reference.reachabilityFence(m_dutyCycle);
}
/**