[ 
http://issues.apache.org/jira/browse/AXIS2-572?page=comments#action_12374918 ] 

rnell commented on AXIS2-572:
-----------------------------

It has been my experience is that the looping in the while-loop almost never 
happens, the wait() completes due to a notify() or timeout, and there is no CPU 
performance issue.   

We are very interested in Axis2 because of the JMS support and the async 
features.  Take this feature away, or lessen it's importance and we likely be 
in axis1.x camp.


> Callback timeout incorrectly reported as an AxisFault( null )
> -------------------------------------------------------------
>
>          Key: AXIS2-572
>          URL: http://issues.apache.org/jira/browse/AXIS2-572
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>   Components: client-api
>     Versions: 0.95
>     Reporter: rnell
>     Assignee: Deepal Jayasinghe
>  Attachments: ServiceClient.diff, ServiceClient.diff
>
> The code in ServiceClient.java:418 that waits for a callback reply throws a 
> generic AxisFault( null ) when there is a timeout. Would expect a 
> "responseTimeOut" exception. 
> Also the callback.wait( timeout ) can end prematurely and that situation 
> needs to be handled, see the javadoc for Object.wait(long timeout):
> Current code in ServiceClient.java:418
>        long timeout = options.getTimeOutInMilliSeconds();
>        synchronized (callback) {
>                 try {
>                               callback.wait(timeout);
>                 } catch (InterruptedException e) {
>                               throw new AxisFault(Messages
>                                                 
> .getMessage("responseTimeOut"));
>                 }
>        }
>        // process the resule of the invocation
>        if (callback.envelope != null) {
>                 // building soap enevlop
>                 callback.envelope.build();
>                 // closing tranport
>                 return callback.envelope.getBody().getFirstElement();
>        } else {
>                 if (callback.error instanceof AxisFault) {
>                               throw (AxisFault) callback.error;
>                 } else {
>                               throw new AxisFault(callback.error);
>                 }
>        }
>        
> Suggested code:
>        long timeout = options.getTimeOutInMilliSeconds();
> *      long waitTime = timeout;
> *      long startTime = System.currentTimeMillis();
>        synchronized (callback) {
> *               while( ! callback.isComplete() && waitTime >= 0 ) {
>                               try {
>                                        callback.wait(timeout);
>                               } catch (InterruptedException e) {
> *                                      // We were interrupted for some 
> reason, keep waiting
> *                                      // or throw new AxisFault( "Callback 
> was interrupted by someone?" );
>                               }
> *                             // The wait finished, compute remaining time
> *                             // - wait can end prematurly, see Object.wait( 
> int timeout )
> *                             waitTime = timeout - ( 
> System.currentTimeMillis() - startTime );
>                 }
>        }
>        // process the resule of the invocation
>        if (callback.envelope != null) {
>                 // building soap enevlop
>                 callback.envelope.build();
>                 // closing tranport
>                 return callback.envelope.getBody().getFirstElement();
>        } else {
>                 if (callback.error instanceof AxisFault) {
>                               throw (AxisFault) callback.error;
>                 } else if( callback.error != null ) {
>                               throw new AxisFault(callback.error);
> *               } else if( ! callback.isComplete() ) {
> *                             throw new AxisFault(Messages.getMessage( 
> "responseTimeOut" ) );
> *               } else
> *                             throw new AxisFault( "Callback completed but 
> there was no envelope or error" );
>  }
>  
>  
> This change is necessary because we are quering the isComplete() above.  
> Shouldn't call notify() until the setComplete() has been called.
> Current code in ServiceClient.java:594.
>     public void onComplete(AsyncResult result) {
>                 this.envelope = result.getResponseEnvelope();
>                 this.msgctx = result.getResponseMessageContext();
>                 synchronized (this) {
>                               notify();
>                 }
>        }
> Suggested code in CallbackReceiver:35 
>        public void onComplete(AsyncResult result) {
>                 this.envelope = result.getResponseEnvelope();
>                 this.msgctx = result.getResponseMessageContext();
> *      }
> *      public void setComplete( boolean complete ) {
> *               super.setComplete( complete );
> *               synchronized (this) {
> *                             notify();
> *               }
> *      }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to