Skip to content

Commit cc704ac

Browse files
committed
prevent exceptions on get/set B2BUAHelper
1 parent 24254dd commit cc704ac

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java

+15-7
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ public void invalidate(boolean bypassCheck) {
11151115
// sipApplicationSession = null;
11161116
manager = null;
11171117
if(getB2buaHelper() != null) {
1118+
//this will remove the linking so infinite loop is prevented
11181119
getB2buaHelper().unlinkSipSessionsInternal(this, false);
11191120
}
11201121
derivedSipSessions = null;
@@ -1181,7 +1182,7 @@ public void invalidate(boolean bypassCheck) {
11811182
// semaphore = null;
11821183
// }
11831184
facade = null;
1184-
}
1185+
}
11851186

11861187
/**
11871188
* Not needed anymore after PFD JSR 289 spec
@@ -1604,7 +1605,7 @@ public void onTerminatedState() {
16041605
if (linkedSession != null) {
16051606
logger.debug("terminating linked session.");
16061607
linkedSession.onTerminatedState();
1607-
}
1608+
}
16081609

16091610
if(!this.isValid && this.parentSession != null) {
16101611
//Since there is a parent session, and since the current derived sip session
@@ -1614,7 +1615,7 @@ public void onTerminatedState() {
16141615
if(logger.isDebugEnabled()) {
16151616
String msg = String.format("SipSession [%s] onTerminateState hasParentSession [%s] that will ask to onReadyToInvalidate()", key, parentSession.getKey());
16161617
logger.debug(msg);
1617-
}
1618+
}
16181619

16191620
this.parentSession.onReadyToInvalidate();
16201621
}
@@ -2051,7 +2052,7 @@ public void onReadyToInvalidate() {
20512052
return;
20522053
} else {
20532054
logger.debug("All Derived ready, lets proceed.");
2054-
}
2055+
}
20552056

20562057
if(logger.isDebugEnabled()) {
20572058
logger.debug("invalidateWhenReady flag is set to " + invalidateWhenReady);
@@ -2098,17 +2099,24 @@ public void setProxy(MobicentsProxy proxy) {
20982099
* {@inheritDoc}
20992100
*/
21002101
public void setB2buaHelper(MobicentsB2BUAHelper helperImpl) {
2101-
logger.debug("setting B2BUAHelper:" + helperImpl);
2102+
logger.debug("setting B2BUAHelper");
21022103
SipApplicationSession applicationSession = getApplicationSession();
2103-
applicationSession.setAttribute(B2buaHelperImpl.B2BUA_ATT_NAME, helperImpl);
2104+
if (this.isValid && applicationSession.isValid()) {
2105+
applicationSession.setAttribute(B2buaHelperImpl.B2BUA_ATT_NAME, helperImpl);
2106+
logger.debug("B2BUAHelper set");
2107+
}
21042108
}
21052109

21062110
/**
21072111
* {@inheritDoc}
21082112
*/
21092113
public B2buaHelperImpl getB2buaHelper() {
2114+
B2buaHelperImpl helper = null;
21102115
SipApplicationSession applicationSession = getApplicationSession();
2111-
B2buaHelperImpl helper = (B2buaHelperImpl) applicationSession.getAttribute(B2buaHelperImpl.B2BUA_ATT_NAME);
2116+
if (this.isValid && applicationSession.isValid()) {
2117+
helper = (B2buaHelperImpl) applicationSession.getAttribute(B2buaHelperImpl.B2BUA_ATT_NAME);
2118+
logger.debug("B2BUAHelper got");
2119+
}
21122120
return helper;
21132121
}
21142122

0 commit comments

Comments
 (0)