[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [Issue 245] Problem with Java CAA Test Case JCA_11017
This is now issue http://osoa.org/jira/browse/JAVA-245 -Anish -- On 9/13/2011 4:07 AM, Mike Edwards wrote: > > Target: sca-j-caa-1.1-testcases-csd02.zip > > Description: > > Testcase JCA_11017 has a problem which has recently been revealed by a > fix to the Apache Tuscany runtime. > > 11017 is a test of Asynchronous capabilities and as a result has code > that is concerned with synchronization between > the activities of multiple threads. > > In the class > /JCA_General_POJO/src/main/java/org/oasisopen/sca/test/service1AsyncRefImpl.java, > there is code that > handles an SCA asynchronous service using callbacks and the > synchronization between the invoking thread and the > callback is handled by means of a CountDownLatch. > > However, the latch is potentially used multiple times, with multiple > calls to the service being made. This requires a > new latch for each request - however, the current code only allocates a > single latch for all subsequent invocations. > This fails causing the incorrect result to be returned to the test > runner client. > > Current code: > > privateCallbackHandler callback = newCallbackHandler(); > privatevolatileString asyncResponse = null; > privateCountDownLatch theLatch = newCountDownLatch(1); > > privateclassCallbackHandler implementsAsyncHandler<String> { > > publicvoidhandleResponse(Response<String> arg0) { > try{ > asyncResponse = (String)arg0.get(); > } catch(ExecutionException e) { > /// An ExecutionException signals that the invocation of the target > service threw the exception > /Throwable t = e.getCause(); > asyncResponse = "Exception received when Response.get() invoked: "+ > t.toString(); > } catch(Exception e) { > asyncResponse = "Exception received when Response.get() invoked: "+ > e.getClass().toString() + " "+ e.getMessage(); > } /// end try > /theLatch.countDown(); > } /// end handleResponse > / > } /// end class CallbackHandler > / > ...... > > if( invoke.equals("asyncCallback")) { > /// Invoke async callback method... > /Future<?> theFuture = reference1.operation1Async(inputs.next(), callback); > if( theFuture == null) { > result += "No Future returned "; > } else{ > result += "Future returned "; > } /// end if > //// Wait for the asynchronous return of the response data from the > invoked service operation > /try{ > theLatch.await(10, TimeUnit.SECONDS); > } catch(InterruptedException e) { > result += "Interrupted exception received when waiting for the async > callback"; > } /// end try > /result += asyncResponse; > } /// end if > / > > > > Proposal: > > Update the code to allocate a new latch for each invocation that expects > an async callback response: > > *private*CallbackHandler callback= *new*CallbackHandler(); > *private**volatile*String asyncResponse= *null*; > *private**volatile*CountDownLatch theLatch= *null*; > > *private**class*CallbackHandler *implements*AsyncHandler<String> { > > *public**void*handleResponse(Response<String> arg0) { > *try*{ > asyncResponse= (String)arg0.get(); > } *catch*(ExecutionException e) { > // An ExecutionException signals that the invocation of the target > service threw the exception > Throwable t = e.getCause(); > asyncResponse= "Exception received when Response.get() invoked: "+ > t.toString(); > } *catch*(Exception e) { > asyncResponse= "Exception received when Response.get() invoked: "+ > e.getClass().toString() + " "+ e.getMessage(); > } // end try > theLatch.countDown(); > } // end handleResponse > > } // end class CallbackHandler > > ........ > > > *if*( invoke.equals("asyncCallback")) { > // Create a new latch to coordinate between this invoking method and the > _callback_ method > theLatch= *new*CountDownLatch(1); > // Invoke _async_ _callback_ method... > Future<?> theFuture = reference1.operation1Async(inputs.next(), callback); > *if*( theFuture == *null*) { > result += "No Future returned "; > } *else*{ > result += "Future returned "; > } // end if > // Wait for the asynchronous return of the response data from the > invoked service operation > *try*{ > theLatch.await(10, TimeUnit./SECONDS/); > } *catch*(InterruptedException e) { > result += "Interrupted exception received when waiting for the async > callback"; > } // end try > result += asyncResponse; > } // end if > > > Yours, Mike > ------------------------------------------------------------------------ > Dr Mike Edwards Mail Point 137, Hursley Park > <http://www.ibm.com/> > STSM Winchester, Hants SO21 2JN > SCA, Cloud Computing & Services Standards United Kingdom > Co-Chair OASIS SCA Assembly TC > Chair UK ISO SC38 mirror committee (Cloud & SOA) > IBM Software Group > Phone: +44-1962 818014 > Mobile: +44-7802-467431 (274097) > e-mail: mike_edwards@uk.ibm.com > > > > > > ------------------------------------------------------------------------ > > / > / > > /Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU/ > > > > > >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]