Hi Susumu,
Thank you for the test case. Is this a patch you want to contribute to Apache?
I have updated the "Response syncSendPacket(Command command, int
timeout)" method so that it instead of NPE on a timeout, it will
return a null response.
On 4/17/06, Susumu Moro <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I found that NullPointerException will occur in ActiveMQConnection#Close().
> Especially, the NullPointerException occurs at
> ActiveMQConnection#syncSendPacket(Command,int) with
> ResponseCorrelator#request(Command,int).
> To reproduce the case, I wrote a simple JUnit testcase.
> Is this case a bug or a feature?
> Would anyone please check the case with the following JUnit testcase.
>
> -- the JUnit TestCase --
>
> package org.apache.activemq;
>
> import java.io.IOException;
>
> import javax.jms.JMSException;
>
> import org.apache.activemq.command.ActiveMQMessage;
> import org.apache.activemq.command.ActiveMQTextMessage;
> import org.apache.activemq.command.Command;
> import org.apache.activemq.command.ConnectionInfo;
> import org.apache.activemq.command.Response;
> import org.apache.activemq.management.JMSStatsImpl;
> import org.apache.activemq.openwire.CommandIdComparator;
> import org.apache.activemq.transport.ResponseCorrelator;
> import org.apache.activemq.transport.Transport;
> import org.apache.activemq.transport.TransportSupport;
> import org.apache.activemq.transport.mock.MockTransport;
> import org.apache.activemq.transport.mock.MockTransportFactory;
> import org.apache.activemq.util.ServiceStopper;
> import org.omg.PortableInterceptor.ACTIVE;
>
> import junit.framework.TestCase;
>
> public class SyncSendTimeOutTest extends TestCase {
>
> public static void main(String[] args) {
> junit.swingui.TestRunner.run(SyncSendTimeOutTest.class);
> }
>
> private Transport mock;
> private Transport testTarget;
> private ActiveMQConnection connection;
> protected void setUp() throws Exception {
> // create new transport as mock object
> mock = new TransportSupport(){
> protected void doStop(ServiceStopper arg0) throws
> Exception {}
> protected void doStart() throws Exception {}
> public void oneway(Command cmd) throws IOException {
> // System.out.println(cmd);
>
> // only stop response of activemq message
> if( !(cmd instanceof ActiveMQMessage) &&
> cmd.isResponseRequired() ){
> Response r = new Response();
> r.setCorrelationId(
> cmd.getCommandId() );
> getTransportListener().onCommand( r );
> }
> }
> };
>
> // create new ResponseCorrelator transport for test
> testTarget = new ResponseCorrelator(mock);
>
> // create new ActiveMQConnection with responseCorrelator
> transport
> connection = new ActiveMQConnection( testTarget, new
> JMSStatsImpl() );
> connection.start();
>
> super.setUp();
> }
>
> public void testSyncSendWithTimeOut10Mill() throws Exception {
> try {
> connection.syncSendPacket( new ActiveMQTextMessage(),
> 10 );
> fail();
> }catch( JMSException e ){
>
> }
> }
> public void testSyncSendWithTimeOut100Mill() throws Exception {
> try {
> connection.syncSendPacket( new ActiveMQTextMessage(),
> 100 );
> fail();
> }catch( JMSException e ){}
> }
> public void testSyncSendWithTimeOut1000Mill() throws Exception {
> try {
> connection.syncSendPacket( new ActiveMQTextMessage(),
> 1000 );
> fail();
> }catch( JMSException e ){}
> }
> }
>
> -- end the JUnit TestCase --
>
> sincerely,
>
> --
> Susumu MORO <[EMAIL PROTECTED]>
> Open Source Software Development Center, NTT DATA CORPORATION
>
> --
> View this message in context:
> http://www.nabble.com/NullPointerException-occurs-at-ActiveMQConnection-close%28%29-%284.0RC3%29-t1460174.html#a3946245
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
Regards,
Hiram