Hi, this is Coverity Scan for current git master, after the message encoding PR was merged. Forwarded with hope something on it is real issue. See https://scan.coverity.com/projects/apache-activemq-artemis for full details.
---------- Forwarded message ---------- From: <[email protected]> Date: Mon, Mar 6, 2017 at 4:45 PM Subject: New Defects reported by Coverity Scan for Apache ActiveMQ Artemis To: [email protected] Hi, Please find the latest report on new defect(s) introduced to Apache ActiveMQ Artemis found with Coverity Scan. 16 new defect(s) introduced to Apache ActiveMQ Artemis found with Coverity Scan. 30 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan. New defect(s) Reported-by: Coverity Scan Showing 16 of 16 defect(s) ** CID 1415199: Null pointer dereferences (REVERSE_INULL) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java: 2491 in org.apache.activemq.artemis.core.server.impl.QueueImpl.makeCopy(org.apache.activemq.artemis.core.server.MessageReference, boolean, boolean)() ________________________________________________________________________________________________________ *** CID 1415199: Null pointer dereferences (REVERSE_INULL) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java: 2491 in org.apache.activemq.artemis.core.server.impl.QueueImpl.makeCopy(org.apache.activemq.artemis.core.server.MessageReference, boolean, boolean)() 2485 2486 long newID = storageManager.generateID(); 2487 2488 Message copy = message.copy(newID); 2489 2490 if (copyOriginalHeaders) { >>> CID 1415199: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "ref" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 2491 copy.referenceOriginalMessage(message, ref != null ? ref.getQueue().getName().toString() : null); 2492 } 2493 2494 if (expiry) { 2495 copy.putLongProperty(Message.HDR_ACTUAL_EXPIRY_TIME.toString(), System.currentTimeMillis()); 2496 } ** CID 1415198: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTRetainMessageManager.java: 58 in org.apache.activemq.artemis.core.protocol.mqtt.MQTTRetainMessageManager.handleRetainedMessage(org.apache.activemq.artemis.api.core.Message, java.lang.String, boolean, org.apache.activemq.artemis.core.transaction.Transaction)() ________________________________________________________________________________________________________ *** CID 1415198: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTRetainMessageManager.java: 58 in org.apache.activemq.artemis.core.protocol.mqtt.MQTTRetainMessageManager.handleRetainedMessage(org.apache.activemq.artemis.api.core.Message, java.lang.String, boolean, org.apache.activemq.artemis.core.transaction.Transaction)() 52 queue = session.getServerSession().createQueue(retainAddress, retainAddress, null, false, true); 53 } 54 55 56 try (LinkedListIterator<MessageReference> iterator = queue.iterator()) { 57 synchronized (queue) { >>> CID 1415198: Null pointer dereferences (NULL_RETURNS) >>> Calling a method on null object "iterator". 58 if (iterator.hasNext()) { 59 MessageReference ref = iterator.next(); 60 iterator.remove(); 61 queue.acknowledge(tx, ref); 62 } 63 ** CID 1415197: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java: 238 in org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession.sendMessage(org.apache.activemq.artemis.core.server.MessageReference, org.apache.activemq.artemis.api.core.Message, org.apache.activemq.artemis.core.server.ServerConsumer, int)() ________________________________________________________________________________________________________ *** CID 1415197: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java: 238 in org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession.sendMessage(org.apache.activemq.artemis.core.server.MessageReference, org.apache.activemq.artemis.api.core.Message, org.apache.activemq.artemis.core.server.ServerConsumer, int)() 232 public int sendMessage(MessageReference reference, 233 org.apache.activemq.artemis.api.core.Message message, 234 ServerConsumer consumer, 235 int deliveryCount) { 236 AMQConsumer theConsumer = (AMQConsumer) consumer.getProtocolData(); 237 // TODO: use encoders and proper conversions here >>> CID 1415197: Null pointer dereferences (NULL_RETURNS) >>> Calling a method on null object "theConsumer". 238 return theConsumer.handleDeliver(reference, message.toCore(), deliveryCount); 239 } 240 241 @Override 242 public int sendLargeMessage(MessageReference reference, 243 org.apache.activemq.artemis.api.core.Message message, ** CID 1415196: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java: 395 in org.apache.activemq.artemis.core.protocol.stomp.StompSession.sendInternalLarge(org.apache.activemq.artemis.core.message.impl.CoreMessage, boolean)() ________________________________________________________________________________________________________ *** CID 1415196: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java: 395 in org.apache.activemq.artemis.core.protocol.stomp.StompSession.sendInternalLarge(org.apache.activemq.artemis.core.message.impl.CoreMessage, boolean)() 389 long id = storageManager.generateID(); 390 LargeServerMessage largeMessage = storageManager.createLargeMessage(id, message); 391 392 byte[] bytes = new byte[message.getBodyBuffer().writerIndex() - CoreMessage.BODY_OFFSET]; 393 message.getBodyBuffer().readBytes(bytes); 394 >>> CID 1415196: Null pointer dereferences (NULL_RETURNS) >>> Calling a method on null object "largeMessage". 395 largeMessage.addBytes(bytes); 396 397 largeMessage.releaseResources(); 398 399 largeMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, bytes.length); 400 ** CID 1415195: Null pointer dereferences (NULL_RETURNS) /artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java: 549 in org.apache.activemq.artemis.api.core.Message.toMap()() ________________________________________________________________________________________________________ *** CID 1415195: Null pointer dereferences (NULL_RETURNS) /artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java: 549 in org.apache.activemq.artemis.api.core.Message.toMap()() 543 544 /** 545 * @return Returns the message in Map form, useful when encoding to JSON 546 */ 547 default Map<String, Object> toMap() { 548 Map map = toPropertyMap(); >>> CID 1415195: Null pointer dereferences (NULL_RETURNS) >>> Calling a method on null object "map". 549 map.put("messageID", getMessageID()); 550 Object userID = getUserID(); 551 if (getUserID() != null) { 552 map.put("userID", "ID:" + userID.toString()); 553 } 554 ** CID 1415194: Null pointer dereferences (NULL_RETURNS) /artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java: 173 in org.apache.activemq.artemis.api.core.Message.getDeliveryAnnotationPropertyString(org.apache.activemq.artemis.api.core.SimpleString)() ________________________________________________________________________________________________________ *** CID 1415194: Null pointer dereferences (NULL_RETURNS) /artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java: 173 in org.apache.activemq.artemis.api.core.Message.getDeliveryAnnotationPropertyString(org.apache.activemq.artemis.api.core.SimpleString)() 167 168 default SimpleString getDeliveryAnnotationPropertyString(SimpleString property) { 169 Object obj = getDeliveryAnnotationProperty(property); 170 if (obj instanceof SimpleString) { 171 return (SimpleString)obj; 172 } else { >>> CID 1415194: Null pointer dereferences (NULL_RETURNS) >>> Calling a method on null object "obj". 173 return SimpleString.toSimpleString(obj.toString()); 174 } 175 } 176 177 default void cleanupInternalProperties() { 178 // only on core ** CID 1415193: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java: 489 in org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback.sendMessage(org.apache.activemq.artemis.core.server.MessageReference, org.apache.activemq.artemis.api.core.Message, org.apache.activemq.artemis.core.server.ServerConsumer, int)() ________________________________________________________________________________________________________ *** CID 1415193: Null pointer dereferences (NULL_RETURNS) /artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java: 489 in org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback.sendMessage(org.apache.activemq.artemis.core.server.MessageReference, org.apache.activemq.artemis.api.core.Message, org.apache.activemq.artemis.core.server.ServerConsumer, int)() 483 484 message.removeProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString()); 485 486 ProtonServerSenderContext plugSender = (ProtonServerSenderContext) consumer.getProtocolContext(); 487 488 try { >>> CID 1415193: Null pointer dereferences (NULL_RETURNS) >>> Calling a method on null object "plugSender". 489 return plugSender.deliverMessage(CoreAmqpConverter.checkAMQP(message), deliveryCount); 490 } catch (Exception e) { 491 synchronized (connection.getLock()) { 492 plugSender.getSender().setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, e.getMessage())); 493 connection.flush(); 494 } ** CID 1415192: Program hangs (LOCK_INVERSION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java: 1040 in org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl$3.run()() ________________________________________________________________________________________________________ *** CID 1415192: Program hangs (LOCK_INVERSION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java: 1040 in org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl$3.run()() 1034 // Inner classes 1035 // ------------------------------------------------------------------------ 1036 1037 private final Runnable resumeLargeMessageRunnable = new Runnable() { 1038 @Override 1039 public void run() { >>> CID 1415192: Program hangs (LOCK_INVERSION) >>> Acquiring lock "ServerConsumerImpl.lock". 1040 synchronized (lock) { 1041 try { 1042 if (largeMessageDeliverer == null || largeMessageDeliverer.deliver()) { 1043 forceDelivery(); 1044 } 1045 } catch (Exception e) { ** CID 1415191: Concurrent data access violations (GUARDED_BY_VIOLATION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java: 924 in org.apache.activemq.artemis.core.server.impl.QueueImpl.hasMatchingConsumer(org.apache.activemq.artemis.api.core.Message)() ________________________________________________________________________________________________________ *** CID 1415191: Concurrent data access violations (GUARDED_BY_VIOLATION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java: 924 in org.apache.activemq.artemis.core.server.impl.QueueImpl.hasMatchingConsumer(org.apache.activemq.artemis.api.core.Message)() 918 public synchronized Set<Consumer> getConsumers() { 919 return new HashSet<>(consumerSet); 920 } 921 922 @Override 923 public boolean hasMatchingConsumer(final Message message) { >>> CID 1415191: Concurrent data access violations (GUARDED_BY_VIOLATION) >>> Accessing "consumerList" without holding lock "QueueImpl.this". Elsewhere, "org.apache.activemq.artemis.core.server.impl.QueueImpl.consumerList" is accessed with "QueueImpl.this" held 13 out of 17 times. 924 for (ConsumerHolder holder : consumerList) { 925 Consumer consumer = holder.consumer; 926 927 if (consumer instanceof Redistributor) { 928 continue; 929 } ** CID 1415190: Concurrent data access violations (GUARDED_BY_VIOLATION) /artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java: 164 in org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage.getMessageAnnotations()() ________________________________________________________________________________________________________ *** CID 1415190: Concurrent data access violations (GUARDED_BY_VIOLATION) /artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java: 164 in org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage.getMessageAnnotations()() 158 parsedHeaders = true; 159 } 160 } 161 162 public MessageAnnotations getMessageAnnotations() { 163 parseHeaders(); >>> CID 1415190: Concurrent data access violations (GUARDED_BY_VIOLATION) >>> Accessing "_messageAnnotations" without holding lock "AMQPMessage.this". Elsewhere, "org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage._messageAnnotations" is accessed with "AMQPMessage.this" held 2 out of 3 times. 164 return _messageAnnotations; 165 } 166 167 public Header getHeader() { 168 parseHeaders(); 169 return _header; ** CID 1415189: Null pointer dereferences (FORWARD_NULL) /tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java: 1296 in org.apache.activemq.artemis.tests.integration.amqp.ProtonTest$7.run()() ________________________________________________________________________________________________________ *** CID 1415189: Null pointer dereferences (FORWARD_NULL) /tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java: 1296 in org.apache.activemq.artemis.tests.integration.amqp.ProtonTest$7.run()() 1290 exceptions.add(e); 1291 e.printStackTrace(); 1292 } finally { 1293 try { 1294 // if the createconnecion wasn't commented out 1295 if (connectionConsumer != connection) { >>> CID 1415189: Null pointer dereferences (FORWARD_NULL) >>> Calling a method on null object "connectionConsumer". 1296 connectionConsumer.close(); 1297 } 1298 } catch (Throwable ignored) { 1299 // NO OP 1300 } 1301 } ** CID 1415188: Null pointer dereferences (FORWARD_NULL) ________________________________________________________________________________________________________ *** CID 1415188: Null pointer dereferences (FORWARD_NULL) /artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java: 464 in org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter.processMessageProperties(org.apache.activemq.artemis.api.core.Message)() 458 message.putIntProperty(key, Integer.parseInt(value)); 459 break; 460 case XmlDataConstants.PROPERTY_TYPE_LONG: 461 message.putLongProperty(key, Long.parseLong(value)); 462 break; 463 case XmlDataConstants.PROPERTY_TYPE_SIMPLE_STRING: >>> CID 1415188: Null pointer dereferences (FORWARD_NULL) >>> Passing "null" to "putStringProperty", which dereferences it. (The virtual call resolves to "org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage.putStringProperty".) 464 message.putStringProperty(new SimpleString(key), value == null ? null : SimpleString.toSimpleString(value)); 465 break; 466 case XmlDataConstants.PROPERTY_TYPE_STRING: 467 message.putStringProperty(key, value); 468 break; 469 } ** CID 1415187: Null pointer dereferences (FORWARD_NULL) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java: 2377 in org.apache.activemq.artemis.core.server.impl.QueueImpl.moveBetweenSnFQueues(org.apache.activemq.artemis.api.core.SimpleString, org.apache.activemq.artemis.core.transaction.Transaction, org.apache.activemq.artemis.core.server.MessageReference)() ________________________________________________________________________________________________________ *** CID 1415187: Null pointer dereferences (FORWARD_NULL) /artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java: 2377 in org.apache.activemq.artemis.core.server.impl.QueueImpl.moveBetweenSnFQueues(org.apache.activemq.artemis.api.core.SimpleString, org.apache.activemq.artemis.core.transaction.Transaction, org.apache.activemq.artemis.core.server.MessageReference)() 2371 2372 // there should only be one of these properties so potentially save some loop iterations 2373 break; 2374 } 2375 } 2376 >>> CID 1415187: Null pointer dereferences (FORWARD_NULL) >>> Passing null pointer "oldRouteToIDs" to "wrap", which dereferences it. 2377 ByteBuffer oldBuffer = ByteBuffer.wrap(oldRouteToIDs); 2378 2379 RoutingContext routingContext = new RoutingContextImpl(tx); 2380 2381 /* this algorithm will look at the old route and find the new remote queue bindings where the messages should go 2382 * and route them there directly ** CID 1415186: Null pointer dereferences (FORWARD_NULL) ________________________________________________________________________________________________________ *** CID 1415186: Null pointer dereferences (FORWARD_NULL) /artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java: 168 in org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage.setJMSDestination(javax.jms.Destination)() 162 } 163 } 164 165 @Override 166 public final void setJMSDestination(Destination destination) throws JMSException { 167 if (destination == null) { >>> CID 1415186: Null pointer dereferences (FORWARD_NULL) >>> Passing "null" to "setAddress", which dereferences it. (The virtual call resolves to "org.apache.activemq.artemis.core.message.impl.CoreMessage.setAddress".) 168 message.setAddress((SimpleString)null); 169 } else { 170 message.setAddress(((ActiveMQDestination) destination).getSimpleAddress()); 171 } 172 173 } ** CID 1409771: Program hangs (LOCK_INVERSION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java: 136 in org.apache.activemq.artemis.core.paging.cursor.impl.PageCursorProviderImpl.getPageCache(long)() ________________________________________________________________________________________________________ *** CID 1409771: Program hangs (LOCK_INVERSION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java: 136 in org.apache.activemq.artemis.core.paging.cursor.impl.PageCursorProviderImpl.getPageCache(long)() 130 } 131 132 @Override 133 public PageCache getPageCache(final long pageId) { 134 try { 135 PageCache cache; >>> CID 1409771: Program hangs (LOCK_INVERSION) >>> Acquiring lock "PageCursorProviderImpl.softCache". 136 synchronized (softCache) { 137 if (pageId > pagingStore.getCurrentWritingPage()) { 138 return null; 139 } 140 141 cache = softCache.get(pageId); ** CID 1409143: (LOCK_INVERSION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java: 1178 in org.apache.activemq.artemis.core.paging.cursor.impl.PageSubscriptionImpl$CursorIterator.moveNext()() /artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java: 1178 in org.apache.activemq.artemis.core.paging.cursor.impl.PageSubscriptionImpl$CursorIterator.moveNext()() ________________________________________________________________________________________________________ *** CID 1409143: (LOCK_INVERSION) /artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java: 1178 in org.apache.activemq.artemis.core.paging.cursor.impl.PageSubscriptionImpl$CursorIterator.moveNext()() 1172 PagedReference message; 1173 1174 PagePosition lastPosition = position; 1175 PagePosition tmpPosition = position; 1176 1177 do { >>> CID 1409143: (LOCK_INVERSION) >>> Acquiring lock "CursorIterator.redeliveries". 1178 synchronized (redeliveries) { 1179 PagePosition redelivery = redeliveries.poll(); 1180 1181 if (redelivery != null) { 1182 // There's a redelivery pending, we will get it out of that pool instead 1183 isredelivery = true; /artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java: 1178 in org.apache.activemq.artemis.core.paging.cursor.impl.PageSubscriptionImpl$CursorIterator.moveNext()() 1172 PagedReference message; 1173 1174 PagePosition lastPosition = position; 1175 PagePosition tmpPosition = position; 1176 1177 do { >>> CID 1409143: (LOCK_INVERSION) >>> Acquiring lock "CursorIterator.redeliveries". 1178 synchronized (redeliveries) { 1179 PagePosition redelivery = redeliveries.poll(); 1180 1181 if (redelivery != null) { 1182 // There's a redelivery pending, we will get it out of that pool instead 1183 isredelivery = true; ________________________________________________________________________________________________________ To view the defects in Coverity Scan visit, https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A-2BWcWUl-2F-2BfV0V05UPxvVjWch-2Bd2MGckcRZSbhom32dlDl11LWEm9nX1rtAWaC-2BDSVBpUSy28m9Zb8yC8TsR8PEkb70GF-2BiZPHs-3D_FskC5xBa3KJMdLzpQ7DMPdi-2Bg7iORJg0iEJDpvzM9wDE9Yd4-2FCN-2Fy8UFapwlOiQj8BC676trfKvMtmIKbTBk8rHbpYpVtj7IPdke9oXdMki3q5c7-2BVqCO-2BSILe5W0BIOA4gulo2mvcwplLzlXigXR7XrojLNrlz2bHWZW5sVS4IJKi-2BQVe-2FN1h8IMGZo9AvK3QbokcUD3GWPImCN6KyNUg-3D-3D To manage Coverity Scan email notifications for "[email protected]", click https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A-2BWcWUl-2F-2BfV0V05UPxvVjWch-2Bd2MGckcRbVDbis712qZDP-2FA8y06Nq4ayNyW5oN6bOTmA3eqVv9aekj-2F0CBXY1ycW0hZjdXilegPumDmuHGy9LK5TWnfvYxQ6gVG5mrC9yxgLSOeowoGl-2Bn30PFzC603ZASlb9JLM4-3D_FskC5xBa3KJMdLzpQ7DMPdi-2Bg7iORJg0iEJDpvzM9wDE9Yd4-2FCN-2Fy8UFapwlOiQj9DmySmy47ocPcPljvITSQpPIWDxbnsrnZ0oVCst2rpreOJrYQyXO-2BxqlNe-2B2h3bTzQrOWh7fZ2rPBoleEXW5Md4T5gnGxY9t1dCRBoh5bwZqGd-2BeQrfKhmuY1FjjqOGrc12hwsXyA5VnXCb0EwiKlw-3D-3D -- Jiří Daněk Messaging QA
