[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjms-developer
Subject:    [openjms-developer] PATCH : jmsServerSessionPool
From:       "Day, Jem BGI WAC" <Jem.Day () barclaysglobal ! com>
Date:       2003-01-30 21:33:00
[Download RAW message or body]

Hi,

  There seemed to be a potential synchronization problem when
  an attempt was made to obtain a session from the Pool.

  I changed getServerSession() to :


  Attached is a diff file.

  public ServerSession getServerSession()
        throws JMSException
    {
        ServerSession result = null;

        try
        {
            synchronized(sessionPool_)
            {

                while (sessionPool_.size() == 0)
                {
                    try {
                        // Wait for a Session to be returned.
                        sessionPool_.wait();
                    }
                    catch (InterruptedException ie)
                    {
                        // Swallow this
                    }
                }

                // Grab a Session.
                result = (ServerSession)sessionPool_.remove(0);
            }

        }
        catch (Exception exception)
        {
            throw new JMSException("Error in getServerSession " +
exception);
        }

        return result;
    }

Jem..

 

  
 <<diff.txt>> 

["diff.txt" (text/plain)]

cvs -z9 diff JmsServerSessionPool.java (in directory \
                C:\open-source\openjms\src\main\org\exolab\jms\client)
Index: JmsServerSessionPool.java
===================================================================
RCS file: /cvsroot/openjms/openjms/src/main/org/exolab/jms/client/JmsServerSessionPool.java,v
 retrieving revision 1.3
diff -r1.3 JmsServerSessionPool.java
47c47
<  * 
---
> *
62,63c62,63
<  * This class is an example implements of the ServerSessionPool interface, 
<  * which is primarily by the application server facility. It is the 
---
> * This class is an example implements of the ServerSessionPool interface,
> * which is primarily by the application server facility. It is the
66c66
<  * The ServerSessionPool manages a collection of ServerSession objects, 
---
> * The ServerSessionPool manages a collection of ServerSession objects,
75c75
<     implements ServerSessionPool 
---
> implements ServerSessionPool
90c90
<      * @param       listener        message listener that sessions will be 
---
> * @param       listener        message listener that sessions will be
94c94
<         
---
> 
100c100
<                // only assing it if it is greater than zero 
---
> // only assing it if it is greater than zero
112c112
<                         new JmsServerSession(serverSessionPool__, listener));   
---
> new JmsServerSession(serverSessionPool__, listener));
130c130
<      * If init hasn't been called before retrieving the instance then a 
---
> * If init hasn't been called before retrieving the instance then a
148c148
<     public ServerSession getServerSession() 
---
> public ServerSession getServerSession()
155,156c155
<             // put an upper limit on the amount of time it waits
<             for (;;)
---
> synchronized(sessionPool_)
158,163c157,158
<                 if (sessionPool_.size() > 0) 
<                 {
<                     result = (ServerSession)sessionPool_.remove(0);
<                     break;
<                 }
<                 else
---
> 
> while (sessionPool_.size() == 0)
165,170c160,162
<                     try
<                     {
<                         synchronized (sessionPool_)
<                         {
<                             sessionPool_.wait();
<                         }
---
> try {
> // Wait for a Session to be returned.
> sessionPool_.wait();
172c164
<                     catch (InterruptedException exception)
---
> catch (InterruptedException ie)
174c166
<                         // ignore the error
---
> // Swallow this
176a169,171
> 
> // Grab a Session.
> result = (ServerSession)sessionPool_.remove(0);
177a173
> 
181c177
<             throw new JMSException("Error in getServerSession " + exception); 
---
> throw new JMSException("Error in getServerSession " + exception);
189c185
<      * Recycle the specified server session by appending it to the end of 
---
> * Recycle the specified server session by appending it to the end of
212,213c208,209
<     
<     
---
> 
> 
240c236
<     private static boolean init__ = false; 
---
> private static boolean init__ = false;


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
openjms-developer mailing list
openjms-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openjms-developer

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic