You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/02/20 22:12:13 UTC
[activemq-artemis] 04/06: NO-JIRA Inline some variables to simplify
the code flow
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 69582ef642da385e6045c00fa1255ff539562d91
Author: Otavio R. Piske <an...@gmail.com>
AuthorDate: Wed Feb 20 21:09:45 2019 +0100
NO-JIRA Inline some variables to simplify the code flow
---
.../activemq/artemis/core/client/impl/ClientSessionImpl.java | 6 ++----
.../artemis/core/client/impl/LargeMessageControllerImpl.java | 3 +--
.../activemq/artemis/core/client/impl/ServerLocatorImpl.java | 9 +++------
.../org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java | 4 +---
.../activemq/artemis/core/protocol/core/impl/ChannelImpl.java | 6 ++----
.../activemq/artemis/core/remoting/impl/ssl/SSLSupport.java | 2 +-
.../java/org/apache/activemq/artemis/utils/SoftValueHashMap.java | 3 +--
.../java/org/apache/activemq/artemis/utils/XidCodecSupport.java | 3 +--
8 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
index e8e39e7..29ef071 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
@@ -1496,8 +1496,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
@Override
public ClientProducerCredits getCredits(final SimpleString address, final boolean anon) {
synchronized (producerCreditManager) {
- ClientProducerCredits credits = producerCreditManager.getCredits(address, anon, sessionContext);
- return credits;
+ return producerCreditManager.getCredits(address, anon, sessionContext);
}
}
@@ -2020,8 +2019,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
private ClientConsumerInternal getConsumer(final ConsumerContext consumerContext) {
synchronized (consumers) {
- ClientConsumerInternal consumer = consumers.get(consumerContext);
- return consumer;
+ return consumers.get(consumerContext);
}
}
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java
index b256ab1..d5d1c82 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java
@@ -741,8 +741,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
}
public int readInt(final int pos) {
- int v = getInt(pos);
- return v;
+ return getInt(pos);
}
@Override
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
index 8fa0beb..8ac7c9e 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
@@ -317,8 +317,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
private static DiscoveryGroup createDiscoveryGroup(String nodeID,
DiscoveryGroupConfiguration config) throws Exception {
- DiscoveryGroup group = new DiscoveryGroup(nodeID, config.getName(), config.getRefreshTimeout(), config.getBroadcastEndpointFactory(), null);
- return group;
+ return new DiscoveryGroup(nodeID, config.getName(), config.getRefreshTimeout(), config.getBroadcastEndpointFactory(), null);
}
private ServerLocatorImpl(final Topology topology,
@@ -672,8 +671,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
if (topologyMember.getLive() == null && topologyMember.getBackup() != null) {
// This shouldn't happen, however I wanted this to consider all possible cases
- ClientSessionFactoryInternal factory = (ClientSessionFactoryInternal) createSessionFactory(topologyMember.getBackup());
- return factory;
+ return (ClientSessionFactoryInternal) createSessionFactory(topologyMember.getBackup());
}
// it shouldn't happen
return null;
@@ -1854,8 +1852,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
private Object writeReplace() throws ObjectStreamException {
- ServerLocatorImpl clone = new ServerLocatorImpl(this);
- return clone;
+ return new ServerLocatorImpl(this);
}
public boolean isReceivedTopology() {
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java
index 07e26b0..b57042b 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java
@@ -190,9 +190,7 @@ public final class DiscoveryGroup implements ActiveMQComponent {
}
public synchronized List<DiscoveryEntry> getDiscoveryEntries() {
- List<DiscoveryEntry> list = new ArrayList<>(connectors.values());
-
- return list;
+ return new ArrayList<>(connectors.values());
}
public boolean waitForBroadcast(final long timeout) {
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 ffcf1b8..3fcb9cf 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
@@ -571,11 +571,9 @@ public final class ChannelImpl implements Channel {
// And switch it
- final CoreRemotingConnection rnewConnection = newConnection;
+ newConnection.putChannel(id, this);
- rnewConnection.putChannel(id, this);
-
- connection = rnewConnection;
+ connection = newConnection;
transferring = true;
}
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
index 89994c2..507f8ea 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
@@ -288,7 +288,7 @@ public class SSLSupport {
return new URL(storePath);
} catch (MalformedURLException e) {
File file = new File(storePath);
- if (file.exists() == true && file.isFile()) {
+ if (file.exists() && file.isFile()) {
return file.toURI().toURL();
} else {
URL url = findResource(storePath);
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java
index 070f91e..9c90b94 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java
@@ -316,8 +316,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
}
private AggregatedSoftReference createReference(final K key, final V value) {
- AggregatedSoftReference ref = new AggregatedSoftReference(key, value);
- return ref;
+ return new AggregatedSoftReference(key, value);
}
// Inner classes -------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XidCodecSupport.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XidCodecSupport.java
index 6a09164..32e5194 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XidCodecSupport.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XidCodecSupport.java
@@ -43,8 +43,7 @@ public class XidCodecSupport {
in.readBytes(bq);
byte[] gtxid = new byte[in.readInt()];
in.readBytes(gtxid);
- Xid xid = new XidImpl(bq, formatID, gtxid);
- return xid;
+ return new XidImpl(bq, formatID, gtxid);
}
public static int getXidEncodeLength(final Xid xid) {