Skip to content

Commit

Permalink
Should fix unlocks on exceptional paths (#98)
Browse files Browse the repository at this point in the history
* Should fix unlocks on exceptional paths

* Moves debug logging to match original functionality in run()

* Moves lock outside the try
  • Loading branch information
StrongestNumber9 authored Mar 11, 2024
1 parent 27905b6 commit 09fb14e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/teragrep/rlp_03/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ public class Status {

void complete() {
lock.lock();
done.set(true);
pending.signal();
lock.unlock();
try {
done.set(true);
pending.signal();
} finally {
lock.unlock();
}
}

public void waitForCompletion() throws InterruptedException {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/teragrep/rlp_03/context/RelpReadImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public class RelpReadImpl implements RelpRead {
public void run() {
LOGGER.debug("run entry!");
lock.lock();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("run lock! with activeBuffers.size() <{}>", activeBuffers.size());
}
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("run lock! with activeBuffers.size() <{}>", activeBuffers.size());
}
while (true) {
LOGGER.debug("run loop start");
// TODO implement better state store?
Expand Down

0 comments on commit 09fb14e

Please sign in to comment.