[ https://issues.apache.org/jira/browse/AMQ-6150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15123663#comment-15123663 ]
ASF GitHub Bot commented on AMQ-6150: ------------------------------------- GitHub user mbreslow opened a pull request: https://github.com/apache/activemq/pull/166 Fix AMQ-6150 (Found 3 instances of impossible casts in the activemq code) Running static analysis on activemq I was able to identify 3 instances of impossible casts in the code. This pull request resolves them. You can merge this pull request into a Git repository by running: $ git pull https://github.com/DevFactory/activemq AMQ-6150-fix-impossible-cast-issues Alternatively you can review and apply these changes as the patch at: https://github.com/apache/activemq/pull/166.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #166 ---- commit 364e10d40569042595ec27ae710c2fd687fa2746 Author: Marc Breslow <marc.bres...@devfactory.com> Date: 2016-01-28T21:39:29Z Fix Impossible Cast issues in MemoryTopicSub: - recoverSubscription() -- map is defined as LinkedHashMap<MessageId, Message> -- msg is defined as <map> entry.getValue() so must be a Message -- condition if (msg.getClass() == MessageId.class) could never be true -- no need to cast at all when using generics - recoverNextMessages() -- basically same code copy/pasted so same fix commit 61f951d0c811b8c9dcde306fa7843aadce70d199 Author: Marc Breslow <marc.bres...@devfactory.com> Date: 2016-01-29T15:51:18Z Removed 2 conditions from ServerSessionPoolImpl that would result in impossible casts. Conditions removed were trying to cast ActiveMQQueueSession and ActiveMQTopicSession to ActiveMQSession which is illegal. Since it isn't obvious what to do if you get an ActiveMQQueueSession or ActiveMQTopicSession from getServerSession() I make it fall back to the else condition which raises an async exception. This is better than getting a ClassCastException at runtime. commit f177a52c62336115dc3df7af0694851046ae670c Author: Marc Breslow <marc.bres...@devfactory.com> Date: 2016-01-29T16:00:31Z Remove impossible cast in MemoryMessageStore commit 509fe1ce8f3e1a6b5b64be4a027487e9c11737a6 Author: Marc Breslow <marc.bres...@devfactory.com> Date: 2016-01-29T16:11:30Z Merge branch 'master' into AMQ-6150-fix-impossible-cast-issues ---- > Found (and fixed) 3 instances of impossible casts in the activemq code > ---------------------------------------------------------------------- > > Key: AMQ-6150 > URL: https://issues.apache.org/jira/browse/AMQ-6150 > Project: ActiveMQ > Issue Type: Bug > Components: Broker > Affects Versions: 5.13.0 > Reporter: Marc Breslow > Priority: Critical > Attachments: 0001-Fix-Impossible-Cast-issues-in-MemoryTopicSub.patch, > 0002-Removed-2-conditions-from-ServerSessionPoolImpl-that.patch, > 0003-Remove-impossible-cast-in-MemoryMessageStore.patch > > > Running static analysis on activemq I was able to identify 3 instances of > impossible casts in the code. Attaching patch files to fix. -- This message was sent by Atlassian JIRA (v6.3.4#6332)