1 Reply Latest reply on Mar 26, 2015 2:15 PM by Justin Bertram

    HornetQConnectionFactory throws NullPointerException in its finalize method

    Stanislav Parkhomenko Newbie

      Hi,

       

      I am using hornetq-jms-client 2.4.5.Final library.

      When I instantiate its default constructor

       

      public HornetQConnectionFactory()
      {
        serverLocator = null;
      }
      

       

      the serverLocator attribute is set to null, so when the GC destroys the object in its finalize method

       

      protected void finalize() throws Throwable
      {
         try
         {
            serverLocator.close();
         }
         catch (Exception e)
         {
            e.printStackTrace();
            //not much we can do here
         }
         super.finalize();
      }
      

       

      I'm getting a NullPointerException when serverLocator.close is being invoked.

       

      Is there a way not to avoid this?

       

      Thanks,

      Stas