Skip to content

Commit

Permalink
Fix spurious IllegalStateException.
Browse files Browse the repository at this point in the history
  • Loading branch information
broneill committed Feb 1, 2025
1 parent f52e12c commit f03ac7c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/cojen/dirmi/core/AutoDisposer.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public BasicRef(StubWrapper wrapper, StubInvoker invoker) {
}

void removed() {
if (mInvoker.support().session() instanceof CoreSession session) {
if (mInvoker.support().trySession() instanceof CoreSession session) {
// Note: Although the pipe isn't flushed immediately, this operation might
// still block. If it does, then no dispose messages will be sent for any
// sessions until the blocked one automatically disconnects. This can be
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cojen/dirmi/core/DisposedStubSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public CoreSession<?> session() {
return mSession;
}

@Override
public CoreSession<?> trySession() {
return mSession;
}

@Override
public boolean isLenientRestorable() {
return mSession != null && mRestorable;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/cojen/dirmi/core/StubSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
public interface StubSupport {
Session session();

/**
* @return null if disposed
*/
default Session trySession() {
return session();
}

public default boolean isLenientRestorable() {
return false;
}
Expand Down

0 comments on commit f03ac7c

Please sign in to comment.