Revision: 36a5137d6048
Author:   Jean Deruelle <[email protected]>
Date:     Tue Apr 22 19:43:45 2014 UTC
Log:      Update Issue 266

fix + non regression test

(cherry picked from commit 8dd437d36d972887f1b81928c23c6c49571f97e2)

Conflicts:
        containers/sip-servlets-as7-drop-in/jboss-as-mobicents/.classpath
sip-servlets-test-suite/applications/proxy-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ProxySipServlet.java

http://code.google.com/p/sipservlets/source/detail?r=36a5137d6048

Modified:
 /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/.classpath
/sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/proxy/MobicentsProxy.java /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/CancelRequestDispatcher.java /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyImpl.java /sip-servlets-test-suite/applications/proxy-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ProxySipServlet.java

=======================================
--- /sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/proxy/MobicentsProxy.java Tue Sep 20 15:23:24 2011 UTC +++ /sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/proxy/MobicentsProxy.java Tue Apr 22 19:43:45 2014 UTC
@@ -1,23 +1,20 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2014, Telestax Inc and individual contributors
+ * by the @authors tag.
  *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
  * the License, or (at your option) any later version.
  *
- * This software is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
  */

 package org.mobicents.servlet.sip.core.proxy;
@@ -25,6 +22,7 @@
 import java.util.Map;

 import javax.servlet.sip.Proxy;
+import javax.servlet.sip.ProxyBranch;

 import org.mobicents.javax.servlet.sip.ProxyExt;
 import org.mobicents.servlet.sip.core.message.MobicentsSipServletRequest;
@@ -42,5 +40,7 @@
        boolean isTerminationSent();
        void setAckReceived(boolean equalsIgnoreCase);
        void setOriginalRequest(MobicentsSipServletRequest sipServletRequest);
+       // https://code.google.com/p/sipservlets/issues/detail?id=266
+ void cancelAllExcept(ProxyBranch except, String[] protocol, int[] reasonCode, String[] reasonText, boolean throwExceptionIfCannotCancel);

 }
=======================================
--- /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/CancelRequestDispatcher.java Tue Apr 1 12:35:32 2014 UTC +++ /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/CancelRequestDispatcher.java Tue Apr 22 19:43:45 2014 UTC
@@ -24,7 +24,6 @@
 import java.io.IOException;

 import javax.servlet.ServletException;
-import javax.servlet.sip.Proxy;
 import javax.servlet.sip.SipSession.State;
 import javax.sip.InvalidArgumentException;
 import javax.sip.ServerTransaction;
@@ -39,6 +38,7 @@
 import org.mobicents.servlet.sip.core.DispatcherException;
 import org.mobicents.servlet.sip.core.RoutingState;
 import org.mobicents.servlet.sip.core.SipContext;
+import org.mobicents.servlet.sip.core.proxy.MobicentsProxy;
import org.mobicents.servlet.sip.core.session.MobicentsSipApplicationSession;
 import org.mobicents.servlet.sip.core.session.MobicentsSipSession;
 import org.mobicents.servlet.sip.message.SipServletMessageImpl;
@@ -235,7 +235,7 @@
                        final SipContext sipContext = 
sipApplicationSession.getSipContext();
                        try {
                                sipContext.enterSipApp(sipApplicationSession, 
sipSession, false, true);
-                               final Proxy proxy = sipSession.getProxy();
+                               final MobicentsProxy proxy = 
sipSession.getProxy();
                                if(proxy != null) {
                                        if(logger.isDebugEnabled()) {
                                                logger.debug("proxying the CANCEL 
" + sipServletRequest);
@@ -252,7 +252,7 @@
                                                }
                                        } else {
// otherwise, all branches are cancelled, and response processing continues as usual
-                                               proxy.cancel();
+                                               proxy.cancelAllExcept(null, 
null, null, null, false);
                                        }
// Fix for Issue 796 : SIP servlet (simple proxy) does not receive "Cancel" requests. (http://code.google.com/p/mobicents/issues/detail?id=796) // JSR 289 Section 10.2.6 Receiving CANCEL : In either case, the application is subsequently invoked with the CANCEL request
=======================================
--- /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java Tue Mar 11 18:46:24 2014 UTC +++ /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java Tue Apr 22 19:43:45 2014 UTC
@@ -1033,7 +1033,7 @@
                }
                if(proxy != null && !proxy.getAckReceived()) {
                        try {
-                               proxy.cancel();
+                               proxy.cancelAllExcept(null, null, null, null, 
false);
                        } catch (Exception e) {
logger.debug("Problem cancelling proxy. We just try our best. This is not a critical error.", e);
                        }
=======================================
--- /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyImpl.java Fri Sep 27 08:36:27 2013 UTC +++ /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyImpl.java Tue Apr 22 19:43:45 2014 UTC
@@ -243,15 +243,22 @@
logger.debug("Cancelling all Branches except " + except + " with outgoing resquest " + except.getRequest());
                        }
                }
