activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino (JIRA)" <>
Subject [jira] Resolved: (AMQ-597) NullPointerException in MemoryBoundedMessageCache
Date Thu, 15 Jun 2006 03:23:51 GMT
     [ ]
Hiram Chirino resolved AMQ-597:

    Fix Version: 3.2.4
     Resolution: Fixed

Hi Matthew,

I think this was fixed since the 3.1 release could you check the 3.2.4 release?  If not the
4.0 release has revamped is memory managment is much better.  I would recommed you upgrade
to 4.0 ASAP.

> NullPointerException in MemoryBoundedMessageCache
> -------------------------------------------------
>          Key: AMQ-597
>          URL:
>      Project: ActiveMQ
>         Type: Bug

>     Versions: 3.1
>  Environment: Windows XP, Java 1.4.1_01
>     Reporter: Matthew Vincent
>      Fix For: 4.0, 3.2.4

> If you put two messages in the MemoryBoundedMessageCache with the same message id, the
MemoryBoundedMessageCache puts itself into an inconsistent state, which causes a NullPointerException
in removeOldest(), on the following line:
>       CacheNode node = (CacheNode) messages.remove(messageID);
>       decrementMemoryUsed(node.message);
> This is because there is no corresponding CacheNode entry for the given messageID.
> The problem is caused by the following block of code, in put(String, ActiveMQMessage):
>             CacheNode oldNode = (CacheNode) messages.put(messageID, newNode);
>             if( oldNode !=null ) {
>                 lruList.remove(oldNode);
>                 decrementMemoryUsed(oldNode.message);
>             }  
> When it removes the existing CacheNode from the messages map, it fails to remove it from
the lruList, causing its entry to be left in the lruList. This means that the lruList will
now contain two entries for the same message id.  The first one to be removed will remove
the only entry in the messages map, and will be fine, but the second one to be removed will
cause a NullPointerException, since there is now no corresponding CacheNode in the messages
> To fix all that needs to be done is change the line:
>                 lruList.remove(oldNode);
> to be
>                 lruList.remove(oldNode.entry);
> so that the entry is correctly removed from the lruList.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message