This is an automated email from the ASF dual-hosted git repository. michaelpearce pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 57aacf784ce77068fc79f2cde54ca8b9cab99410 Author: Justin Bertram <jbert...@apache.org> AuthorDate: Wed Sep 5 13:49:13 2018 -0500 NO-JIRA fix lgtm.com warnings Warnings enumerated at https://lgtm.com/projects/g/apache/activemq-artemis/alerts/?mode=tree&severity=warning --- .../cli/commands/messages/ConsumerThread.java | 2 +- .../artemis/cli/commands/tools/PrintData.java | 94 +++++++++++----------- .../cli/commands/tools/xml/XMLMessageImporter.java | 8 +- .../artemis/core/server/NetworkHealthCheck.java | 14 +++- .../activemq/artemis/utils/FactoryFinder.java | 9 +-- .../utils/collections/ConcurrentLongHashMap.java | 6 +- .../core/client/impl/ClientProducerImpl.java | 2 +- .../core/impl/ActiveMQClientProtocolManager.java | 4 +- .../core/protocol/core/impl/ChannelImpl.java | 2 +- .../core/remoting/impl/netty/NettyConnector.java | 6 +- .../jdbc/store/drivers/AbstractJDBCDriver.java | 2 +- .../artemis/jms/client/ActiveMQMessage.java | 4 +- .../core/io/aio/AIOSequentialFileFactory.java | 4 +- .../protocol/amqp/converter/CoreAmqpConverter.java | 8 +- .../core/protocol/openwire/OpenWireConnection.java | 8 +- .../openwire/OpenWireMessageConverter.java | 2 +- .../artemis/ra/ActiveMQRAManagedConnection.java | 9 +-- .../artemis/ra/ConnectionFactoryProperties.java | 7 +- .../artemis/rest/topic/SubscriptionsResource.java | 2 +- .../activemq/artemis/rest/util/TimeoutTask.java | 2 +- .../core/config/impl/ConfigurationImpl.java | 3 - .../core/management/impl/QueueControlImpl.java | 2 +- .../core/postoffice/impl/PostOfficeImpl.java | 2 +- .../core/server/cluster/ha/ColocatedHAManager.java | 4 +- .../cluster/impl/ClusterConnectionBridge.java | 18 ++--- .../core/server/impl/LiveOnlyActivation.java | 6 +- .../artemis/core/server/impl/QueueImpl.java | 5 +- .../core/server/impl/ServerConsumerImpl.java | 2 +- .../server/impl/SharedNothingBackupActivation.java | 2 +- .../plugin/ActiveMQServerConsumerPlugin.java | 2 +- .../core/transaction/impl/TransactionImpl.java | 4 +- .../spi/core/security/jaas/LDAPLoginModule.java | 2 +- 32 files changed, 123 insertions(+), 124 deletions(-) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java index 9fbff81..762147b 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java @@ -201,7 +201,7 @@ public class ConsumerThread extends Thread { System.out.println(threadName + " Committing transaction: " + transactions++); session.commit(); } - } else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { + } else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE && msg != null) { if (batchSize > 0 && received > 0 && received % batchSize == 0) { System.out.println("Acknowledging last " + batchSize + " messages; messages so far = " + received); msg.acknowledge(); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java index 9345973..fe7d2c4 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java @@ -216,63 +216,63 @@ public class PrintData extends DBOption { if (pgStore != null) { folder = pgStore.getFolder(); - } - out.println("####################################################################################################"); - out.println("Exploring store " + store + " folder = " + folder); - int pgid = (int) pgStore.getFirstPage(); - for (int pg = 0; pg < pgStore.getNumberOfPages(); pg++) { - out.println("******* Page " + pgid); - Page page = pgStore.createPage(pgid); - page.open(); - List<PagedMessage> msgs = page.read(sm); - page.close(); - - int msgID = 0; - - for (PagedMessage msg : msgs) { - msg.initMessage(sm); - if (safe) { - try { - out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ", msg=" + msg.getMessage().getClass().getSimpleName() + "(safe data, size=" + msg.getMessage().getPersistentSize() + ")"); - } catch (Exception e) { - out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ", msg=" + msg.getMessage().getClass().getSimpleName() + "(safe data)"); + out.println("####################################################################################################"); + out.println("Exploring store " + store + " folder = " + folder); + int pgid = (int) pgStore.getFirstPage(); + for (int pg = 0; pg < pgStore.getNumberOfPages(); pg++) { + out.println("******* Page " + pgid); + Page page = pgStore.createPage(pgid); + page.open(); + List<PagedMessage> msgs = page.read(sm); + page.close(); + + int msgID = 0; + + for (PagedMessage msg : msgs) { + msg.initMessage(sm); + if (safe) { + try { + out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ", msg=" + msg.getMessage().getClass().getSimpleName() + "(safe data, size=" + msg.getMessage().getPersistentSize() + ")"); + } catch (Exception e) { + out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ", msg=" + msg.getMessage().getClass().getSimpleName() + "(safe data)"); + } + } else { + out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ",userMessageID=" + (msg.getMessage().getUserID() != null ? msg.getMessage().getUserID() : "") + ", msg=" + msg.getMessage()); } - } else { - out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ",userMessageID=" + (msg.getMessage().getUserID() != null ? msg.getMessage().getUserID() : "") + ", msg=" + msg.getMessage()); - } - out.print(",Queues = "); - long[] q = msg.getQueueIDs(); - for (int i = 0; i < q.length; i++) { - out.print(q[i]); + out.print(",Queues = "); + long[] q = msg.getQueueIDs(); + for (int i = 0; i < q.length; i++) { + out.print(q[i]); - PagePosition posCheck = new PagePositionImpl(pgid, msgID); + PagePosition posCheck = new PagePositionImpl(pgid, msgID); - boolean acked = false; + boolean acked = false; - Set<PagePosition> positions = cursorACKs.getCursorRecords().get(q[i]); - if (positions != null) { - acked = positions.contains(posCheck); - } + Set<PagePosition> positions = cursorACKs.getCursorRecords().get(q[i]); + if (positions != null) { + acked = positions.contains(posCheck); + } - if (acked) { - out.print(" (ACK)"); - } + if (acked) { + out.print(" (ACK)"); + } - if (cursorACKs.getCompletePages(q[i]).contains(Long.valueOf(pgid))) { - out.println(" (PG-COMPLETE)"); - } + if (cursorACKs.getCompletePages(q[i]).contains(Long.valueOf(pgid))) { + out.println(" (PG-COMPLETE)"); + } - if (i + 1 < q.length) { - out.print(","); + if (i + 1 < q.length) { + out.print(","); + } } + if (msg.getTransactionID() >= 0 && !pgTXs.contains(msg.getTransactionID())) { + out.print(", **PG_TX_NOT_FOUND**"); + } + out.println(); + msgID++; } - if (msg.getTransactionID() >= 0 && !pgTXs.contains(msg.getTransactionID())) { - out.print(", **PG_TX_NOT_FOUND**"); - } - out.println(); - msgID++; + pgid++; } - pgid++; } } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java index 09e78d5..78ae5ec 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java @@ -71,9 +71,9 @@ public class XMLMessageImporter { Byte type = 0; Byte priority = 0; - Long expiration = 0L; - Long timestamp = 0L; - Long id = 0L; + long expiration = 0L; + long timestamp = 0L; + long id = 0L; org.apache.activemq.artemis.utils.UUID userId = null; ArrayList<String> queues = new ArrayList<>(); @@ -276,7 +276,7 @@ public class XMLMessageImporter { * CDATA has to be decoded in its entirety. * * @param processor used to deal with the decoded CDATA elements - * @param textMessage If this a text message we decode UTF8 and encode as a simple string + * @param decodeTextMessage If this a text message we decode UTF8 and encode as a simple string */ private void getMessageBodyBytes(MessageBodyBytesProcessor processor, boolean decodeTextMessage) throws IOException, XMLStreamException { int currentEventType; diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java index ff4fd86..c0b7811 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java @@ -86,7 +86,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { netToUse = null; } } catch (Exception e) { - ActiveMQUtilLogger.LOGGER.failedToSetNIC(e, nicName == null ? " " : nicName); + ActiveMQUtilLogger.LOGGER.failedToSetNIC(e, nicName); netToUse = null; } @@ -326,6 +326,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { } public boolean check(InetAddress address) { + if (address == null) { + return false; + } + try { if (address.isReachable(networkInterface, 0, networkTimeout)) { if (logger.isTraceEnabled()) { @@ -336,7 +340,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { return purePing(address); } } catch (Exception e) { - ActiveMQUtilLogger.LOGGER.failedToCheckAddress(e, address == null ? " " : address.toString()); + ActiveMQUtilLogger.LOGGER.failedToCheckAddress(e, address.toString()); return false; } } @@ -392,6 +396,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { } public boolean check(URL url) { + if (url == null) { + return false; + } + try { URLConnection connection = url.openConnection(); connection.setReadTimeout(networkTimeout); @@ -399,7 +407,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { is.close(); return true; } catch (Exception e) { - ActiveMQUtilLogger.LOGGER.failedToCheckURL(e, url == null ? " " : url.toString()); + ActiveMQUtilLogger.LOGGER.failedToCheckURL(e, url.toString()); return false; } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java index 2dda85f..51f0803 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java @@ -101,17 +101,10 @@ public class FactoryFinder { } // lets load the file - BufferedInputStream reader = null; - try { - reader = new BufferedInputStream(in); + try (BufferedInputStream reader = new BufferedInputStream(in)) { Properties properties = new Properties(); properties.load(reader); return properties; - } finally { - try { - reader.close(); - } catch (Exception e) { - } } } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java index 10001b2..32dd819 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java @@ -295,12 +295,12 @@ public class ConcurrentLongHashMap<V> { if (storedKey == key) { if (storedValue == EmptyValue) { - values[bucket] = value != null ? value : valueProvider.apply(key); + values[bucket] = value != null ? value : (valueProvider != null ? valueProvider.apply(key) : null); ++size; ++usedBuckets; return valueProvider != null ? values[bucket] : null; } else if (storedValue == DeletedValue) { - values[bucket] = value != null ? value : valueProvider.apply(key); + values[bucket] = value != null ? value : (valueProvider != null ? valueProvider.apply(key) : null); ++size; return valueProvider != null ? values[bucket] : null; } else if (!onlyIfAbsent) { @@ -320,7 +320,7 @@ public class ConcurrentLongHashMap<V> { } keys[bucket] = key; - values[bucket] = value != null ? value : valueProvider.apply(key); + values[bucket] = value != null ? value : (valueProvider != null ? valueProvider.apply(key) : null); ++size; return valueProvider != null ? values[bucket] : null; } else if (storedValue == DeletedValue) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java index 5cda0c4..b015be6 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java @@ -145,7 +145,7 @@ public class ClientProducerImpl implements ClientProducerInternal { doSend(address1, message, null); if (handler != null) { if (logger.isDebugEnabled()) { - logger.debug("Handler was used on producing messages towards address " + address1.toString() + " however there is no confirmationWindowEnabled"); + logger.debug("Handler was used on producing messages towards address " + (address1 == null ? null : address1.toString()) + " however there is no confirmationWindowEnabled"); } if (!confirmationNotSetLogged) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java index 1b8ec97..9eb0ee5 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java @@ -469,8 +469,8 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { } else if (type == PacketImpl.CLUSTER_TOPOLOGY_V2) { ClusterTopologyChangeMessage_V2 topMessage = (ClusterTopologyChangeMessage_V2) packet; notifyTopologyChange(updateTransportConfiguration(topMessage)); - } else if (type == PacketImpl.CLUSTER_TOPOLOGY || type == PacketImpl.CLUSTER_TOPOLOGY_V2 || type == PacketImpl.CLUSTER_TOPOLOGY_V3) { - ClusterTopologyChangeMessage topMessage = (ClusterTopologyChangeMessage) packet; + } else if (type == PacketImpl.CLUSTER_TOPOLOGY_V3) { + ClusterTopologyChangeMessage_V3 topMessage = (ClusterTopologyChangeMessage_V3) packet; notifyTopologyChange(updateTransportConfiguration(topMessage)); } else if (type == PacketImpl.CHECK_FOR_FAILOVER_REPLY) { System.out.println("Channel0Handler.handlePacket"); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java index 61268d6..ffcf1b8 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java @@ -695,7 +695,7 @@ public final class ChannelImpl implements Channel { clearUpTo(msg.getCommandID()); } - if (!connection.isClient()) { + if (!connection.isClient() && handler != null) { handler.handlePacket(packet); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java index 32deb38..3467f1b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java @@ -1181,7 +1181,7 @@ public class NettyConnector extends AbstractConnector { @Override public boolean isEquivalent(Map<String, Object> configuration) { - Boolean httpUpgradeEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, TransportConstants.DEFAULT_HTTP_UPGRADE_ENABLED, configuration); + boolean httpUpgradeEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, TransportConstants.DEFAULT_HTTP_UPGRADE_ENABLED, configuration); if (httpUpgradeEnabled) { // we need to look at the activemqServerName to distinguish between ActiveMQ servers that could be proxied behind the same // HTTP upgrade handler in the Web server @@ -1198,9 +1198,9 @@ public class NettyConnector extends AbstractConnector { //here we only check host and port because these two parameters //is sufficient to determine the target host String host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME, TransportConstants.DEFAULT_HOST, configuration); - Integer port = ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT, configuration); + int port = ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT, configuration); - if (!port.equals(this.port)) + if (port != this.port) return false; if (host.equals(this.host)) diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java index 2118942..7052deb 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java @@ -199,7 +199,7 @@ public abstract class AbstractJDBCDriver { connection.setAutoCommit(false); final boolean tableExists; try (ResultSet rs = connection.getMetaData().getTables(null, null, tableName, null)) { - if ((rs == null) || (rs != null && !rs.next())) { + if (rs == null || !rs.next()) { tableExists = false; if (logger.isTraceEnabled()) { logger.tracef("Table %s did not exist, creating it with SQL=%s", tableName, Arrays.toString(sqls)); diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java index bb210de..d332e6c 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java @@ -433,7 +433,7 @@ public class ActiveMQMessage implements javax.jms.Message { dest = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address.toString()); } - if (changedAddress != null) { + if (changedAddress != null && dest != null) { ((ActiveMQDestination) dest).setName(changedAddress.toString()); } } @@ -902,7 +902,7 @@ public class ActiveMQMessage implements javax.jms.Message { private void checkProperty(final String name) throws JMSException { if (propertiesReadOnly) { - if (name.equals(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM)) { + if (name != null && name.equals(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM)) { throw new MessageNotWriteableException("You cannot set the Input Stream on received messages. Did you mean " + ActiveMQJMSConstants.JMS_ACTIVEMQ_OUTPUT_STREAM + " or " + ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM + diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java index 3cdf9fe..a993b4d 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java @@ -370,7 +370,9 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor public void sequentialDone() { if (error) { - callback.onError(errorCode, errorMessage); + if (callback != null) { + callback.onError(errorCode, errorMessage); + } onIOError(new ActiveMQException(errorCode, errorMessage), errorMessage, null); errorMessage = null; } else { diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/CoreAmqpConverter.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/CoreAmqpConverter.java index cba15e0..421ea21 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/CoreAmqpConverter.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/CoreAmqpConverter.java @@ -323,12 +323,8 @@ public class CoreAmqpConverter { if (daMap != null) { encoder.writeObject(new DeliveryAnnotations(daMap)); } - if (maMap != null) { - encoder.writeObject(new MessageAnnotations(maMap)); - } - if (properties != null) { - encoder.writeObject(properties); - } + encoder.writeObject(new MessageAnnotations(maMap)); + encoder.writeObject(properties); if (apMap != null) { encoder.writeObject(new ApplicationProperties(apMap)); } diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java index ced463b..ef5568f 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java @@ -1261,7 +1261,9 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se } } } else { - tx.rollback(); + if (tx != null) { + tx.rollback(); + } } return null; @@ -1413,7 +1415,9 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se } } } else { - tx.commit(onePhase); + if (tx != null) { + tx.commit(onePhase); + } } return null; diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java index cdf0cee..db74696 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java @@ -782,7 +782,7 @@ public final class OpenWireMessageConverter { MarshallingSupport.marshalDouble(dataOut, doubleVal); break; case DataConstants.FLOAT: - Float floatVal = Float.intBitsToFloat(buffer.readInt()); + float floatVal = Float.intBitsToFloat(buffer.readInt()); MarshallingSupport.marshalFloat(dataOut, floatVal); break; case DataConstants.INT: diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java index 6d0759e..2fed4a0 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java @@ -250,9 +250,8 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc } catch (JMSException e) { logger.debug("Error unsetting the exception listener " + this, e); } - if (connection != null) { - connection.signalStopToAllSessions(); - } + + connection.signalStopToAllSessions(); try { // we must close the ActiveMQConnectionFactory because it contains a ServerLocator @@ -277,9 +276,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * <p> * connection close will close the ClientSessionFactory which will close all sessions. */ - if (connection != null) { - connection.close(); - } + connection.close(); if (nonXAsession != null) { nonXAsession.close(); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java index d10ede8..5cdb000 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java @@ -934,12 +934,11 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { return false; } else if (!this.producerWindowSize.equals(other.producerWindowSize)) return false; - else if (!protocolManagerFactoryStr.equals(other.protocolManagerFactoryStr)) - return false; if (this.protocolManagerFactoryStr == null) { if (other.protocolManagerFactoryStr != null) return false; - } + } else if (!protocolManagerFactoryStr.equals(other.protocolManagerFactoryStr)) + return false; if (this.reconnectAttempts == null) { if (other.reconnectAttempts != null) return false; @@ -1007,7 +1006,7 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { if (enableSharedClientID == null) { if (other.enableSharedClientID != null) return false; - } else if (!enableSharedClientID == other.enableSharedClientID) + } else if (!this.enableSharedClientID.equals(other.enableSharedClientID)) return false; return true; diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java index f2c2390..1d6602e 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java @@ -148,7 +148,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\""); if (timeout == null) - timeout = Long.valueOf(consumerTimeoutSeconds * 1000); + timeout = Long.valueOf((long) consumerTimeoutSeconds * 1000); boolean deleteWhenIdle = !durable; // default is true if non-durable if (destroyWhenIdle != null) deleteWhenIdle = destroyWhenIdle.booleanValue(); diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java index e2b9cd5..cb42c95 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java @@ -96,7 +96,7 @@ public class TimeoutTask implements Runnable { public void run() { while (running) { try { - Thread.sleep(interval * 1000); + Thread.sleep((long) interval * 1000); } catch (InterruptedException e) { running = false; break; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java index 7fd1294..40db8d9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java @@ -2044,9 +2044,6 @@ public class ConfigurationImpl implements Configuration, Serializable { if (diskScanPeriod != other.diskScanPeriod) { return false; } - if (connectionTtlCheckInterval != other.connectionTtlCheckInterval) { - return false; - } return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java index b0d5910..7f0411e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java @@ -1131,7 +1131,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { long index = 0; - long start = (page - 1) * pageSize; + long start = (long) (page - 1) * pageSize; long end = Math.min(page * pageSize, queue.getMessageCount()); ArrayList<CompositeData> c = new ArrayList<>(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java index 7ea2ab6..8b82ee8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java @@ -1325,7 +1325,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding storageManager.storeReference(queue.getID(), message.getMessageID(), !iter.hasNext()); } - if (deliveryTime > 0) { + if (deliveryTime != null && deliveryTime > 0) { if (tx != null) { storageManager.updateScheduledDeliveryTimeTransactional(tx.getID(), reference); } else { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java index c9d9e1f..505859c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java @@ -291,8 +291,8 @@ public class ColocatedHAManager implements HAManager { } Object serverId = params.get(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME); if (serverId != null) { - Integer newid = Integer.parseInt(serverId.toString()) + portOffset; - params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, newid.toString()); + int newid = Integer.parseInt(serverId.toString()) + portOffset; + params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, newid); } params.put(TransportConstants.ACTIVEMQ_SERVER_NAME, name); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java index 20f83ec..a9d80e5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java @@ -196,16 +196,16 @@ public class ClusterConnectionBridge extends BridgeImpl { } private void setupNotificationConsumer() throws Exception { - if (logger.isDebugEnabled()) { - logger.debug("Setting up notificationConsumer between " + this.clusterConnection.getConnector() + - " and " + - flowRecord.getBridge().getForwardingConnection() + - " clusterConnection = " + - this.clusterConnection.getName() + - " on server " + - clusterConnection.getServer()); - } if (flowRecord != null) { + if (logger.isDebugEnabled()) { + logger.debug("Setting up notificationConsumer between " + this.clusterConnection.getConnector() + + " and " + + flowRecord.getBridge().getForwardingConnection() + + " clusterConnection = " + + this.clusterConnection.getName() + + " on server " + + clusterConnection.getServer()); + } flowRecord.reset(); if (notifConsumer != null) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java index c52dcf6..8dd160d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java @@ -146,10 +146,10 @@ public class LiveOnlyActivation extends Activation { ClientSessionFactoryInternal clientSessionFactory = null; while (clientSessionFactory == null) { Pair<TransportConfiguration, TransportConfiguration> possibleLive = null; + possibleLive = nodeLocator.getLiveConfiguration(); + if (possibleLive == null) // we've tried every connector + break; try { - possibleLive = nodeLocator.getLiveConfiguration(); - if (possibleLive == null) // we've tried every connector - break; clientSessionFactory = (ClientSessionFactoryInternal) scaleDownServerLocator.createSessionFactory(possibleLive.getA(), 0, false); } catch (Exception e) { logger.trace("Failed to connect to " + possibleLive.getA()); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index 6c430bb..51fbe49 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -3685,7 +3685,10 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { if (slowConsumerReaperRunnable == null) { scheduleSlowConsumerReaper(settings); } else if (slowConsumerReaperRunnable.checkPeriod != settings.getSlowConsumerCheckPeriod() || slowConsumerReaperRunnable.threshold != settings.getSlowConsumerThreshold() || !slowConsumerReaperRunnable.policy.equals(settings.getSlowConsumerPolicy())) { - slowConsumerReaperFuture.cancel(false); + if (slowConsumerReaperFuture != null) { + slowConsumerReaperFuture.cancel(false); + slowConsumerReaperFuture = null; + } scheduleSlowConsumerReaper(settings); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java index 18bb987..477fae6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java @@ -389,7 +389,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { // should go back into the // queue for delivery later. // TCP-flow control has to be done first than everything else otherwise we may lose notifications - if (!callback.isWritable(this, protocolContext) || !started || transferring) { + if ((callback != null && !callback.isWritable(this, protocolContext)) || !started || transferring) { return HandleStatus.BUSY; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java index d1f0a05..4c360f0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java @@ -215,7 +215,7 @@ public final class SharedNothingBackupActivation extends Activation { try { if (logger.isTraceEnabled()) { - logger.trace("Calling clusterController.connectToNodeInReplicatedCluster(" + possibleLive.getA() + ")"); + logger.trace("Calling clusterController.connectToNodeInReplicatedCluster(" + possibleLive != null ? possibleLive.getA() : null + ")"); } clusterControl = clusterController.connectToNodeInReplicatedCluster(possibleLive.getA()); } catch (Exception e) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerConsumerPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerConsumerPlugin.java index 93b9c4f..376bfb6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerConsumerPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerConsumerPlugin.java @@ -51,7 +51,7 @@ public interface ActiveMQServerConsumerPlugin extends ActiveMQServerBasePlugin { * Before a consumer is created * * @param consumerID - * @param QueueBinding + * @param queueBinding * @param filterString * @param browseOnly * @param supportLargeMessage diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java index ba731e7..9ef1554 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java @@ -181,9 +181,9 @@ public class TransactionImpl implements Transaction { synchronized (timeoutLock) { boolean timedout; if (timeoutSeconds == -1) { - timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + defaultTimeout * 1000; + timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + (long) defaultTimeout * 1000; } else { - timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + timeoutSeconds * 1000; + timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + (long) timeoutSeconds * 1000; } if (timedout) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java index 1470040..a098ccd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java @@ -184,7 +184,7 @@ public class LDAPLoginModule implements LoginModule { * requests (by verifying that the supplied password is not empty) and * react appropriately. */ - if (password == null || (password != null && password.length() == 0)) + if (password == null || password.length() == 0) throw new FailedLoginException("Password cannot be null or empty"); // authenticate will throw LoginException