<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.jacorb.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://www.jacorb.org/bugzilla/"
          
          maintainer="jacorb@goots.org"
>

    <bug>
          <bug_id>960</bug_id>
          
          <creation_ts>2013-07-31 17:12:10 +0000</creation_ts>
          <short_desc>ORB interception mechanism doesn&apos;t transfer ServiceContexts properly in local invocations when application interceptors raise exceptions</short_desc>
          <delta_ts>2013-11-20 09:38:04 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>JacORB</product>
          <component>ORB</component>
          <version>3.1</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Amadeu A. Barbosa Jr">amadeu</reporter>
          <assigned_to name="Mailinglist to track bugs">jacorb-bugs</assigned_to>
          <cc>jacorb</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3047</commentid>
    <comment_count>0</comment_count>
      <attachid>422</attachid>
    <who name="Amadeu A. Barbosa Jr">amadeu</who>
    <bug_when>2013-07-31 17:12:10 +0000</bug_when>
    <thetext>Created attachment 422
Sample code that manifest the bug

I observed a bug in org.jacorb.orb.Delegate.servant_preinvoke method when both server and client side are the same process using the same ORB. The client interceptors don&apos;t have access to reply ServiceContexts in receive_exception interception point as should be (conform to CORBA spec). The problem doesn&apos;t occur in remote invocation cenario.

I attached a sample code that manifest this bug. The mainclass demo.InterceptorSameORBServerAndClient manifest this bug. Another classes like demo.InterceptorServer and demo.InterceptorClient show that this bug doesn&apos;t affect the remote cenario (when the invocation is remote). Probably when the server side use a differente ORB than the client side the problem probably doesn&apos;t occur also.

Explanation about my test: The demo.ServerRequestInterceptorImpl implements receive_request and put a ServiceContext with 1234 ID in the ServerRequestInfo and raises a NO_PERMISSION exception. After that, the demo.ClientRequestInterceptorImpl implements receive_exception and try to get the reply ServiceContext with 1234 ID to extract some the information that I put there previously but I got a BAD_PARAM exception as showed in the stacktrace:

SEVERE: unexpected exception during servant_preinvoke
org.omg.CORBA.BAD_PARAM: No ServiceContext with id 1234
	at org.jacorb.orb.portableInterceptor.RequestInfoImpl.get_reply_service_context(RequestInfoImpl.java:192)
	at org.jacorb.orb.portableInterceptor.ClientRequestInfoImpl.get_reply_service_context(ClientRequestInfoImpl.java:394)
	at demo.ClientRequestInterceptorImpl.receive_exception(ClientRequestInterceptorImpl.java:26)
	at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.invoke(ClientInterceptorIterator.java:138)
	at org.jacorb.orb.portableInterceptor.AbstractInterceptorIterator.iterate(AbstractInterceptorIterator.java:66)
	at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.iterate(ClientInterceptorIterator.java:87)
	at org.jacorb.orb.DefaultClientInterceptorHandler.invokeInterceptors(DefaultClientInterceptorHandler.java:328)
	at org.jacorb.orb.DefaultClientInterceptorHandler.handle_receive_exception(DefaultClientInterceptorHandler.java:261)
	at org.jacorb.orb.DefaultClientInterceptorHandler.handle_receive_exception(DefaultClientInterceptorHandler.java:231)
	at org.jacorb.orb.Delegate.servant_preinvoke(Delegate.java:2755)
	at org.omg.CORBA.portable.ObjectImpl._servant_preinvoke(ObjectImpl.java:135)
	at demo._HelloStub.sayHello(_HelloStub.java:73)
	at demo.InterceptorSameORBServerAndClient.main(InterceptorSameORBServerAndClient.java:33)