-               for(ProxyBranch proxyBranch : proxyBranches.values()) {
+               for(MobicentsProxyBranch proxyBranch : proxyBranches.values()) {
                        if(!proxyBranch.equals(except)) {
// Do not make this check in the beginning of the method, because in case of reINVITE etc, we already have a single brnch nd this method // would have no actual effect, no need to fail it just because we've already seen ACK. Only throw exception if there are other branches.
                                try {
                                        proxyBranch.cancel(protocol, 
reasonCode, reasonText);
-                               } catch (IllegalStateException e) {
- // TODO: Instead of catching excpetions here just determine if the branch is cancellable
-                                       if(throwExceptionIfCannotCancel) throw 
e;
+                               } catch (IllegalStateException e) {
+                                       if(throwExceptionIfCannotCancel) {
+                                               throw e;
+                                       } else {
+                                               // 
https://code.google.com/p/sipservlets/issues/detail?id=266
+                                               if(logger.isDebugEnabled()) {
+ logger.debug("Problem cancelling proxy branch " + proxyBranch.getTargetURI() + " lastResponse "+ proxyBranch.getResponse() + + " isCancelled " + proxyBranch.isCanceled() + " isStarted " + proxyBranch.isStarted() + " isTimedOut " + proxyBranch.isTimedOut());
+                                               }
+                                       }
                                }
                        }
                }
=======================================
--- /sip-servlets-test-suite/applications/proxy-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ProxySipServlet.java Fri Apr 18 21:29:45 2014 UTC +++ /sip-servlets-test-suite/applications/proxy-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ProxySipServlet.java Tue Apr 22 19:43:45 2014 UTC
@@ -271,6 +271,9 @@
                        } else if(from.contains("nonexist")) {
                                uris.add(uri3);
                                proxy.setProxyTimeout(40);
+                       } else 
if(from.contains("cancel-480-sequential-2-locations")) {
+                               uris.add(uri1);
+                               proxy.setProxyTimeout(140);
                        } else {
                                uris.add(uri2);
                                uris.add(uri1);
@@ -529,10 +532,22 @@
        }

        @Override
-       protected void doBranchResponse(SipServletResponse resp)
+       protected void doBranchResponse(SipServletResponse response)
                        throws ServletException, IOException {
-               logger.info("doBranchResponse callback was called " + resp);
- resp.getApplicationSession().setAttribute("branchResponseReceived", "true");
+               logger.info("doBranchResponse callback was called " + response);
+ response.getApplicationSession().setAttribute("branchResponseReceived", "true");
+               if(response.getStatus() == 408) {
+                       sendMessage("doBranchTimeoutReceived", 5080, "udp");
+               }
+               if(response.getStatus() == 480) {
+                       // 
https://code.google.com/p/sipservlets/issues/detail?id=266
+ SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
+                       ArrayList<URI> uris = new ArrayList<URI>();
+                       // This URi completes and need to be canceled before 
answering
+ uris.add(sipFactory.createAddress("sip:neutral@" + host + ":5058").getURI()); + List<ProxyBranch> branches = response.getProxy().createProxyBranches(uris);
+                       response.getProxy().startProxy();
+               }
        }

        // SipErrorListener methods

--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to