activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan K (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AMQ-1155) "Object reference not set to an instance of an object." exception when closing connection.
Date Tue, 06 Feb 2007 20:04:03 GMT

    [ https://issues.apache.org/activemq/browse/AMQ-1155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38475
] 

Jan K commented on AMQ-1155:
----------------------------

I wanted to provide more information in the description, but it was too late after the "Create"
button. 

When the ActiveMQ connection is being closed, on line 133 in Connection.cs we call  transport.Dispose();.
That calls the Close method in TcpTransport.cs : 

        public void Close()
        {
            if (closed.compareAndSet(false, true))
            {
                socket.Close();
                if (System.Threading.Thread.CurrentThread != readThread)
                    readThread.Join();   //<--- exception is occuring here 
                socketWriter.Close();
                socketReader.Close();
            }
        }

As can be seen from the StackTrace above (in the description), the exception is occuring in
ReadLoop. The line that is failing is :
                try
                {
                    this.commandHandler(this, command);   //<-- the command is null and
this generates the exception
                }


As I understand this, by the time that transport.Dispose() is called (on line 133 in Connection.cs)
, we have already closed the session and the connection to the broker. So, when command =
(Command) Wireformat.Unmarshal(socketReader) is called (on line 131 in TcpTransport.cs) the
command is returned as null but no exception is generated by the Unmarshall call.

My suggestion is to change the code to
                try
                { 
	if (command != null)  //<--- To prevent an exception when the command is null
	         this.commandHandler(this, command);
                }



> "Object reference not set to an instance of an object." exception when closing connection.
> ------------------------------------------------------------------------------------------
>
>                 Key: AMQ-1155
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1155
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, NMS (C# client)
>    Affects Versions: 4.1.0
>         Environment: WINXP SP2 
>            Reporter: Jan K
>
>    at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line
80
>    at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line
334
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command)
in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command)
in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception
command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line
102
>    at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line
150
>    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback
callback, Object state)
>    at System.Threading.ThreadHelper.ThreadStart()

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message