Exception in thread &quot;main&quot; org.omg.CORBA.BAD_PARAM: No ServiceContext with id 1234
	at org.jacorb.orb.portableInterceptor.RequestInfoImpl.get_reply_service_context(RequestInfoImpl.java:192)
	at org.jacorb.orb.portableInterceptor.ClientRequestInfoImpl.get_reply_service_context(ClientRequestInfoImpl.java:394)
	at demo.ClientRequestInterceptorImpl.receive_exception(ClientRequestInterceptorImpl.java:26)
	at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.invoke(ClientInterceptorIterator.java:138)
	at org.jacorb.orb.portableInterceptor.AbstractInterceptorIterator.iterate(AbstractInterceptorIterator.java:66)
	at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.iterate(ClientInterceptorIterator.java:87)
	at org.jacorb.orb.DefaultClientInterceptorHandler.invokeInterceptors(DefaultClientInterceptorHandler.java:328)
	at org.jacorb.orb.DefaultClientInterceptorHandler.handle_receive_exception(DefaultClientInterceptorHandler.java:261)
	at org.jacorb.orb.DefaultClientInterceptorHandler.handle_receive_exception(DefaultClientInterceptorHandler.java:231)
	at org.jacorb.orb.Delegate.servant_preinvoke(Delegate.java:2755)
	at org.omg.CORBA.portable.ObjectImpl._servant_preinvoke(ObjectImpl.java:135)
	at demo._HelloStub.sayHello(_HelloStub.java:73)
	at demo.InterceptorSameORBServerAndClient.main(InterceptorSameORBServerAndClient.java:33)

I studied the JacORB ORB code and I tried a very simple patch that seems to resolve this issue. I&apos;d like to ask you to analyse it:

--- jacorb-3.1-sources-upstream/src/org/jacorb/orb/Delegate.java	2012-08-19 14:26:54.000000000 -0300
+++ jacorb-3.1-sources-bugfix/src/org/jacorb/orb/Delegate.java	2013-07-30 16:05:57.000000000 -0300
@@ -2748,6 +2748,8 @@ public final class Delegate
                {
                    if (interceptors != null &amp;&amp; orb.hasRequestInterceptors())
                    {
+                       Collection&lt;ServiceContext&gt; ctx = sinfo.getReplyServiceContexts();
+                       interceptors.getInfo ().setReplyServiceContexts (ctx.toArray (new ServiceContext[ctx.size ()]));
                        try
                        {
                            if (ex instanceof SystemException)

This bug was observed in JacORB 3.1 but it happens also in master branch code hosted in github also. 
In master branch of github the patch is:
diff --git a/src/org/jacorb/orb/Delegate.java b/src/org/jacorb/orb/Delegate.java
index a4b4166..3c80ffd 100644
--- a/src/org/jacorb/orb/Delegate.java
+++ b/src/org/jacorb/orb/Delegate.java
@@ -2885,6 +2885,8 @@ public final class Delegate
                     {
                         try
                         {
+                            Collection&lt;ServiceContext&gt; ctx = sinfo.getReplyServiceContexts();
+                            interceptors.getInfo ().setReplyServiceContexts (ctx.toArray (new ServiceContext[ctx.size ()]));
                             if (ex instanceof SystemException)
                             {
                                 interceptors.handle_receive_exception ( (SystemException) ex);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3083</commentid>
    <comment_count>1</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2013-11-20 09:38:04 +0000</bug_when>
    <thetext>Fixed by 9659de46abb78a899381ff4f439fbfe5fd246584. Thanks for test and patch.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>422</attachid>
            <date>2013-07-31 17:12:10 +0000</date>
            <delta_ts>2013-07-31 17:12:10 +0000</delta_ts>
            <desc>Sample code that manifest the bug</desc>
            <filename>interceptors.tgz</filename>
            <type>application/x-gzip</type>
            <size>4090</size>
            <attacher name="Amadeu A. Barbosa Jr">amadeu</attacher>
            
              <data encoding="base64">H4sIAFE6+FEAA+0da3PbuDHtTKdjfW8/o+p9kK8W35LS2NZVcZyrbmLLYzu9m15vNDQJS3QokseH
H73x/+if6G/qX+niQYqiSFGKJSU5cxNZIrBYLIBdYLFYSH0nxL6BvdD1A1EYBr7xYu0gSVKn1UL0
vd2m75KisXcCqtpBsiJ3Wp1OW5U7SJJbsqy9QNL6WZmHKAh1H1jRJ7qJo2I8QLu+XkCHNQUl718K
/O6Pv3/x2xcvTnQDDS7QD4gDSXuxAy8FXv+FF3n+33Ike5eX5/wjKfEfeH2bQfnNNP0PhjsRdM+z
sfBzpPu6E1oOfvGzCL0o77fk6861Yaj7l2P8r3tFeu/ovjG2brG/L6vt3pHSe93U1OPjptbqtZqv
pbdSs/X2Te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