Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Code hygiene #1222

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ public class BrokerService implements Service {
LOG.info("Loaded the Bouncy Castle security provider at position: {}", ret);
}
} catch(Throwable e) {
// No BouncyCastle found so we use the default Java Security Provider
// No BouncyCastle found, so we use the default Java Security Provider.
LOG.debug("Using the default Java security provider since no Bouncy Castle is found.");
}

String localHostName = "localhost";
Expand Down Expand Up @@ -2219,21 +2220,17 @@ protected void checkStoreSystemUsageLimits() throws Exception {
}

public void stopAllConnectors(ServiceStopper stopper) {
for (Iterator<NetworkConnector> iter = getNetworkConnectors().iterator(); iter.hasNext();) {
NetworkConnector connector = iter.next();
for (NetworkConnector connector : getNetworkConnectors()) {
unregisterNetworkConnectorMBean(connector);
stopper.stop(connector);
}
for (Iterator<ProxyConnector> iter = getProxyConnectors().iterator(); iter.hasNext();) {
ProxyConnector connector = iter.next();
for (ProxyConnector connector : getProxyConnectors()) {
stopper.stop(connector);
}
for (Iterator<JmsConnector> iter = jmsConnectors.iterator(); iter.hasNext();) {
JmsConnector connector = iter.next();
for (JmsConnector connector : jmsConnectors) {
stopper.stop(connector);
}
for (Iterator<TransportConnector> iter = getTransportConnectors().iterator(); iter.hasNext();) {
TransportConnector connector = iter.next();
for (TransportConnector connector : getTransportConnectors()) {
try {
unregisterConnectorMBean(connector);
} catch (IOException e) {
Expand Down Expand Up @@ -2271,7 +2268,6 @@ protected PersistenceAdapter registerPersistenceAdapterMBean(PersistenceAdapter
}

protected void unregisterPersistenceAdapterMBean(PersistenceAdapter adaptor) throws IOException {
if (isUseJmx()) {}
}

private ObjectName createConnectorObjectName(TransportConnector connector) throws MalformedObjectNameException {
Expand Down Expand Up @@ -2474,8 +2470,7 @@ protected Broker addInterceptors(Broker broker) throws Exception {
broker = new ConnectionSplitBroker(broker);
}
if (plugins != null) {
for (int i = 0; i < plugins.length; i++) {
BrokerPlugin plugin = plugins[i];
for (BrokerPlugin plugin : plugins) {
broker = plugin.installPlugin(broker);
}
}
Expand Down Expand Up @@ -2592,9 +2587,8 @@ protected void logError(String message, Throwable e) {
protected void startDestinations() throws Exception {
if (destinations != null) {
ConnectionContext adminConnectionContext = getAdminConnectionContext();
for (int i = 0; i < destinations.length; i++) {
ActiveMQDestination destination = destinations[i];
getBroker().addDestination(adminConnectionContext, destination,true);
for (ActiveMQDestination destination : destinations) {
getBroker().addDestination(adminConnectionContext, destination, true);
}
}
if (isUseVirtualTopics()) {
Expand Down Expand Up @@ -2626,8 +2620,7 @@ protected void startManagementContext() throws Exception {
public void startAllConnectors() throws Exception {
final Set<ActiveMQDestination> durableDestinations = getBroker().getDurableDestinations();
List<TransportConnector> al = new ArrayList<>();
for (Iterator<TransportConnector> iter = getTransportConnectors().iterator(); iter.hasNext();) {
TransportConnector connector = iter.next();
for (TransportConnector connector : getTransportConnectors()) {
al.add(startTransportConnector(connector));
}
if (al.size() > 0) {
Expand All @@ -2654,8 +2647,7 @@ public Thread newThread(Runnable runnable) {
});
}

for (Iterator<NetworkConnector> iter = getNetworkConnectors().iterator(); iter.hasNext();) {
final NetworkConnector connector = iter.next();
for (final NetworkConnector connector : getNetworkConnectors()) {
connector.setLocalUri(getVmConnectorURI());
startNetworkConnector(connector, durableDestinations, networkConnectorStartExecutor);
}
Expand All @@ -2664,12 +2656,10 @@ public Thread newThread(Runnable runnable) {
ThreadPoolUtils.shutdown(networkConnectorStartExecutor);
}

for (Iterator<ProxyConnector> iter = getProxyConnectors().iterator(); iter.hasNext();) {
ProxyConnector connector = iter.next();
for (ProxyConnector connector : getProxyConnectors()) {
connector.start();
}
for (Iterator<JmsConnector> iter = jmsConnectors.iterator(); iter.hasNext();) {
JmsConnector connector = iter.next();
for (JmsConnector connector : jmsConnectors) {
connector.start();
}
for (Service service : services) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.IOException;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import org.apache.activemq.TransactionContext;
import org.apache.activemq.broker.TransactionBroker;
import org.apache.activemq.command.ConnectionId;
import org.apache.activemq.command.TransactionId;
Expand Down Expand Up @@ -109,14 +108,12 @@ private void storeCommit(TransactionId txid, boolean wasPrepared, Runnable preCo
}

private void illegalStateTransition(String callName) throws XAException {
XAException xae = newXAException("Cannot call " + callName + " now.", XAException.XAER_PROTO);
throw xae;
throw newXAException("Cannot call " + callName + " now.", XAException.XAER_PROTO);
}

private void checkForPreparedState(boolean onePhase) throws XAException {
if (!onePhase) {
XAException xae = newXAException("Cannot do 2 phase commit if the transaction has not been prepared", XAException.XAER_PROTO);
throw xae;
throw newXAException("Cannot do 2 phase commit if the transaction has not been prepared", XAException.XAER_PROTO);
}
}

Expand Down