From: <tan...@us...> - 2003-01-21 14:26:51
|
Update of /cvsroot/openjms/openjms/src/main/org/exolab/jms/client In directory sc8-pr-cvs1:/tmp/cvs-serv24934/src/main/org/exolab/jms/client Modified Files: JmsQueueSender.java Log Message: fixed NPE if sender closed twice Index: JmsQueueSender.java =================================================================== RCS file: /cvsroot/openjms/openjms/src/main/org/exolab/jms/client/JmsQueueSender.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** JmsQueueSender.java 12 Oct 2001 07:55:31 -0000 1.5 --- JmsQueueSender.java 21 Jan 2003 14:26:43 -0000 1.6 *************** *** 39,43 **** * OF THE POSSIBILITY OF SUCH DAMAGE. * ! * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved. * * $Id$ --- 39,43 ---- * OF THE POSSIBILITY OF SUCH DAMAGE. * ! * Copyright 2000-2003 (C) Exoffice Technologies Inc. All Rights Reserved. * * $Id$ *************** *** 49,60 **** import javax.jms.JMSException; import javax.jms.QueueSender; import javax.jms.Queue; ! import javax.jms.Message; ! import javax.jms.DeliveryMode; /** ! * This class is used for sending messages to a queue. It extends JmsMessage- ! * Producer.. * * @version $Revision$ $Date$ --- 49,62 ---- + import javax.jms.DeliveryMode; + import javax.jms.InvalidDestinationException; import javax.jms.JMSException; + import javax.jms.Message; import javax.jms.QueueSender; import javax.jms.Queue; ! ! /** ! * This class is used for sending messages to a queue. * * @version $Revision$ $Date$ *************** *** 122,178 **** // implementation of QueueSender.send(message, deliveryMode, priority,ttl) ! public void send(Queue queue, Message message, int deliveryMode, int priority, ! long timeToLive) ! throws JMSException ! { ! try { ! // ensure that a queue has been specified ! if (queue == null) { ! throw new JMSException("send failed : null queue specified"); ! } ! if (message == null) { ! throw new JMSException("send failed : null message specified"); ! } ! // the timestamp, expiration time and the client ids are all ! // generated by the message manager ! if (timeToLive > 0) { ! message.setJMSExpiration(System.currentTimeMillis() + ! timeToLive); ! } else { ! message.setJMSExpiration(0); ! } ! // if the queue is an instance of a TemporaryQueue then ! // override the deliveryMode to NON_PERSISTENT ! if (queue instanceof JmsTemporaryQueue) { ! message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); ! } else { ! message.setJMSDeliveryMode(deliveryMode); ! } ! message.setJMSPriority(priority); ! message.setJMSDestination(queue); ! super.sendMessage(message); ! } catch (Exception exception) { ! throw new JMSException("Error in send " + exception); } } // overwrites of JmsMessageProducer.close ! public void close() ! throws JMSException ! { ! // unregister this producer from the session before closing.amd then ! // call the base class method. ! ((JmsQueueSession)_session).removeSender(this); ! super.close(); } // overwrites of JmsMessageProducer.destroy ! public void destroy() ! throws JMSException ! { _queue = null; super.destroy(); --- 124,172 ---- // implementation of QueueSender.send(message, deliveryMode, priority,ttl) ! public void send(Queue queue, Message message, int deliveryMode, ! int priority, long timeToLive) throws JMSException { ! if (queue == null) { ! throw new InvalidDestinationException("Argument 'queue' is null"); ! } ! if (message == null) { ! throw new JMSException("Argument 'message' is null"); ! } ! // the timestamp, expiration time and the client ids are all ! // generated by the message manager ! if (timeToLive > 0) { ! message.setJMSExpiration(System.currentTimeMillis() + ! timeToLive); ! } else { ! message.setJMSExpiration(0); ! } ! // if the queue is an instance of a TemporaryQueue then ! // override the deliveryMode to NON_PERSISTENT ! if (queue instanceof JmsTemporaryQueue) { ! message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); ! } else { ! message.setJMSDeliveryMode(deliveryMode); } + + message.setJMSPriority(priority); + message.setJMSDestination(queue); + super.sendMessage(message); } // overwrites of JmsMessageProducer.close ! public void close() throws JMSException { ! if (_session != null) { ! // unregister this producer from the session before closing. ! // and then call the base class method. ! ((JmsQueueSession)_session).removeSender(this); ! super.close(); ! } } // overwrites of JmsMessageProducer.destroy ! public void destroy() throws JMSException { _queue = null; super.destroy(); |