Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get session state after lock acquiring, release session on error #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ public <E> E getState(Class<E> stateType) {
@Override
public boolean handleEvent(StateEvent event) throws InternalException, OverloadException {
ServerRoSessionState newState = null;
ServerRoSessionState state = sessionData.getServerRoSessionState();
try {
sendAndStateLock.lock();

// Get state after lock acquiring
ServerRoSessionState state = sessionData.getServerRoSessionState();

// Can be null if there is no state transition, transition to IDLE state should terminate this app session
Event localEvent = (Event) event;

Expand Down Expand Up @@ -224,6 +226,10 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE
case RECEIVED_TERMINATE:
Answer errorAnswer = ((Request) localEvent.getRequest().getMessage()).createAnswer(ResultCode.UNKNOWN_SESSION_ID);
session.send(errorAnswer);

// release this session
release();

logger.debug("Received an UPDATE or TERMINATE for a new session. Answering with 5002 (UNKNOWN_SESSION_ID) and terminating session.");
// and let it throw exception anyway ...
default:
Expand Down