This closes #815

This commit is contained in:
Martyn Taylor 2016-09-30 16:25:01 +01:00
commit f698a7f818
2823 changed files with 19525 additions and 30112 deletions

View File

@ -45,14 +45,17 @@ public class Artemis {
execute(fileHome, fileInstance, args);
}
/** This is a good method for booting an embedded command */
/**
* This is a good method for booting an embedded command
*/
public static Object execute(File artemisHome, File artemisInstance, List<String> args) throws Throwable {
return execute(artemisHome, artemisInstance, args.toArray(new String[args.size()]));
}
/** This is a good method for booting an embedded command */
public static Object execute(File fileHome, File fileInstance, String ... args) throws Throwable {
/**
* This is a good method for booting an embedded command
*/
public static Object execute(File fileHome, File fileInstance, String... args) throws Throwable {
ArrayList<File> dirs = new ArrayList<>();
if (fileHome != null) {
dirs.add(new File(fileHome, "lib"));
@ -61,7 +64,6 @@ public class Artemis {
dirs.add(new File(fileInstance, "lib"));
}
ArrayList<URL> urls = new ArrayList<>();
// Without the etc on the config, things like JGroups configuration wouldn't be loaded
@ -118,13 +120,12 @@ public class Artemis {
Thread.currentThread().setContextClassLoader(loader);
Class<?> clazz = loader.loadClass("org.apache.activemq.artemis.cli.Artemis");
Method method = clazz.getMethod("execute", File.class, File.class, args.getClass());
try {
return method.invoke(null, fileHome, fileInstance, args);
}
catch (InvocationTargetException e) {
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
finally {
} finally {
Thread.currentThread().setContextClassLoader(originalCL);
}
@ -141,8 +142,7 @@ public class Artemis {
private static void add(ArrayList<URL> urls, File file) {
try {
urls.add(file.toURI().toURL());
}
catch (MalformedURLException e) {
} catch (MalformedURLException e) {
e.printStackTrace();
}
}

View File

@ -24,17 +24,17 @@ import java.util.List;
import io.airlift.airline.Cli;
import org.apache.activemq.artemis.cli.commands.Action;
import org.apache.activemq.artemis.cli.commands.ActionContext;
import org.apache.activemq.artemis.cli.commands.messages.Browse;
import org.apache.activemq.artemis.cli.commands.messages.Consumer;
import org.apache.activemq.artemis.cli.commands.Create;
import org.apache.activemq.artemis.cli.commands.destination.CreateDestination;
import org.apache.activemq.artemis.cli.commands.destination.DeleteDestination;
import org.apache.activemq.artemis.cli.commands.HelpAction;
import org.apache.activemq.artemis.cli.commands.destination.HelpDestination;
import org.apache.activemq.artemis.cli.commands.Kill;
import org.apache.activemq.artemis.cli.commands.messages.Producer;
import org.apache.activemq.artemis.cli.commands.Run;
import org.apache.activemq.artemis.cli.commands.Stop;
import org.apache.activemq.artemis.cli.commands.destination.CreateDestination;
import org.apache.activemq.artemis.cli.commands.destination.DeleteDestination;
import org.apache.activemq.artemis.cli.commands.destination.HelpDestination;
import org.apache.activemq.artemis.cli.commands.messages.Browse;
import org.apache.activemq.artemis.cli.commands.messages.Consumer;
import org.apache.activemq.artemis.cli.commands.messages.Producer;
import org.apache.activemq.artemis.cli.commands.tools.CompactJournal;
import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal;
import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal;
@ -73,25 +73,21 @@ public class Artemis {
public static Object execute(File artemisHome, File artemisInstance, String... args) throws Exception {
try {
return internalExecute(artemisHome, artemisInstance, args);
}
catch (ConfigurationException configException) {
} catch (ConfigurationException configException) {
System.err.println(configException.getMessage());
System.out.println();
System.out.println("Configuration should be specified as 'scheme:location'. Default configuration is 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'");
return configException;
}
catch (CLIException cliException) {
} catch (CLIException cliException) {
System.err.println(cliException.getMessage());
return cliException;
}
catch (NullPointerException e) {
} catch (NullPointerException e) {
// Yeah.. I really meant System.err..
// this is the CLI and System.out and System.err are common places for interacting with the user
// this is a programming error that must be visualized and corrected
e.printStackTrace();
return e;
}
catch (RuntimeException re) {
} catch (RuntimeException re) {
System.err.println(re.getMessage());
System.out.println();
@ -102,8 +98,10 @@ public class Artemis {
}
}
/** This method is used to validate exception returns.
* Useful on test cases */
/**
* This method is used to validate exception returns.
* Useful on test cases
*/
public static Object internalExecute(File artemisHome, File artemisInstance, String[] args) throws Exception {
Action action = builder(artemisInstance).build().parse(args);
action.setHomeValues(artemisHome, artemisInstance);
@ -122,22 +120,16 @@ public class Artemis {
private static Cli.CliBuilder<Action> builder(File artemisInstance) {
String instance = artemisInstance != null ? artemisInstance.getAbsolutePath() : System.getProperty("artemis.instance");
Cli.CliBuilder<Action> builder = Cli.<Action>builder("artemis").withDescription("ActiveMQ Artemis Command Line")
.withCommand(HelpAction.class)
.withCommand(Producer.class)
.withCommand(Consumer.class)
.withCommand(Browse.class)
.withDefaultCommand(HelpAction.class);
Cli.CliBuilder<Action> builder = Cli.<Action>builder("artemis").withDescription("ActiveMQ Artemis Command Line").withCommand(HelpAction.class).withCommand(Producer.class).withCommand(Consumer.class).withCommand(Browse.class).withDefaultCommand(HelpAction.class);
builder.withGroup("destination").withDescription("Destination tools group (create|delete) (example ./artemis destination create)").
withDefaultCommand(HelpDestination.class).withCommands(CreateDestination.class, DeleteDestination.class);
withDefaultCommand(HelpDestination.class).withCommands(CreateDestination.class, DeleteDestination.class);
if (instance != null) {
builder.withGroup("data").withDescription("data tools group (print|exp|imp|exp|encode|decode|compact) (example ./artemis data print)").
withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class, XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class, CompactJournal.class);
builder = builder.withCommands(Run.class, Stop.class, Kill.class);
}
else {
} else {
builder.withGroup("data").withDescription("data tools group (print) (example ./artemis data print)").
withDefaultCommand(HelpData.class).withCommands(PrintData.class);
builder = builder.withCommand(Create.class);

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -17,7 +17,7 @@
package org.apache.activemq.artemis.cli;
public class CLIException extends Exception {
public class CLIException extends Exception {
public CLIException(String message) {
super(message);

View File

@ -72,7 +72,6 @@ public abstract class Configurable extends ActionAbstract {
}
}
protected FileConfiguration getFileConfiguration() throws Exception {
if (fileConfiguration == null) {
if (getBrokerInstance() == null) {
@ -84,8 +83,7 @@ public abstract class Configurable extends ActionAbstract {
fileConfiguration.setLargeMessagesDirectory(defaultLocation + "/largemessages");
fileConfiguration.setPagingDirectory(defaultLocation + "/paging");
fileConfiguration.setBrokerInstance(new File("."));
}
else {
} else {
fileConfiguration = new FileConfiguration();
FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
@ -97,7 +95,6 @@ public abstract class Configurable extends ActionAbstract {
}
}
return fileConfiguration;
}

View File

@ -500,8 +500,7 @@ public class Create extends InputAbstract {
if (!created) {
throw new RuntimeException(String.format("Unable to create the path '%s'.", directory));
}
}
else if (!directory.canWrite()) {
} else if (!directory.canWrite()) {
throw new RuntimeException(String.format("The path '%s' is not writable.", directory));
}
}
@ -533,16 +532,14 @@ public class Create extends InputAbstract {
if (replicated) {
clustered = true;
filters.put("${replicated.settings}", applyFilters(readTextFile(ETC_REPLICATED_SETTINGS_TXT), filters));
}
else {
} else {
filters.put("${replicated.settings}", "");
}
if (sharedStore) {
clustered = true;
filters.put("${shared-store.settings}", applyFilters(readTextFile(ETC_SHARED_STORE_SETTINGS_TXT), filters));
}
else {
} else {
filters.put("${shared-store.settings}", "");
}
@ -551,8 +548,7 @@ public class Create extends InputAbstract {
if (IS_WINDOWS || !supportsLibaio()) {
aio = false;
filters.put("${journal.settings}", "NIO");
}
else {
} else {
aio = true;
filters.put("${journal.settings}", "ASYNCIO");
}
@ -567,8 +563,7 @@ public class Create extends InputAbstract {
extraWebAttr += " clientAuth=\"true\" trustStorePath=\"" + sslTrust + "\" trustStorePassword=\"" + sslTrustPassword + "\"";
}
filters.put("${extra.web.attributes}", extraWebAttr);
}
else {
} else {
filters.put("${web.protocol}", "http");
filters.put("${extra.web.attributes}", "");
}
@ -601,8 +596,7 @@ public class Create extends InputAbstract {
filters.put("${cluster.settings}", applyFilters(readTextFile(ETC_CLUSTER_SETTINGS_TXT), filters));
filters.put("${cluster-user}", getClusterUser());
filters.put("${cluster-password}", getClusterPassword());
}
else {
} else {
if (name == null) {
name = getHost();
}
@ -643,8 +637,7 @@ public class Create extends InputAbstract {
if (isAllowAnonymous()) {
write(ETC_LOGIN_CONFIG_WITH_GUEST, filters, false);
new File(directory, ETC_LOGIN_CONFIG_WITH_GUEST).renameTo(new File(directory, ETC_LOGIN_CONFIG));
}
else {
} else {
write(ETC_LOGIN_CONFIG_WITHOUT_GUEST, filters, false);
new File(directory, ETC_LOGIN_CONFIG_WITHOUT_GUEST).renameTo(new File(directory, ETC_LOGIN_CONFIG));
}
@ -670,36 +663,31 @@ public class Create extends InputAbstract {
if (noWeb) {
filters.put("${bootstrap-web-settings}", "");
}
else {
} else {
filters.put("${bootstrap-web-settings}", applyFilters(readTextFile(ETC_BOOTSTRAP_WEB_SETTINGS_TXT), filters));
}
if (noAmqpAcceptor) {
filters.put("${amqp-acceptor}", "");
}
else {
} else {
filters.put("${amqp-acceptor}", applyFilters(readTextFile(ETC_AMQP_ACCEPTOR_TXT), filters));
}
if (noMqttAcceptor) {
filters.put("${mqtt-acceptor}", "");
}
else {
} else {
filters.put("${mqtt-acceptor}", applyFilters(readTextFile(ETC_MQTT_ACCEPTOR_TXT), filters));
}
if (noStompAcceptor) {
filters.put("${stomp-acceptor}", "");
}
else {
} else {
filters.put("${stomp-acceptor}", applyFilters(readTextFile(ETC_STOMP_ACCEPTOR_TXT), filters));
}
if (noHornetQAcceptor) {
filters.put("${hornetq-acceptor}", "");
}
else {
} else {
filters.put("${hornetq-acceptor}", applyFilters(readTextFile(ETC_HORNETQ_ACCEPTOR_TXT), filters));
}
@ -782,8 +770,7 @@ public class Create extends InputAbstract {
private void performAutoTune(HashMap<String, String> filters, boolean aio, File dataFolder) {
if (noAutoTune) {
filters.put("${journal-buffer.settings}", "");
}
else {
} else {
try {
int writes = 250;
System.out.println("");
@ -804,8 +791,7 @@ public class Create extends InputAbstract {
filters.put("${journal-buffer.settings}", applyFilters(readTextFile(ETC_JOURNAL_BUFFER_SETTINGS), syncFilter));
}
catch (Exception e) {
} catch (Exception e) {
filters.put("${journal-buffer.settings}", "");
e.printStackTrace();
System.err.println("Couldn't perform sync calculation, using default values");
@ -817,20 +803,17 @@ public class Create extends InputAbstract {
if (forceLibaio) {
// forcing libaio
return true;
}
else if (forceNIO) {
} else if (forceNIO) {
// forcing NIO
return false;
}
else if (LibaioContext.isLoaded()) {
} else if (LibaioContext.isLoaded()) {
try (LibaioContext context = new LibaioContext(1, true)) {
File tmpFile = new File(directory, "validateAIO.bin");
boolean supportsLibaio = true;
try {
LibaioFile file = context.openFile(tmpFile, true);
file.close();
}
catch (Exception e) {
} catch (Exception e) {
supportsLibaio = false;
}
tmpFile.delete();
@ -839,8 +822,7 @@ public class Create extends InputAbstract {
}
return supportsLibaio;
}
}
else {
} else {
return false;
}
}
@ -852,8 +834,7 @@ public class Create extends InputAbstract {
private String[] getQueueList() {
if (queues == null) {
return new String[0];
}
else {
} else {
return queues.split(",");
}
}
@ -861,8 +842,7 @@ public class Create extends InputAbstract {
private String[] getTopicList() {
if (topics == null) {
return new String[0];
}
else {
} else {
return topics.split(",");
}
}
@ -874,8 +854,7 @@ public class Create extends InputAbstract {
private String path(File value, boolean unixPaths) throws IOException {
if (unixPaths && IS_CYGWIN) {
return value.getCanonicalPath();
}
else {
} else {
return value.getCanonicalPath();
}
}

View File

@ -50,8 +50,7 @@ public class InputAbstract extends ActionAbstract {
inputStr = scanner.nextLine();
if (inputStr.trim().equals("")) {
System.out.println("Invalid Entry!");
}
else {
} else {
valid = true;
}
} while (!valid);
@ -74,8 +73,7 @@ public class InputAbstract extends ActionAbstract {
if (inputStr.trim().equals("")) {
System.out.println("Invalid Entry!");
}
else {
} else {
valid = true;
}
} while (!valid);

View File

@ -127,8 +127,7 @@ public class Run extends LockAbstract {
try {
System.err.println("Halting by user request");
fileKill.delete();
}
catch (Throwable ignored) {
} catch (Throwable ignored) {
}
Runtime.getRuntime().halt(0);
}
@ -136,13 +135,11 @@ public class Run extends LockAbstract {
try {
try {
server.stop();
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
timer.cancel();
}
finally {
} finally {
System.out.println("Server stopped!");
System.out.flush();
latchRunning.countDown();
@ -159,8 +156,7 @@ public class Run extends LockAbstract {
public void run() {
try {
server.stop();
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}

View File

@ -17,6 +17,8 @@
package org.apache.activemq.artemis.cli.commands.destination;
import javax.jms.Message;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
@ -24,8 +26,6 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
import org.apache.activemq.artemis.cli.commands.ActionContext;
import javax.jms.Message;
@Command(name = "create", description = "create a queue or topic")
public class CreateDestination extends DestinationAction {
@ -47,14 +47,11 @@ public class CreateDestination extends DestinationAction {
if (JMS_QUEUE.equals(destType)) {
createJmsQueue(context);
}
else if (CORE_QUEUE.equals(destType)) {
} else if (CORE_QUEUE.equals(destType)) {
createCoreQueue(context);
}
else if (JMS_TOPIC.equals(destType)) {
} else if (JMS_TOPIC.equals(destType)) {
createJmsTopic(context);
}
else {
} else {
throw new IllegalArgumentException("--type can only be one of " + JMS_QUEUE + ", " + JMS_TOPIC + " and " + CORE_QUEUE);
}
return null;
@ -72,8 +69,7 @@ public class CreateDestination extends DestinationAction {
boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
if (result) {
context.out.println("Topic " + getName() + " created successfully.");
}
else {
} else {
context.err.println("Failed to create topic " + getName() + ".");
}
}
@ -128,8 +124,7 @@ public class CreateDestination extends DestinationAction {
boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
if (result) {
context.out.println("Jms queue " + getName() + " created successfully.");
}
else {
} else {
context.err.println("Failed to create jms queue " + getName() + ".");
}
}

View File

@ -17,6 +17,8 @@
package org.apache.activemq.artemis.cli.commands.destination;
import javax.jms.Message;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
@ -24,8 +26,6 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
import org.apache.activemq.artemis.cli.commands.ActionContext;
import javax.jms.Message;
@Command(name = "delete", description = "delete a queue or topic")
public class DeleteDestination extends DestinationAction {
@ -38,14 +38,11 @@ public class DeleteDestination extends DestinationAction {
if (JMS_QUEUE.equals(destType)) {
deleteJmsQueue(context);
}
else if (CORE_QUEUE.equals(destType)) {
} else if (CORE_QUEUE.equals(destType)) {
deleteCoreQueue(context);
}
else if (JMS_TOPIC.equals(destType)) {
} else if (JMS_TOPIC.equals(destType)) {
deleteJmsTopic(context);
}
else {
} else {
throw new IllegalArgumentException("--type can only be one of " + JMS_QUEUE + ", " + JMS_TOPIC + " and " + CORE_QUEUE);
}
return null;
@ -63,8 +60,7 @@ public class DeleteDestination extends DestinationAction {
boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
if (result) {
context.out.println("Topic " + getName() + " deleted successfully.");
}
else {
} else {
context.err.println("Failed to delete topic " + getName());
}
}
@ -89,8 +85,7 @@ public class DeleteDestination extends DestinationAction {
boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
if (result) {
context.out.println("Jms queue " + getName() + " deleted successfully.");
}
else {
} else {
context.err.println("Failed to delete queue " + getName());
}
}

View File

@ -16,6 +16,11 @@
*/
package org.apache.activemq.artemis.cli.commands.destination;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueRequestor;
import javax.jms.Session;
import io.airlift.airline.Option;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
@ -32,11 +37,6 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQSession;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueRequestor;
import javax.jms.Session;
public abstract class DestinationAction extends InputAbstract {
public static final String JMS_QUEUE = "jms-queue";
@ -58,7 +58,10 @@ public abstract class DestinationAction extends InputAbstract {
@Option(name = "--name", description = "destination name")
String name;
public static void performJmsManagement(String brokerURL, String user, String password, ManagementCallback<Message> cb) throws Exception {
public static void performJmsManagement(String brokerURL,
String user,
String password,
ManagementCallback<Message> cb) throws Exception {
try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURL, user, password);
ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
@ -79,15 +82,16 @@ public abstract class DestinationAction extends InputAbstract {
if (result) {
cb.requestSuccessful(reply);
}
else {
} else {
cb.requestFailed(reply);
}
}
}
public static void performCoreManagement(String brokerURL, String user, String password, ManagementCallback<ClientMessage> cb) throws Exception {
public static void performCoreManagement(String brokerURL,
String user,
String password,
ManagementCallback<ClientMessage> cb) throws Exception {
try (ServerLocator locator = ServerLocatorImpl.newLocator(brokerURL);
ClientSessionFactory sessionFactory = locator.createSessionFactory();
@ -102,8 +106,7 @@ public abstract class DestinationAction extends InputAbstract {
if (ManagementHelper.hasOperationSucceeded(reply)) {
cb.requestSuccessful(reply);
}
else {
} else {
cb.requestFailed(reply);
}
}
@ -130,6 +133,7 @@ public abstract class DestinationAction extends InputAbstract {
}
public interface ManagementCallback<T> {
void setUpInvocation(T message) throws Exception;
void requestSuccessful(T reply) throws Exception;

View File

@ -17,14 +17,14 @@
package org.apache.activemq.artemis.cli.commands.destination;
import io.airlift.airline.Help;
import org.apache.activemq.artemis.cli.commands.Action;
import org.apache.activemq.artemis.cli.commands.ActionContext;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import io.airlift.airline.Help;
import org.apache.activemq.artemis.cli.commands.Action;
import org.apache.activemq.artemis.cli.commands.ActionContext;
public class HelpDestination extends Help implements Action {
@Override

View File

@ -17,6 +17,10 @@
package org.apache.activemq.artemis.cli.commands.messages;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.Session;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.activemq.artemis.cli.commands.ActionContext;
@ -24,10 +28,6 @@ import org.apache.activemq.artemis.cli.commands.util.ConsumerThread;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.Session;
@Command(name = "browser", description = "It will send consume messages from an instance")
public class Browse extends DestAbstract {
@ -49,8 +49,7 @@ public class Browse extends DestAbstract {
Session session;
if (txBatchSize > 0) {
session = connection.createSession(true, Session.SESSION_TRANSACTED);
}
else {
} else {
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
threadsArray[i] = new ConsumerThread(session, dest, i);

View File

@ -58,8 +58,7 @@ public class Consumer extends DestAbstract {
Session session;
if (txBatchSize > 0) {
session = connection.createSession(true, Session.SESSION_TRANSACTED);
}
else {
} else {
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
threadsArray[i] = new ConsumerThread(session, dest, i);

View File

@ -59,8 +59,7 @@ public class Producer extends DestAbstract {
Session session;
if (txBatchSize > 0) {
session = connection.createSession(true, Session.SESSION_TRANSACTED);
}
else {
} else {
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
threadsArray[i] = new ProducerThread(session, dest, i);

View File

@ -38,8 +38,7 @@ public final class CompactJournal extends LockAbstract {
compactJournal(new File(getBinding()), "activemq-bindings", "bindings", 2, 1048576, null);
System.out.println("Compactation succeeded for " + getBinding());
}
catch (Exception e) {
} catch (Exception e) {
treatError(e, "data", "compact");
}
return null;

View File

@ -62,8 +62,7 @@ public class DecodeJournal extends LockAbstract {
directory = getFileConfiguration().getJournalDirectory();
}
importJournal(directory, prefix, suffix, 2, size, input);
}
catch (Exception e) {
} catch (Exception e) {
treatError(e, "data", "decode");
}
@ -145,41 +144,35 @@ public class DecodeJournal extends LockAbstract {
if (operation.equals("AddRecord")) {
RecordInfo info = parseRecord(lineProperties);
journal.appendAddRecord(info.id, info.userRecordType, info.data, false);
}
else if (operation.equals("AddRecordTX")) {
} else if (operation.equals("AddRecordTX")) {
long txID = parseLong("txID", lineProperties);
AtomicInteger counter = getCounter(txID, txCounters);
counter.incrementAndGet();
RecordInfo info = parseRecord(lineProperties);
journal.appendAddRecordTransactional(txID, info.id, info.userRecordType, info.data);
}
else if (operation.equals("AddRecordTX")) {
} else if (operation.equals("AddRecordTX")) {
long txID = parseLong("txID", lineProperties);
AtomicInteger counter = getCounter(txID, txCounters);
counter.incrementAndGet();
RecordInfo info = parseRecord(lineProperties);
journal.appendAddRecordTransactional(txID, info.id, info.userRecordType, info.data);
}
else if (operation.equals("UpdateTX")) {
} else if (operation.equals("UpdateTX")) {
long txID = parseLong("txID", lineProperties);
AtomicInteger counter = getCounter(txID, txCounters);
counter.incrementAndGet();
RecordInfo info = parseRecord(lineProperties);
journal.appendUpdateRecordTransactional(txID, info.id, info.userRecordType, info.data);
}
else if (operation.equals("Update")) {
} else if (operation.equals("Update")) {
RecordInfo info = parseRecord(lineProperties);
journal.appendUpdateRecord(info.id, info.userRecordType, info.data, false);
}
else if (operation.equals("DeleteRecord")) {
} else if (operation.equals("DeleteRecord")) {
long id = parseLong("id", lineProperties);
// If not found it means the append/update records were reclaimed already
if (journalRecords.get(id) != null) {
journal.appendDeleteRecord(id, false);
}
}
else if (operation.equals("DeleteRecordTX")) {
} else if (operation.equals("DeleteRecordTX")) {
long txID = parseLong("txID", lineProperties);
long id = parseLong("id", lineProperties);
AtomicInteger counter = getCounter(txID, txCounters);
@ -189,8 +182,7 @@ public class DecodeJournal extends LockAbstract {
if (journalRecords.get(id) != null) {
journal.appendDeleteRecordTransactional(txID, id);
}
}
else if (operation.equals("Prepare")) {
} else if (operation.equals("Prepare")) {
long txID = parseLong("txID", lineProperties);
int numberOfRecords = parseInt("numberOfRecords", lineProperties);
AtomicInteger counter = getCounter(txID, txCounters);
@ -198,8 +190,7 @@ public class DecodeJournal extends LockAbstract {
if (counter.get() == numberOfRecords) {
journal.appendPrepareRecord(txID, data, false);
}
else {
} else {
System.err.println("Transaction " + txID +
" at line " +
lineNumber +
@ -208,15 +199,13 @@ public class DecodeJournal extends LockAbstract {
" while the import only had " +
counter);
}
}
else if (operation.equals("Commit")) {
} else if (operation.equals("Commit")) {
long txID = parseLong("txID", lineProperties);
int numberOfRecords = parseInt("numberOfRecords", lineProperties);
AtomicInteger counter = getCounter(txID, txCounters);
if (counter.get() == numberOfRecords) {
journal.appendCommitRecord(txID, false);
}
else {
} else {
System.err.println("Transaction " + txID +
" at line " +
lineNumber +
@ -225,16 +214,13 @@ public class DecodeJournal extends LockAbstract {
" while the import only had " +
counter);
}
}
else if (operation.equals("Rollback")) {
} else if (operation.equals("Rollback")) {
long txID = parseLong("txID", lineProperties);
journal.appendRollbackRecord(txID, false);
}
else {
} else {
System.err.println("Invalid operation " + operation + " at line " + lineNumber);
}
}
catch (Exception ex) {
} catch (Exception ex) {
System.err.println("Error at line " + lineNumber + ", operation=" + operation + " msg = " + ex.getMessage());
}
}
@ -317,8 +303,7 @@ public class DecodeJournal extends LockAbstract {
String[] tuple = el.split("@");
if (tuple.length == 2) {
properties.put(tuple[0], tuple[1]);
}
else {
} else {
properties.put(tuple[0], tuple[0]);
}
}

View File

@ -57,8 +57,7 @@ public class EncodeJournal extends LockAbstract {
}
exportJournal(directory, prefix, suffix, 2, size);
}
catch (Exception e) {
} catch (Exception e) {
treatError(e, "data", "encode");
}

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -26,7 +26,8 @@ import org.apache.activemq.artemis.cli.CLIException;
import org.apache.activemq.artemis.cli.commands.Action;
import org.apache.activemq.artemis.cli.commands.ActionContext;
public abstract class LockAbstract extends DataAbstract implements Action {
public abstract class LockAbstract extends DataAbstract implements Action {
// There should be one lock per VM
// These will be locked as long as the VM is running
private static RandomAccessFile serverLockFile = null;
@ -35,9 +36,8 @@ public abstract class LockAbstract extends DataAbstract implements Action {
protected File getLockPlace() throws Exception {
String brokerInstance = getBrokerInstance();
if (brokerInstance != null) {
return new File(new File(brokerInstance),"lock");
}
else {
return new File(new File(brokerInstance), "lock");
} else {
return null;
}
}
@ -53,8 +53,7 @@ public abstract class LockAbstract extends DataAbstract implements Action {
serverLockLock.close();
serverLockLock = null;
}
}
catch (Exception ignored) {
} catch (Exception ignored) {
}
}
@ -65,15 +64,13 @@ public abstract class LockAbstract extends DataAbstract implements Action {
if (getBrokerInstance() == null) {
System.err.println("Warning: You are running a data tool outside of any broker instance. Modifying data on a running server might break the server's data");
System.err.println();
}
else {
} else {
lockCLI(getLockPlace());
}
return null;
}
protected void lockCLI(File lockPlace) throws Exception {
if (lockPlace != null) {
lockPlace.mkdirs();
@ -87,12 +84,10 @@ public abstract class LockAbstract extends DataAbstract implements Action {
throw new CLIException("Error: There is another process using the server at " + lockPlace + ". Cannot start the process!");
}
serverLockLock = lock;
}
catch (OverlappingFileLockException e) {
} catch (OverlappingFileLockException e) {
throw new CLIException("Error: There is another process using the server at " + lockPlace + ". Cannot start the process!");
}
}
}
}

View File

@ -21,7 +21,9 @@ import java.io.File;
import io.airlift.airline.Option;
/** This is for commands where --f on ignoring lock could be valid. */
/**
* This is for commands where --f on ignoring lock could be valid.
*/
public class OptionalLocking extends LockAbstract {
@Option(name = "--f", description = "This will allow certain tools like print-data to be performed ignoring any running servers. WARNING: Changing data concurrently with a running broker may damage your data. Be careful with this option.")

View File

@ -65,8 +65,7 @@ public class PrintData extends OptionalLocking {
super.execute(context);
try {
printData(new File(getBinding()), new File(getJournal()), new File(getPaging()));
}
catch (Exception e) {
} catch (Exception e) {
treatError(e, "data", "print");
}
return null;
@ -87,8 +86,7 @@ public class PrintData extends OptionalLocking {
System.out.println("Server's ID=" + fileLock.getNodeId().toString());
System.out.println("********************************************");
fileLock.stop();
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -99,8 +97,7 @@ public class PrintData extends OptionalLocking {
try {
DescribeJournal.describeBindingsJournal(bindingsDirectory);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
@ -112,8 +109,7 @@ public class PrintData extends OptionalLocking {
DescribeJournal describeJournal = null;
try {
describeJournal = DescribeJournal.describeMessagesJournal(messagesDirectory);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
return;
}
@ -125,8 +121,7 @@ public class PrintData extends OptionalLocking {
System.out.println("********************************************");
printPages(pagingDirectory, describeJournal);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
return;
}
@ -218,8 +213,7 @@ public class PrintData extends OptionalLocking {
}
}
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -248,8 +242,7 @@ public class PrintData extends OptionalLocking {
}
set.add(encoding.position);
}
else if (record.userRecordType == JournalRecordIds.PAGE_CURSOR_COMPLETE) {
} else if (record.userRecordType == JournalRecordIds.PAGE_CURSOR_COMPLETE) {
CursorAckRecordEncoding encoding = new CursorAckRecordEncoding();
encoding.decode(buff);
@ -259,15 +252,13 @@ public class PrintData extends OptionalLocking {
if (!cursorInfo.getCompletePages(queueID).add(pageNR)) {
System.err.println("Page " + pageNR + " has been already set as complete on queue " + queueID);
}
}
else if (record.userRecordType == JournalRecordIds.PAGE_TRANSACTION) {
} else if (record.userRecordType == JournalRecordIds.PAGE_TRANSACTION) {
if (record.isUpdate) {
PageUpdateTXEncoding pageUpdate = new PageUpdateTXEncoding();
pageUpdate.decode(buff);
cursorInfo.getPgTXs().add(pageUpdate.pageTX);
}
else {
} else {
PageTransactionInfoImpl pageTransactionInfo = new PageTransactionInfoImpl();
pageTransactionInfo.decode(buff);

View File

@ -66,12 +66,12 @@ import org.apache.activemq.artemis.core.paging.impl.Page;
import org.apache.activemq.artemis.core.paging.impl.PageTransactionInfoImpl;
import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl;
import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO;
import org.apache.activemq.artemis.core.persistence.impl.journal.AckDescribe;
import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal;
import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal.MessageDescribe;
import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal.ReferenceDescribe;
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds;
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
import org.apache.activemq.artemis.core.persistence.impl.journal.AckDescribe;
import org.apache.activemq.artemis.core.persistence.impl.journal.codec.CursorAckRecordEncoding;
import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageUpdateTXEncoding;
import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PersistentQueueBindingEncoding;
@ -130,8 +130,7 @@ public final class XmlDataExporter extends OptionalLocking {
try {
process(context.out, getBinding(), getJournal(), getPaging(), getLargeMessages());
}
catch (Exception e) {
} catch (Exception e) {
treatError(e, "data", "exp");
}
return null;
@ -236,26 +235,21 @@ public final class XmlDataExporter extends OptionalLocking {
Object o = DescribeJournal.newObjectEncoding(info, storageManager);
if (info.getUserRecordType() == JournalRecordIds.ADD_MESSAGE) {
messages.put(info.id, ((MessageDescribe) o).getMsg());
}
else if (info.getUserRecordType() == JournalRecordIds.ADD_LARGE_MESSAGE) {
} else if (info.getUserRecordType() == JournalRecordIds.ADD_LARGE_MESSAGE) {
messages.put(info.id, ((MessageDescribe) o).getMsg());
}
else if (info.getUserRecordType() == JournalRecordIds.ADD_REF) {
} else if (info.getUserRecordType() == JournalRecordIds.ADD_REF) {
ReferenceDescribe ref = (ReferenceDescribe) o;
HashMap<Long, ReferenceDescribe> map = messageRefs.get(info.id);
if (map == null) {
HashMap<Long, ReferenceDescribe> newMap = new HashMap<>();
newMap.put(ref.refEncoding.queueID, ref);
messageRefs.put(info.id, newMap);
}
else {
} else {
map.put(ref.refEncoding.queueID, ref);
}
}
else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) {
} else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) {
acks.add(info);
}
else if (info.userRecordType == JournalRecordIds.ACKNOWLEDGE_CURSOR) {
} else if (info.userRecordType == JournalRecordIds.ACKNOWLEDGE_CURSOR) {
CursorAckRecordEncoding encoding = new CursorAckRecordEncoding();
encoding.decode(buff);
@ -267,15 +261,13 @@ public final class XmlDataExporter extends OptionalLocking {
}
set.add(encoding.position);
}
else if (info.userRecordType == JournalRecordIds.PAGE_TRANSACTION) {
} else if (info.userRecordType == JournalRecordIds.PAGE_TRANSACTION) {
if (info.isUpdate) {
PageUpdateTXEncoding pageUpdate = new PageUpdateTXEncoding();
pageUpdate.decode(buff);
pgTXs.add(pageUpdate.pageTX);
}
else {
} else {
PageTransactionInfoImpl pageTransactionInfo = new PageTransactionInfoImpl();
pageTransactionInfo.decode(buff);
@ -336,15 +328,13 @@ public final class XmlDataExporter extends OptionalLocking {
cf.setId(id);
ActiveMQServerLogger.LOGGER.info("Found JMS connection factory: " + cf.getName());
jmsConnectionFactories.put(cf.getName(), cf);
}
else if (rec == JMSJournalStorageManagerImpl.DESTINATION_RECORD) {
} else if (rec == JMSJournalStorageManagerImpl.DESTINATION_RECORD) {
PersistedDestination destination = new PersistedDestination();
destination.decode(buffer);
destination.setId(id);
ActiveMQServerLogger.LOGGER.info("Found JMS destination: " + destination.getName());
jmsDestinations.put(new Pair<>(destination.getType(), destination.getName()), destination);
}
else if (rec == JMSJournalStorageManagerImpl.BINDING_RECORD) {
} else if (rec == JMSJournalStorageManagerImpl.BINDING_RECORD) {
PersistedBindings jndi = new PersistedBindings();
jndi.decode(buffer);
jndi.setId(id);
@ -355,8 +345,7 @@ public final class XmlDataExporter extends OptionalLocking {
}
ActiveMQServerLogger.LOGGER.info("Found JMS JNDI binding data for " + jndi.getType() + " " + jndi.getName() + ": " + builder.toString());
jmsJNDI.put(key, jndi);
}
else {
} else {
throw new IllegalStateException("Invalid record type " + rec);
}
@ -401,8 +390,7 @@ public final class XmlDataExporter extends OptionalLocking {
xmlWriter.writeEndDocument();
xmlWriter.flush();
xmlWriter.close();
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -745,13 +733,11 @@ public final class XmlDataExporter extends OptionalLocking {
pageId++;
}
}
else {
} else {
ActiveMQServerLogger.LOGGER.debug("Page store was null");
}
}
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -771,8 +757,7 @@ public final class XmlDataExporter extends OptionalLocking {
if (message.isLargeMessage()) {
printLargeMessageBody((LargeServerMessage) message);
}
else {
} else {
int size = message.getEndOfBodyPosition() - message.getBodyBuffer().readerIndex();
byte[] buffer = new byte[size];
message.getBodyBuffer().readBytes(buffer);
@ -796,8 +781,7 @@ public final class XmlDataExporter extends OptionalLocking {
Long remainder = bodySize - totalBytesWritten;
if (remainder >= LARGE_MESSAGE_CHUNK_SIZE) {
bufferSize = LARGE_MESSAGE_CHUNK_SIZE;
}
else {
} else {
bufferSize = remainder;
}
ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(bufferSize.intValue());
@ -806,16 +790,13 @@ public final class XmlDataExporter extends OptionalLocking {
totalBytesWritten += bufferSize;
}
encoder.close();
}
catch (ActiveMQException e) {
} catch (ActiveMQException e) {
e.printStackTrace();
}
finally {
} finally {
if (encoder != null) {
try {
encoder.close();
}
catch (ActiveMQException e) {
} catch (ActiveMQException e) {
e.printStackTrace();
}
}
@ -839,39 +820,29 @@ public final class XmlDataExporter extends OptionalLocking {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_NAME, key.toString());
if (value instanceof byte[]) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_VALUE, encode((byte[]) value));
}
else {
} else {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_VALUE, value == null ? XmlDataConstants.NULL : value.toString());
}
if (value instanceof Boolean) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_BOOLEAN);
}
else if (value instanceof Byte) {
} else if (value instanceof Byte) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_BYTE);
}
else if (value instanceof Short) {
} else if (value instanceof Short) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_SHORT);
}
else if (value instanceof Integer) {
} else if (value instanceof Integer) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_INTEGER);
}
else if (value instanceof Long) {
} else if (value instanceof Long) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_LONG);
}
else if (value instanceof Float) {
} else if (value instanceof Float) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_FLOAT);
}
else if (value instanceof Double) {
} else if (value instanceof Double) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_DOUBLE);
}
else if (value instanceof String) {
} else if (value instanceof String) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_STRING);
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_SIMPLE_STRING);
}
else if (value instanceof byte[]) {
} else if (value instanceof byte[]) {
xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_BYTES);
}
}
@ -887,17 +858,13 @@ public final class XmlDataExporter extends OptionalLocking {
String prettyType = XmlDataConstants.DEFAULT_TYPE_PRETTY;
if (rawType == Message.BYTES_TYPE) {
prettyType = XmlDataConstants.BYTES_TYPE_PRETTY;
}
else if (rawType == Message.MAP_TYPE) {
} else if (rawType == Message.MAP_TYPE) {
prettyType = XmlDataConstants.MAP_TYPE_PRETTY;
}
else if (rawType == Message.OBJECT_TYPE) {
} else if (rawType == Message.OBJECT_TYPE) {
prettyType = XmlDataConstants.OBJECT_TYPE_PRETTY;
}
else if (rawType == Message.STREAM_TYPE) {
} else if (rawType == Message.STREAM_TYPE) {
prettyType = XmlDataConstants.STREAM_TYPE_PRETTY;
}
else if (rawType == Message.TEXT_TYPE) {
} else if (rawType == Message.TEXT_TYPE) {
prettyType = XmlDataConstants.TEXT_TYPE_PRETTY;
}
xmlWriter.writeAttribute(XmlDataConstants.MESSAGE_TYPE, prettyType);

View File

@ -161,8 +161,7 @@ public final class XmlDataImporter extends ActionAbstract {
this.session = session;
if (managementSession != null) {
this.managementSession = managementSession;
}
else {
} else {
this.managementSession = session;
}
localSession = false;
@ -182,8 +181,7 @@ public final class XmlDataImporter extends ActionAbstract {
if (user != null || password != null) {
session = sf.createSession(user, password, false, !transactional, true, false, 0);
managementSession = sf.createSession(user, password, false, true, true, false, 0);
}
else {
} else {
session = sf.createSession(false, !transactional, true);
managementSession = sf.createSession(false, true, true);
}
@ -201,14 +199,11 @@ public final class XmlDataImporter extends ActionAbstract {
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
if (XmlDataConstants.BINDINGS_CHILD.equals(reader.getLocalName())) {
bindQueue();
}
else if (XmlDataConstants.MESSAGES_CHILD.equals(reader.getLocalName())) {
} else if (XmlDataConstants.MESSAGES_CHILD.equals(reader.getLocalName())) {
processMessage();
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORIES.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORIES.equals(reader.getLocalName())) {
createJmsConnectionFactories();
}
else if (XmlDataConstants.JMS_DESTINATIONS.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_DESTINATIONS.equals(reader.getLocalName())) {
createJmsDestinations();
}
}
@ -218,8 +213,7 @@ public final class XmlDataImporter extends ActionAbstract {
if (!session.isAutoCommitSends()) {
session.commit();
}
}
finally {
} finally {
// if the session was created in our constructor then close it (otherwise the caller will close it)
if (localSession) {
session.close();
@ -270,11 +264,9 @@ public final class XmlDataImporter extends ActionAbstract {
case XMLStreamConstants.START_ELEMENT:
if (XmlDataConstants.MESSAGE_BODY.equals(reader.getLocalName())) {
processMessageBody(message);
}
else if (XmlDataConstants.PROPERTIES_CHILD.equals(reader.getLocalName())) {
} else if (XmlDataConstants.PROPERTIES_CHILD.equals(reader.getLocalName())) {
processMessageProperties(message);
}
else if (XmlDataConstants.QUEUES_CHILD.equals(reader.getLocalName())) {
} else if (XmlDataConstants.QUEUES_CHILD.equals(reader.getLocalName())) {
processMessageQueues(queues);
}
break;
@ -330,8 +322,7 @@ public final class XmlDataImporter extends ActionAbstract {
if (queueIDs.containsKey(queue)) {
queueID = queueIDs.get(queue);
}
else {
} else {
// Get the ID of the queues involved so the message can be routed properly. This is done because we cannot
// send directly to a queue, we have to send to an address instead but not all the queues related to the
// address may need the message
@ -474,8 +465,7 @@ public final class XmlDataImporter extends ActionAbstract {
FileInputStream fileInputStream = new FileInputStream(tempFileName);
BufferedInputStream bufferedInput = new BufferedInputStream(fileInputStream);
((ClientMessage) message).setBodyInputStream(bufferedInput);
}
else {
} else {
getMessageBodyBytes(new MessageBodyBytesProcessor() {
@Override
public void processBodyBytes(byte[] bytes) throws IOException {
@ -502,15 +492,13 @@ public final class XmlDataImporter extends ActionAbstract {
currentEventType = reader.getEventType();
if (currentEventType == XMLStreamConstants.END_ELEMENT) {
break;
}
} else if (currentEventType == XMLStreamConstants.CHARACTERS && reader.isWhiteSpace() && cdata.length() > 0) {
/* when we hit a whitespace CHARACTERS event we know that the entire CDATA is complete so decode, pass back to
* the processor, and reset the cdata for the next event(s)
*/
else if (currentEventType == XMLStreamConstants.CHARACTERS && reader.isWhiteSpace() && cdata.length() > 0) {
processor.processBodyBytes(decode(cdata.toString()));
cdata.setLength(0);
}
else {
} else {
cdata.append(new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()).trim());
}
reader.next();
@ -544,8 +532,7 @@ public final class XmlDataImporter extends ActionAbstract {
if (logger.isDebugEnabled()) {
logger.debug("Binding queue(name=" + queueName + ", address=" + address + ", filter=" + filter + ")");
}
}
else {
} else {
if (logger.isDebugEnabled()) {
logger.debug("Binding " + queueName + " already exists so won't re-bind.");
}
@ -651,210 +638,175 @@ public final class XmlDataImporter extends ActionAbstract {
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory callFailoverTimeout: " + callFailoverTimeout);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CALL_TIMEOUT.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CALL_TIMEOUT.equals(reader.getLocalName())) {
callTimeout = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory callTimeout: " + callTimeout);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_FAILURE_CHECK_PERIOD.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_FAILURE_CHECK_PERIOD.equals(reader.getLocalName())) {
clientFailureCheckPeriod = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory clientFailureCheckPeriod: " + clientFailureCheckPeriod);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_ID.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_ID.equals(reader.getLocalName())) {
clientId = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory clientId: " + clientId);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONFIRMATION_WINDOW_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONFIRMATION_WINDOW_SIZE.equals(reader.getLocalName())) {
confirmationWindowSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory confirmationWindowSize: " + confirmationWindowSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTION_TTL.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTION_TTL.equals(reader.getLocalName())) {
connectionTtl = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory connectionTtl: " + connectionTtl);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTOR.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTOR.equals(reader.getLocalName())) {
connectors = getConnectors();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory getLocalName: " + connectors);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_MAX_RATE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_MAX_RATE.equals(reader.getLocalName())) {
consumerMaxRate = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory consumerMaxRate: " + consumerMaxRate);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_WINDOW_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_WINDOW_SIZE.equals(reader.getLocalName())) {
consumerWindowSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory consumerWindowSize: " + consumerWindowSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DISCOVERY_GROUP_NAME.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DISCOVERY_GROUP_NAME.equals(reader.getLocalName())) {
discoveryGroupName = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory discoveryGroupName: " + discoveryGroupName);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DUPS_OK_BATCH_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DUPS_OK_BATCH_SIZE.equals(reader.getLocalName())) {
dupsOkBatchSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory dupsOkBatchSize: " + dupsOkBatchSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_GROUP_ID.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_GROUP_ID.equals(reader.getLocalName())) {
groupId = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory groupId: " + groupId);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_LOAD_BALANCING_POLICY_CLASS_NAME.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_LOAD_BALANCING_POLICY_CLASS_NAME.equals(reader.getLocalName())) {
loadBalancingPolicyClassName = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory loadBalancingPolicyClassName: " + loadBalancingPolicyClassName);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MAX_RETRY_INTERVAL.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MAX_RETRY_INTERVAL.equals(reader.getLocalName())) {
maxRetryInterval = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory maxRetryInterval: " + maxRetryInterval);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MIN_LARGE_MESSAGE_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MIN_LARGE_MESSAGE_SIZE.equals(reader.getLocalName())) {
minLargeMessageSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory minLargeMessageSize: " + minLargeMessageSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_NAME.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_NAME.equals(reader.getLocalName())) {
name = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory name: " + name);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_MAX_RATE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_MAX_RATE.equals(reader.getLocalName())) {
producerMaxRate = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory producerMaxRate: " + producerMaxRate);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_WINDOW_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_WINDOW_SIZE.equals(reader.getLocalName())) {
producerWindowSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory producerWindowSize: " + producerWindowSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RECONNECT_ATTEMPTS.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RECONNECT_ATTEMPTS.equals(reader.getLocalName())) {
reconnectAttempts = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory reconnectAttempts: " + reconnectAttempts);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL.equals(reader.getLocalName())) {
retryInterval = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory retryInterval: " + retryInterval);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL_MULTIPLIER.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL_MULTIPLIER.equals(reader.getLocalName())) {
retryIntervalMultiplier = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory retryIntervalMultiplier: " + retryIntervalMultiplier);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_SCHEDULED_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_SCHEDULED_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) {
scheduledThreadMaxPoolSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory scheduledThreadMaxPoolSize: " + scheduledThreadMaxPoolSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) {
threadMaxPoolSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory threadMaxPoolSize: " + threadMaxPoolSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TRANSACTION_BATCH_SIZE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TRANSACTION_BATCH_SIZE.equals(reader.getLocalName())) {
transactionBatchSize = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory transactionBatchSize: " + transactionBatchSize);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TYPE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TYPE.equals(reader.getLocalName())) {
type = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory type: " + type);
}
}
else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) {
entries = getEntries();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory entries: " + entries);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_AUTO_GROUP.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_AUTO_GROUP.equals(reader.getLocalName())) {
autoGroup = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory autoGroup: " + autoGroup);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_ACKNOWLEDGE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_ACKNOWLEDGE.equals(reader.getLocalName())) {
blockOnAcknowledge = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory blockOnAcknowledge: " + blockOnAcknowledge);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_DURABLE_SEND.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_DURABLE_SEND.equals(reader.getLocalName())) {
blockOnDurableSend = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory blockOnDurableSend: " + blockOnDurableSend);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_NON_DURABLE_SEND.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_NON_DURABLE_SEND.equals(reader.getLocalName())) {
blockOnNonDurableSend = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory blockOnNonDurableSend: " + blockOnNonDurableSend);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CACHE_LARGE_MESSAGES_CLIENT.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CACHE_LARGE_MESSAGES_CLIENT.equals(reader.getLocalName())) {
cacheLargeMessagesClient = reader.getElementText();
ActiveMQServerLogger.LOGGER.info("JMS connection factory " + name + " cacheLargeMessagesClient: " + cacheLargeMessagesClient);
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_COMPRESS_LARGE_MESSAGES.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_COMPRESS_LARGE_MESSAGES.equals(reader.getLocalName())) {
compressLargeMessages = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory compressLargeMessages: " + compressLargeMessages);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_FAILOVER_ON_INITIAL_CONNECTION.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_FAILOVER_ON_INITIAL_CONNECTION.equals(reader.getLocalName())) {
failoverOnInitialConnection = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory failoverOnInitialConnection: " + failoverOnInitialConnection);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_HA.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_HA.equals(reader.getLocalName())) {
ha = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory ha: " + ha);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PREACKNOWLEDGE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PREACKNOWLEDGE.equals(reader.getLocalName())) {
preacknowledge = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory preacknowledge: " + preacknowledge);
}
}
else if (XmlDataConstants.JMS_CONNECTION_FACTORY_USE_GLOBAL_POOLS.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_CONNECTION_FACTORY_USE_GLOBAL_POOLS.equals(reader.getLocalName())) {
useGlobalPools = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS connection factory useGlobalPools: " + useGlobalPools);
@ -883,8 +835,7 @@ public final class XmlDataImporter extends ActionAbstract {
if (logger.isDebugEnabled()) {
logger.debug("Created connection factory " + name);
}
}
else {
} else {
ActiveMQServerLogger.LOGGER.error("Problem creating " + name);
}
@ -907,20 +858,17 @@ public final class XmlDataImporter extends ActionAbstract {
if (logger.isDebugEnabled()) {
logger.debug("JMS destination name: " + name);
}
}
else if (XmlDataConstants.JMS_DESTINATION_SELECTOR.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_DESTINATION_SELECTOR.equals(reader.getLocalName())) {
selector = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS destination selector: " + selector);
}
}
else if (XmlDataConstants.JMS_DESTINATION_TYPE.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_DESTINATION_TYPE.equals(reader.getLocalName())) {
type = reader.getElementText();
if (logger.isDebugEnabled()) {
logger.debug("JMS destination type: " + type);
}
}
else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) {
} else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) {
entries = getEntries();
}
break;
@ -940,8 +888,7 @@ public final class XmlDataImporter extends ActionAbstract {
ClientMessage managementMessage = managementSession.createMessage(false);
if ("Queue".equals(type)) {
ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createQueue", name, entries, selector);
}
else if ("Topic".equals(type)) {
} else if ("Topic".equals(type)) {
ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createTopic", name, entries);
}
managementSession.start();
@ -950,8 +897,7 @@ public final class XmlDataImporter extends ActionAbstract {
if (logger.isDebugEnabled()) {
logger.debug("Created " + type.toLowerCase() + " " + name);
}
}
else {
} else {
ActiveMQServerLogger.LOGGER.error("Problem creating " + name);
}

View File

@ -60,8 +60,7 @@ public class ConsumerThread extends Thread {
public void run() {
if (browse) {
browse();
}
else {
} else {
consume();
}
}
@ -74,8 +73,7 @@ public class ConsumerThread extends Thread {
try {
if (filter != null) {
consumer = session.createBrowser((Queue) destination, filter);
}
else {
} else {
consumer = session.createBrowser((Queue) destination);
}
Enumeration<Message> enumBrowse = consumer.getEnumeration();
@ -99,8 +97,7 @@ public class ConsumerThread extends Thread {
if (received >= messageCount) {
break;
}
}
else {
} else {
break;
}
@ -111,11 +108,9 @@ public class ConsumerThread extends Thread {
}
consumer.close();
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
finally {
} finally {
if (finished != null) {
finished.countDown();
}
@ -123,8 +118,7 @@ public class ConsumerThread extends Thread {
System.out.println(threadName + " Consumed: " + this.getReceived() + " messages");
try {
consumer.close();
}
catch (JMSException e) {
} catch (JMSException e) {
e.printStackTrace();
}
}
@ -142,16 +136,13 @@ public class ConsumerThread extends Thread {
if (durable && destination instanceof Topic) {
if (filter != null) {
consumer = session.createDurableSubscriber((Topic) destination, getName(), filter, false);
}
else {
} else {
consumer = session.createDurableSubscriber((Topic) destination, getName());
}
}
else {
} else {
if (filter != null) {
consumer = session.createConsumer(destination, filter);
}
else {
} else {
consumer = session.createConsumer(destination);
}
}
@ -169,8 +160,7 @@ public class ConsumerThread extends Thread {
System.out.println("Message:" + msg);
}
received++;
}
else {
} else {
if (breakOnNull) {
break;
}
@ -181,8 +171,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) {
if (batchSize > 0 && received > 0 && received % batchSize == 0) {
System.out.println("Acknowledging last " + batchSize + " messages; messages so far = " + received);
msg.acknowledge();
@ -196,14 +185,11 @@ public class ConsumerThread extends Thread {
try {
session.commit();
} catch (Throwable ignored) {
}
catch (Throwable ignored) {
}
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
finally {
} finally {
if (finished != null) {
finished.countDown();
}
@ -211,8 +197,7 @@ public class ConsumerThread extends Thread {
System.out.println(threadName + " Consumed: " + this.getReceived() + " messages");
try {
consumer.close();
}
catch (JMSException e) {
} catch (JMSException e) {
e.printStackTrace();
}
}

View File

@ -84,8 +84,7 @@ public class ProducerThread extends Thread {
sendMessage(producer, threadName);
sentCount.incrementAndGet();
}
}
else {
} else {
for (sentCount.set(0); sentCount.get() < messageCount && running; sentCount.incrementAndGet()) {
paused.await();
sendMessage(producer, threadName);
@ -94,8 +93,7 @@ public class ProducerThread extends Thread {
try {
session.commit();
}
catch (Throwable ignored) {
} catch (Throwable ignored) {
}
System.out.println(threadName + " Produced: " + this.getSentCount() + " messages");
@ -104,19 +102,16 @@ public class ProducerThread extends Thread {
System.out.println(threadName + " Elapsed time in second : " + elapsed + " s");
System.out.println(threadName + " Elapsed time in milli second : " + (tEnd - tStart) + " milli seconds");
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
finally {
} finally {
if (finished != null) {
finished.countDown();
}
if (producer != null) {
try {
producer.close();
}
catch (JMSException e) {
} catch (JMSException e) {
e.printStackTrace();
}
}
@ -154,20 +149,16 @@ public class ProducerThread extends Thread {
if (payload != null) {
answer = session.createBytesMessage();
((BytesMessage) answer).writeBytes(payload);
}
else {
} else {
if (textMessageSize > 0) {
if (messageText == null) {
messageText = readInputStream(getClass().getResourceAsStream("demo.txt"), textMessageSize, i);
}
}
else if (payloadUrl != null) {
} else if (payloadUrl != null) {
messageText = readInputStream(new URL(payloadUrl).openStream(), -1, i);
}
else if (message != null) {
} else if (message != null) {
messageText = message;
}
else {
} else {
messageText = createDefaultMessage(i);
}
answer = session.createTextMessage(messageText);
@ -186,8 +177,7 @@ public class ProducerThread extends Thread {
char[] buffer;
if (size > 0) {
buffer = new char[size];
}
else {
} else {
buffer = new char[1024];
}
int count;
@ -198,8 +188,7 @@ public class ProducerThread extends Thread {
break;
}
return builder.toString();
}
catch (IOException ioe) {
} catch (IOException ioe) {
return createDefaultMessage(messageNumber);
}
}

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -122,22 +122,18 @@ public class SyncCalculation {
}
return totalTime;
}
finally {
} finally {
try {
file.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
file.delete();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
factory.stop();
}
catch (Exception e) {
} catch (Exception e) {
}
}
}
@ -160,8 +156,7 @@ public class SyncCalculation {
((AIOSequentialFileFactory) factory).disableBufferReuse();
return factory;
}
else {
} else {
SequentialFileFactory factory = new NIOSequentialFileFactory(datafolder, 1);
factory.start();
return factory;

View File

@ -70,8 +70,7 @@ public class ProcessBuilder {
String[] newArgs;
if (IS_WINDOWS) {
newArgs = rebuildArgs(args, "cmd", "/c", "artemis.cmd");
}
else {
} else {
newArgs = rebuildArgs(args, "./artemis");
}
@ -147,14 +146,12 @@ public class ProcessBuilder {
if (print) {
if (sendToErr) {
System.err.println(logName + "-err:" + line);
}
else {
} else {
System.out.println(logName + "-out:" + line);
}
}
}
}
catch (IOException e) {
} catch (IOException e) {
// ok, stream closed
}

View File

@ -15,5 +15,7 @@
* limitations under the License.
*/
/** Contains useful classes for spawning process from client classes */
/**
* Contains useful classes for spawning process from client classes
*/
package org.apache.activemq.artemis.cli.process;

View File

@ -33,7 +33,9 @@ public class BrokerFactory {
return createBrokerConfiguration(configURI, null, null);
}
public static BrokerDTO createBrokerConfiguration(URI configURI, String artemisHome, String artemisInstance) throws Exception {
public static BrokerDTO createBrokerConfiguration(URI configURI,
String artemisHome,
String artemisInstance) throws Exception {
if (configURI.getScheme() == null) {
throw new ConfigurationException("Invalid configuration URI, no scheme specified: " + configURI);
}
@ -42,20 +44,20 @@ public class BrokerFactory {
try {
FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/");
factory = (BrokerFactoryHandler) finder.newInstance(configURI.getScheme());
}
catch (IOException ioe) {
} catch (IOException ioe) {
throw new ConfigurationException("Invalid configuration URI, can't find configuration scheme: " + configURI.getScheme());
}
return factory.createBroker(configURI, artemisHome, artemisInstance);
}
public static BrokerDTO createBrokerConfiguration(String configuration) throws Exception {
return createBrokerConfiguration(new URI(configuration), null, null);
}
public static BrokerDTO createBrokerConfiguration(String configuration, String artemisHome, String artemisInstance) throws Exception {
public static BrokerDTO createBrokerConfiguration(String configuration,
String artemisHome,
String artemisInstance) throws Exception {
return createBrokerConfiguration(new URI(configuration), artemisHome, artemisInstance);
}
@ -75,8 +77,7 @@ public class BrokerFactory {
try {
FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/server/");
handler = (BrokerHandler) finder.newInstance(configURI.getScheme());
}
catch (IOException ioe) {
} catch (IOException ioe) {
throw new ConfigurationException("Invalid configuration URI, can't find configuration scheme: " + configURI.getScheme());
}

View File

@ -16,10 +16,10 @@
*/
package org.apache.activemq.artemis.factory;
import org.apache.activemq.artemis.dto.BrokerDTO;
import java.net.URI;
import org.apache.activemq.artemis.dto.BrokerDTO;
public interface BrokerFactoryHandler {
BrokerDTO createBroker(URI brokerURI) throws Exception;

View File

@ -22,6 +22,7 @@ import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
public class JaasSecurityHandler implements SecurityHandler {
@Override
public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) throws Exception {
JaasSecurityDTO jaasSecurity = (JaasSecurityDTO) security;

View File

@ -16,12 +16,12 @@
*/
package org.apache.activemq.artemis.factory;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.activemq.artemis.dto.SecurityDTO;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.apache.activemq.artemis.utils.FactoryFinder;
import javax.xml.bind.annotation.XmlRootElement;
public class SecurityManagerFactory {
public static ActiveMQSecurityManager create(SecurityDTO config) throws Exception {
@ -29,8 +29,7 @@ public class SecurityManagerFactory {
FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/security/");
SecurityHandler securityHandler = (SecurityHandler) finder.newInstance(config.getClass().getAnnotation(XmlRootElement.class).name());
return securityHandler.createSecurityManager(config);
}
else {
} else {
throw new Exception("No security manager configured!");
}
}

View File

@ -16,13 +16,13 @@
*/
package org.apache.activemq.artemis.factory;
import java.io.File;
import java.net.URI;
import org.apache.activemq.artemis.cli.ConfigurationException;
import org.apache.activemq.artemis.dto.BrokerDTO;
import org.apache.activemq.artemis.dto.XmlUtil;
import java.io.File;
import java.net.URI;
public class XmlBrokerFactoryHandler implements BrokerFactoryHandler {
@Override

View File

@ -23,5 +23,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
* A Broker os a set of ActiveMQComponents that create a Server, for instance core and jms.
*/
public interface Broker extends ActiveMQComponent {
ActiveMQServer getServer();
}

View File

@ -16,6 +16,10 @@
*/
package org.apache.activemq.artemis.integration;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Map;
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
@ -25,10 +29,6 @@ import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger
import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Map;
public class FileBroker implements Broker {
private final String configurationUrl;

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -45,8 +45,7 @@ public class ServerUtil {
ProcessBuilder builder = null;
if (IS_WINDOWS) {
builder = new ProcessBuilder("cmd", "/c", "artemis.cmd", "run");
}
else {
} else {
builder = new ProcessBuilder("./artemis", "run");
}
@ -86,8 +85,7 @@ public class ServerUtil {
try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) {
cf.createConnection().close();
System.out.println("server " + uri + " started");
}
catch (Exception e) {
} catch (Exception e) {
System.out.println("awaiting server " + uri + " start at ");
Thread.sleep(500);
continue;
@ -160,14 +158,12 @@ public class ServerUtil {
if (print) {
if (sendToErr) {
System.err.println(logName + "-err:" + line);
}
else {
} else {
System.out.println(logName + "-out:" + line);
}
}
}
}
catch (IOException e) {
} catch (IOException e) {
// ok, stream closed
}
}

View File

@ -80,8 +80,7 @@ public class ArtemisTest {
if (original == null) {
System.clearProperty("java.security.auth.login.config");
}
else {
} else {
System.setProperty("java.security.auth.login.config", original);
}
@ -97,8 +96,7 @@ public class ArtemisTest {
public void invalidPathDoesntThrowException() {
if (isWindows()) {
testCli("create", "zzzzz:/rawr", "--silent");
}
else {
} else {
testCli("create", "/rawr", "--silent");
}
}
@ -132,7 +130,7 @@ public class ArtemisTest {
File bootstrapFile = new File(new File(instance1, "etc"), "bootstrap.xml");
Assert.assertTrue(bootstrapFile.exists());
Document config = parseXml(bootstrapFile);
Element webElem = (Element)config.getElementsByTagName("web").item(0);
Element webElem = (Element) config.getElementsByTagName("web").item(0);
String bindAttr = webElem.getAttribute("bind");
String bindStr = "http://localhost:" + Create.HTTP_PORT;
@ -151,7 +149,7 @@ public class ArtemisTest {
bootstrapFile = new File(new File(instance2, "etc"), "bootstrap.xml");
Assert.assertTrue(bootstrapFile.exists());
config = parseXml(bootstrapFile);
webElem = (Element)config.getElementsByTagName("web").item(0);
webElem = (Element) config.getElementsByTagName("web").item(0);
bindAttr = webElem.getAttribute("bind");
bindStr = "https://localhost:" + Create.HTTP_PORT;
@ -168,9 +166,7 @@ public class ArtemisTest {
//instance3: https with clientAuth
File instance3 = new File(temporaryFolder.getRoot(), "instance3");
Artemis.main("create", instance3.getAbsolutePath(), "--silent", "--ssl-key", "etc/keystore",
"--ssl-key-password", "password1",
"--use-client-auth", "--ssl-trust", "etc/truststore", "--ssl-trust-password", "password2");
Artemis.main("create", instance3.getAbsolutePath(), "--silent", "--ssl-key", "etc/keystore", "--ssl-key-password", "password1", "--use-client-auth", "--ssl-trust", "etc/truststore", "--ssl-trust-password", "password2");
bootstrapFile = new File(new File(instance3, "etc"), "bootstrap.xml");
Assert.assertTrue(bootstrapFile.exists());
@ -179,7 +175,7 @@ public class ArtemisTest {
System.out.println("confg: " + cfgText);
config = parseXml(bootstrapFile);
webElem = (Element)config.getElementsByTagName("web").item(0);
webElem = (Element) config.getElementsByTagName("web").item(0);
bindAttr = webElem.getAttribute("bind");
bindStr = "https://localhost:" + Create.HTTP_PORT;
@ -227,8 +223,7 @@ public class ArtemisTest {
try {
Artemis.internalExecute("data", "print");
Assert.fail("Exception expected");
}
catch (CLIException expected) {
} catch (CLIException expected) {
}
Artemis.internalExecute("data", "print", "--f");
@ -268,8 +263,7 @@ public class ArtemisTest {
// Checking it was acked before
Assert.assertEquals(Integer.valueOf(100), Artemis.internalExecute("consumer", "--txt-size", "50", "--verbose", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
}
finally {
} finally {
stopServer();
}
}
@ -287,8 +281,7 @@ public class ArtemisTest {
try {
Assert.assertEquals(Integer.valueOf(100), Artemis.internalExecute("producer", "--message-count", "100"));
Assert.assertEquals(Integer.valueOf(100), Artemis.internalExecute("consumer", "--message-count", "100"));
}
finally {
} finally {
stopServer();
}
}
@ -296,8 +289,7 @@ public class ArtemisTest {
private void testCli(String... args) {
try {
Artemis.main(args);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Exception caught " + e.getMessage());
}

View File

@ -60,8 +60,7 @@ public class FileBrokerTest {
Assert.assertNotNull(activeMQServer);
Assert.assertTrue(activeMQServer.isStarted());
Assert.assertTrue(broker.isStarted());
}
finally {
} finally {
if (broker != null) {
broker.stop();
}
@ -82,8 +81,7 @@ public class FileBrokerTest {
Assert.assertNotNull(activeMQServer);
Assert.assertTrue(activeMQServer.isStarted());
Assert.assertTrue(broker.isStarted());
}
finally {
} finally {
assert broker != null;
broker.stop();
}
@ -124,13 +122,11 @@ public class FileBrokerTest {
try {
producer.send(session.createMessage(true));
fail("Should throw a security exception");
}
catch (Exception e) {
} catch (Exception e) {
}
locator.close();
}
finally {
} finally {
assert broker != null;
broker.stop();
if (path != null) {

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -18,6 +18,7 @@
package org.apache.activemq.artemis;
public class ArtemisConstants {
public static final int DEFAULT_JOURNAL_BUFFER_SIZE_AIO = 490 * 1024;
public static final int DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO = (int) (1000000000d / 2000);
public static final int DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO = (int) (1000000000d / 300);

View File

@ -44,8 +44,7 @@ public final class Pair<A, B> implements Serializable {
if (hash == -1) {
if (a == null && b == null) {
return super.hashCode();
}
else {
} else {
hash = (a == null ? 0 : a.hashCode()) + 37 * (b == null ? 0 : b.hashCode());
}
}

View File

@ -122,8 +122,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
if (end < start || start < 0 || end > len) {
throw new IndexOutOfBoundsException();
}
else {
} else {
int newlen = end - start << 1;
byte[] bytes = new byte[newlen];
@ -217,8 +216,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
}
return true;
}
else {
} else {
return false;
}
}
@ -270,8 +268,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
if (all == null) {
return new SimpleString[]{this};
}
else {
} else {
// Adding the last one
byte[] bytes = new byte[data.length - lasPos];
System.arraycopy(data, lasPos, bytes, 0, bytes.length);
@ -366,8 +363,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
public static int sizeofNullableString(final SimpleString str) {
if (str == null) {
return 1;
}
else {
} else {
return 1 + str.sizeof();
}
}

View File

@ -35,7 +35,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
public static ByteBuf unwrap(ByteBuf buffer) {
ByteBuf parent;
while ((parent = buffer.unwrap()) != null && parent != buffer) { // this last part is just in case the semantic
// ever changes where unwrap is returning itself
// ever changes where unwrap is returning itself
buffer = parent;
}
@ -49,8 +49,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
public ChannelBufferWrapper(final ByteBuf buffer, boolean releasable) {
if (!releasable) {
this.buffer = Unpooled.unreleasableBuffer(buffer);
}
else {
} else {
this.buffer = buffer;
}
this.releasable = releasable;
@ -105,11 +104,9 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
chars[i] = (char) buffer.readShort();
}
return new String(chars);
}
else if (len < 0xfff) {
} else if (len < 0xfff) {
return readUTF();
}
else {
} else {
return readSimpleStringInternal().toString();
}
}
@ -128,8 +125,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
public void writeNullableSimpleString(final SimpleString val) {
if (val == null) {
buffer.writeByte(DataConstants.NULL);
}
else {
} else {
buffer.writeByte(DataConstants.NOT_NULL);
writeSimpleStringInternal(val);
}
@ -139,8 +135,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
public void writeNullableString(final String val) {
if (val == null) {
buffer.writeByte(DataConstants.NULL);
}
else {
} else {
buffer.writeByte(DataConstants.NOT_NULL);
writeStringInternal(val);
}
@ -172,12 +167,10 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
for (int i = 0; i < val.length(); i++) {
buffer.writeShort((short) val.charAt(i));
}
}
else if (length < 0xfff) {
} else if (length < 0xfff) {
// Store as UTF - this is quicker than char by char for most strings
writeUTF(val);
}
else {
} else {
// Store as SimpleString, since can't store utf > 0xffff in length
writeSimpleStringInternal(new SimpleString(val));
}
@ -609,23 +602,28 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
buffer.writeShort(value);
}
/** from {@link java.io.DataInput} interface */
/**
* from {@link java.io.DataInput} interface
*/
@Override
public void readFully(byte[] b) throws IOException {
readBytes(b);
}
/** from {@link java.io.DataInput} interface */
/**
* from {@link java.io.DataInput} interface
*/
@Override
public void readFully(byte[] b, int off, int len) throws IOException {
readBytes(b, off, len);
}
/** from {@link java.io.DataInput} interface */
/**
* from {@link java.io.DataInput} interface
*/
@Override
public String readLine() throws IOException {
return ByteUtil.readLine(this);
}
}

View File

@ -25,10 +25,11 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.logging.Logger;
/** This is for components with a scheduled at a fixed rate. */
/**
* This is for components with a scheduled at a fixed rate.
*/
public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, Runnable {
private static final Logger logger = Logger.getLogger(ActiveMQScheduledComponent.class);
private final ScheduledExecutorService scheduledExecutorService;
private long period;
@ -69,8 +70,7 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R
}
if (period >= 0) {
future = scheduledExecutorService.scheduleWithFixedDelay(runForScheduler, period, period, timeUnit);
}
else {
} else {
logger.tracef("did not start scheduled executor on %s because period was configured as %d", this, period);
}
}
@ -79,8 +79,7 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R
int value = delayed.incrementAndGet();
if (value > 10) {
delayed.decrementAndGet();
}
else {
} else {
// We only schedule up to 10 periods upfront.
// this is to avoid a window where a current one would be running and a next one is coming.
// in theory just 2 would be enough. I'm using 10 as a precaution here.
@ -124,7 +123,6 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R
return future != null;
}
// this will restart the schedulped component upon changes
private void restartIfNeeded() {
if (isStarted()) {

View File

@ -17,10 +17,10 @@
package org.apache.activemq.artemis.logs;
import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
import org.jboss.logging.Messages;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageBundle;
import org.jboss.logging.Messages;
/**
* Logger Code 20

View File

@ -71,19 +71,19 @@ public class AssertionLoggerHandler extends ExtHandler {
return false;
}
public static boolean findText(long mstimeout, String ... text) {
public static boolean findText(long mstimeout, String... text) {
long timeMax = System.currentTimeMillis() + mstimeout;
do {
if (findText(text)) {
return true;
}
}
while (timeMax > System.currentTimeMillis());
} while (timeMax > System.currentTimeMillis());
return false;
}
/**
* Find a line that contains the parameters passed as an argument
*
@ -105,8 +105,7 @@ public class AssertionLoggerHandler extends ExtHandler {
if (!found) {
break;
}
}
else {
} else {
break;
}
}

View File

@ -41,8 +41,8 @@ public final class ActiveMQThreadFactory implements ThreadFactory {
* new threads if a security manager is installed.
*
* @param groupName the name of the thread group to assign threads to by default
* @param daemon whether the created threads should be daemon threads
* @param tccl the context class loader of newly created threads
* @param daemon whether the created threads should be daemon threads
* @param tccl the context class loader of newly created threads
*/
public ActiveMQThreadFactory(final String groupName, final boolean daemon, final ClassLoader tccl) {
group = new ThreadGroup(groupName + "-" + System.identityHashCode(this));
@ -61,8 +61,7 @@ public final class ActiveMQThreadFactory implements ThreadFactory {
// create a thread in a privileged block if running with Security Manager
if (acc != null) {
return AccessController.doPrivileged(new ThreadCreateAction(command), acc);
}
else {
} else {
return createThread(command);
}
}

View File

@ -41,8 +41,10 @@ import java.util.concurrent.atomic.AtomicInteger;
* executor is not limited. Only the offer method checks the configured limit.
*/
public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
@SuppressWarnings("serial")
private static class ThreadPoolQueue extends LinkedBlockingQueue<Runnable> {
private ActiveMQThreadPoolExecutor executor = null;
public void setExecutor(ActiveMQThreadPoolExecutor executor) {
@ -75,7 +77,12 @@ public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
}
// private constructor is needed to inject 'this' into the ThreadPoolQueue instance
private ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, TimeUnit keepUnits, ThreadPoolQueue myQueue, ThreadFactory factory) {
private ActiveMQThreadPoolExecutor(int coreSize,
int maxSize,
long keep,
TimeUnit keepUnits,
ThreadPoolQueue myQueue,
ThreadFactory factory) {
super(coreSize, Integer.MAX_VALUE, keep, keepUnits, myQueue, factory);
maxPoolSize = maxSize;
myQueue.setExecutor(this);

View File

@ -7,7 +7,6 @@
* don't have to match it up with any other open source license &em; just use it. You can rename the files, move the
* Java packages, whatever you want. If your lawyers say you have to have a license, contact me, and I'll make a special
* release to you under whatever reasonable license you desire: MIT, BSD, GPL, whatever."
*
*/
package org.apache.activemq.artemis.utils;
@ -313,11 +312,9 @@ public class Base64 {
private static byte[] getAlphabet(final int options) {
if ((options & Base64.URL_SAFE) == Base64.URL_SAFE) {
return Base64._URL_SAFE_ALPHABET;
}
else if ((options & Base64.ORDERED) == Base64.ORDERED) {
} else if ((options & Base64.ORDERED) == Base64.ORDERED) {
return Base64._ORDERED_ALPHABET;
}
else {
} else {
return Base64._STANDARD_ALPHABET;
}
@ -333,11 +330,9 @@ public class Base64 {
private static byte[] getDecodabet(final int options) {
if ((options & Base64.URL_SAFE) == Base64.URL_SAFE) {
return Base64._URL_SAFE_DECODABET;
}
else if ((options & Base64.ORDERED) == Base64.ORDERED) {
} else if ((options & Base64.ORDERED) == Base64.ORDERED) {
return Base64._ORDERED_DECODABET;
}
else {
} else {
return Base64._STANDARD_DECODABET;
}
@ -359,18 +354,15 @@ public class Base64 {
public static final void main(final String[] args) {
if (args.length < 3) {
Base64.usage("Not enough arguments.");
} // end if: args.length < 3
else {
} else { // end if: args.length < 3
String flag = args[0];
String infile = args[1];
String outfile = args[2];
if (flag.equals("-e")) {
Base64.encodeFileToFile(infile, outfile);
} // end if: encode
else if (flag.equals("-d")) {
} else if (flag.equals("-d")) { // end if: encode
Base64.decodeFileToFile(infile, outfile);
} // end else if: decode
else {
} else { // end else if: decode
Base64.usage("Unknown flag: " + flag);
} // end else
} // end else
@ -540,37 +532,31 @@ public class Base64 {
if (gzip == Base64.GZIP) {
gzos = new java.util.zip.GZIPOutputStream(b64os);
oos = new java.io.ObjectOutputStream(gzos);
} // end if: gzip
else {
// end if: gzip
} else {
oos = new java.io.ObjectOutputStream(b64os);
}
oos.writeObject(serializableObject);
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
e.printStackTrace();
return null;
} // end catch
finally {
} finally {
try {
oos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
gzos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
b64os.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
baos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
@ -670,35 +656,28 @@ public class Base64 {
gzos.write(source, off, len);
gzos.close();
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
e.printStackTrace();
return null;
} // end catch
finally {
} finally {
try {
gzos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
b64os.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
baos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
// Return value according to relevant encoding.
return new String(baos.toByteArray(), Base64.PREFERRED_ENCODING);
} // end if: compress
} else { // Else, don't compress. Better not to use streams at all then.
// Else, don't compress. Better not to use streams at all then.
else {
// Convert option to boolean in way that code likes it.
boolean breakLines = dontBreakLines == 0;
@ -775,10 +754,10 @@ public class Base64 {
destination[destOffset] = (byte) (outBuff >>> 16);
return 1;
}
} else if (source[srcOffset + 3] == Base64.EQUALS_SIGN) {
// Example: DkL=
// Example: DkL=
else if (source[srcOffset + 3] == Base64.EQUALS_SIGN) {
// Two ways to do the same thing. Don't know which way I like best.
// int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
// | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
@ -789,10 +768,8 @@ public class Base64 {
destination[destOffset] = (byte) (outBuff >>> 16);
destination[destOffset + 1] = (byte) (outBuff >>> 8);
return 2;
}
// Example: DkLE
else {
} else {
// Example: DkLE
try {
// Two ways to do the same thing. Don't know which way I like best.
// int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
@ -808,8 +785,7 @@ public class Base64 {
destination[destOffset + 2] = (byte) outBuff;
return 3;
}
catch (Exception e) {
} catch (Exception e) {
System.out.println("" + source[srcOffset] + ": " + DECODABET[source[srcOffset]]);
System.out.println("" + source[srcOffset + 1] + ": " + DECODABET[source[srcOffset + 1]]);
System.out.println("" + source[srcOffset + 2] + ": " + DECODABET[source[srcOffset + 2]]);
@ -862,8 +838,7 @@ public class Base64 {
} // end if: equals sign or better
} // end if: white space, equals sign or better
else {
} else {
System.err.println("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)");
return null;
} // end else:
@ -926,25 +901,20 @@ public class Base64 {
// No error? Get new bytes.
bytes = baos.toByteArray();
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
// Just return originally-decoded bytes
} // end catch
finally {
} finally {
try {
baos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
gzis.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
bais.close();
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
@ -975,25 +945,20 @@ public class Base64 {
ois = new java.io.ObjectInputStream(bais);
obj = ois.readObject();
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
e.printStackTrace();
obj = null;
} // end catch
catch (java.lang.ClassNotFoundException e) {
} catch (java.lang.ClassNotFoundException e) {
e.printStackTrace();
obj = null;
} // end catch
finally {
} finally {
try {
bais.close();
}
catch (Exception e) {
} catch (Exception e) {
}
try {
ois.close();
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
@ -1015,16 +980,13 @@ public class Base64 {
bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.ENCODE);
bos.write(dataToEncode);
success = true;
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
success = false;
} // end catch: IOException
finally {
} finally {
try {
bos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
@ -1046,15 +1008,12 @@ public class Base64 {
bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.DECODE);
bos.write(dataToDecode.getBytes(Base64.PREFERRED_ENCODING));
success = true;
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
success = false;
} // end catch: IOException
finally {
} finally {
try {
bos.close();
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
@ -1098,17 +1057,14 @@ public class Base64 {
decodedData = new byte[length];
System.arraycopy(buffer, 0, decodedData, 0, length);
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
System.err.println("Error decoding from file " + filename);
} // end catch: IOException
finally {
} finally {
try {
if (bis != null) {
bis.close();
}
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
@ -1145,15 +1101,12 @@ public class Base64 {
// Save in a variable to return
encodedData = new String(buffer, 0, length, Base64.PREFERRED_ENCODING);
} // end try
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
System.err.println("Error encoding from file " + filename);
} // end catch: IOException
finally {
} finally {
try {
bis.close();
}
catch (Exception e) {
} catch (Exception e) {
}
} // end finally
@ -1181,20 +1134,16 @@ public class Base64 {
out.write(buffer, 0, read);
} // end while: through file
success = true;
}
catch (java.io.IOException exc) {
} catch (java.io.IOException exc) {
exc.printStackTrace();
}
finally {
} finally {
try {
in.close();
}
catch (Exception exc) {
} catch (Exception exc) {
}
try {
out.close();
}
catch (Exception exc) {
} catch (Exception exc) {
}
} // end finally
@ -1222,20 +1171,16 @@ public class Base64 {
out.write(buffer, 0, read);
} // end while: through file
success = true;
}
catch (java.io.IOException exc) {
} catch (java.io.IOException exc) {
exc.printStackTrace();
}
finally {
} finally {
try {
in.close();
}
catch (Exception exc) {
} catch (Exception exc) {
}
try {
out.close();
}
catch (Exception exc) {
} catch (Exception exc) {
}
} // end finally
@ -1341,8 +1286,7 @@ public class Base64 {
numBinaryBytes++;
} // end if: not end of stream
} // end try: read
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
// Only a problem if we got no data at all.
if (i == 0) {
throw e;
@ -1355,14 +1299,10 @@ public class Base64 {
Base64.encode3to4(b3, 0, numBinaryBytes, buffer, 0, options);
position = 0;
numSigBytes = 4;
} // end if: got data
else {
} else {
return -1;
}
} // end if: encoding
// Else decoding
else {
} else { // Else decoding
byte[] b4 = new byte[4];
int i = 0;
for (i = 0; i < 4; i++) {
@ -1382,11 +1322,9 @@ public class Base64 {
if (i == 4) {
numSigBytes = Base64.decode4to3(b4, 0, buffer, 0, options);
position = 0;
} // end if: got four characters
else if (i == 0) {
} else if (i == 0) {
return -1;
}
else {
} else {
// Must have broken out from above.
throw new java.io.IOException("Improperly padded Base64 input.");
}
@ -1404,8 +1342,7 @@ public class Base64 {
if (encode && breakLines && lineLength >= Base64.MAX_LINE_LENGTH) {
lineLength = 0;
return '\n';
} // end if
else {
} else {
lineLength++; // This isn't important when decoding
// but throwing an extra "if" seems
// just as wasteful.
@ -1419,8 +1356,7 @@ public class Base64 {
return b & 0xFF; // This is how you "cast" a byte that's
// intended to be unsigned.
} // end else
} // end if: position >= 0
else {
} else {
// When JDK1.4 is more accepted, use an assertion here.
throw new java.io.IOException("Error in Base64 code reading stream.");
}
@ -1450,11 +1386,9 @@ public class Base64 {
if (b >= 0) {
dest[off + i] = (byte) b;
}
else if (i == 0) {
} else if (i == 0) {
return -1;
}
else {
} else {
break; // Out of 'for' loop
}
} // end for: each byte read
@ -1576,11 +1510,10 @@ public class Base64 {
} // end if: end of line
position = 0;
} // end if: enough to output
} // end if: encoding
}
} else {
// Else, Decoding
// Else, Decoding
else {
// Meaningful Base64 character?
if (decodabet[theByte & 0x7f] > Base64.WHITE_SPACE_ENC) {
buffer[position++] = (byte) theByte;
@ -1590,8 +1523,7 @@ public class Base64 {
// out.write( Base64.decode4to3( buffer ) );
position = 0;
} // end if: enough to output
} // end if: meaningful base64 character
else if (decodabet[theByte & 0x7f] != Base64.WHITE_SPACE_ENC) {
} else if (decodabet[theByte & 0x7f] != Base64.WHITE_SPACE_ENC) {
throw new java.io.IOException("Invalid character in Base64 data.");
}
} // end else: decoding
@ -1632,8 +1564,7 @@ public class Base64 {
if (encode) {
out.write(Base64.encode3to4(b4, buffer, position, options));
position = 0;
} // end if: encoding
else {
} else {
throw new java.io.IOException("Base64 input not properly padded.");
}
} // end if: buffer partially full

View File

@ -39,8 +39,7 @@ public class ByteUtil {
try {
logger.trace(message + "\n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16));
}
catch (Exception e) {
} catch (Exception e) {
logger.warn(e.getMessage(), e);
}
@ -48,7 +47,6 @@ public class ByteUtil {
}
}
public static String formatGroup(String str, int groupSize, int lineBreak) {
StringBuffer buffer = new StringBuffer();
@ -64,8 +62,7 @@ public class ByteUtil {
buffer.append(" ");
}
buffer.append(Integer.toString(line) + " */ \"");
}
else if ((i + groupSize) % groupSize == 0 && str.length() - i > groupSize) {
} else if ((i + groupSize) % groupSize == 0 && str.length() - i > groupSize) {
buffer.append("\" + \"");
}
}
@ -79,8 +76,7 @@ public class ByteUtil {
public static String maxString(String value, int size) {
if (value.length() < size) {
return value;
}
else {
} else {
return value.substring(0, size / 2) + " ... " + value.substring(value.length() - size / 2);
}
}
@ -138,7 +134,6 @@ public class ByteUtil {
return buffer.array();
}
public static String readLine(ActiveMQBuffer buffer) {
StringBuilder sb = new StringBuilder("");
char c = buffer.readChar();
@ -154,8 +149,7 @@ public class ByteUtil {
if (buffer.hasArray()) {
byte[] array = buffer.array();
System.arraycopy(array, buffer.arrayOffset() + buffer.position(), ret, 0, ret.length);
}
else {
} else {
buffer.slice().get(ret);
}
return ret;

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -25,20 +25,15 @@ import io.netty.channel.ChannelHandler;
import io.netty.handler.ssl.SslHandler;
public class CertificateUtil {
public static X509Certificate[] getCertsFromChannel(Channel channel) {
X509Certificate[] certificates = null;
ChannelHandler channelHandler = channel
.pipeline()
.get("ssl");
ChannelHandler channelHandler = channel.pipeline().get("ssl");
if (channelHandler != null && channelHandler instanceof SslHandler) {
SslHandler sslHandler = (SslHandler) channelHandler;
try {
certificates = sslHandler
.engine()
.getSession()
.getPeerCertificateChain();
}
catch (SSLPeerUnverifiedException e) {
certificates = sslHandler.engine().getSession().getPeerCertificateChain();
} catch (SSLPeerUnverifiedException e) {
// ignore
}
}

View File

@ -34,8 +34,7 @@ public final class ClassloadingUtil {
try {
Class<?> clazz = loader.loadClass(className);
return clazz.newInstance();
}
catch (Throwable t) {
} catch (Throwable t) {
if (t instanceof InstantiationException) {
System.out.println(INSTANTIATION_EXCEPTION_MESSAGE);
}
@ -45,14 +44,11 @@ public final class ClassloadingUtil {
try {
return loader.loadClass(className).newInstance();
}
catch (InstantiationException e) {
} catch (InstantiationException e) {
throw new RuntimeException(INSTANTIATION_EXCEPTION_MESSAGE + " " + className, e);
}
catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
catch (IllegalAccessException e) {
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@ -67,8 +63,7 @@ public final class ClassloadingUtil {
}
Class<?> clazz = loader.loadClass(className);
return clazz.getConstructor(parametersType).newInstance(objs);
}
catch (Throwable t) {
} catch (Throwable t) {
if (t instanceof InstantiationException) {
System.out.println(INSTANTIATION_EXCEPTION_MESSAGE);
}
@ -78,14 +73,11 @@ public final class ClassloadingUtil {
try {
return loader.loadClass(className).newInstance();
}
catch (InstantiationException e) {
} catch (InstantiationException e) {
throw new RuntimeException(INSTANTIATION_EXCEPTION_MESSAGE + " " + className, e);
}
catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
catch (IllegalAccessException e) {
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@ -97,8 +89,7 @@ public final class ClassloadingUtil {
URL resource = loader.getResource(resourceName);
if (resource != null)
return resource;
}
catch (Throwable t) {
} catch (Throwable t) {
}
loader = Thread.currentThread().getContextClassLoader();

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -16,16 +16,15 @@
*/
package org.apache.activemq.artemis.utils;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
/**
* A DefaultSensitiveDataCodec

View File

@ -75,8 +75,7 @@ public class FactoryFinder {
if (loader != null) {
try {
clazz = loader.loadClass(className);
}
catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e) {
// ignore
}
}
@ -108,12 +107,10 @@ public class FactoryFinder {
Properties properties = new Properties();
properties.load(reader);
return properties;
}
finally {
} finally {
try {
reader.close();
}
catch (Exception e) {
} catch (Exception e) {
}
}
}

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -41,13 +41,11 @@ public class FileUtil {
public static void makeExec(File file) throws IOException {
try {
Files.setPosixFilePermissions(file.toPath(), new HashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, OTHERS_READ, OTHERS_EXECUTE)));
}
catch (Throwable ignore) {
} catch (Throwable ignore) {
// Our best effort was not good enough :)
}
}
public static final boolean deleteDirectory(final File directory) {
if (directory.isDirectory()) {
String[] files = directory.list();
@ -56,8 +54,7 @@ public class FileUtil {
while (files == null && (attempts < num)) {
try {
Thread.sleep(100);
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
}
files = directory.list();
attempts++;
@ -65,8 +62,7 @@ public class FileUtil {
if (files == null) {
logger.warn("Could not list files to clean up in: " + directory.getAbsolutePath());
}
else {
} else {
for (String file : files) {
File f = new File(directory, file);
if (!deleteDirectory(f)) {
@ -79,5 +75,4 @@ public class FileUtil {
return directory.delete();
}
}

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -43,4 +43,4 @@ public class IPV6Util {
return host;
}
}
}

View File

@ -55,8 +55,7 @@ public class PasswordMaskingUtil {
try {
Class<?> clazz = loader.loadClass(codecClassName);
return (SensitiveDataCodec<String>) clazz.newInstance();
}
catch (Exception e) {
} catch (Exception e) {
throw ActiveMQUtilBundle.BUNDLE.errorCreatingCodec(e, codecClassName);
}
}

View File

@ -17,9 +17,11 @@
package org.apache.activemq.artemis.utils;
/** This is similar to a Runnable, except that we throw exceptions.
* In certain places we need to complete tasks after deliveries,
* and this will take care of those situations. */
/**
* This is similar to a Runnable, except that we throw exceptions.
* In certain places we need to complete tasks after deliveries,
* and this will take care of those situations.
*/
public abstract class PendingTask {
public abstract void run() throws Exception;

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -50,8 +50,7 @@ public class ReferenceCounterUtil implements ReferenceCounter {
if (value == 0) {
if (executor != null) {
executor.execute(runnable);
}
else {
} else {
runnable.run();
}
}

View File

@ -100,8 +100,7 @@ public class SelectorTranslator {
matchPos = 0;
}
}
else {
} else {
matchPos = 0;
}
}
@ -126,8 +125,7 @@ public class SelectorTranslator {
}
return buff.toString();
}
else {
} else {
return input;
}
}

View File

@ -20,6 +20,7 @@
package org.apache.activemq.artemis.utils;
public abstract class StringEscapeUtils {
/**
* Adapted from commons lang StringEscapeUtils, escapes a string
*
@ -38,14 +39,11 @@ public abstract class StringEscapeUtils {
// handle unicode
if (ch > 0xfff) {
stringBuilder.append("\\u").append(hex(ch));
}
else if (ch > 0xff) {
} else if (ch > 0xff) {
stringBuilder.append("\\u0").append(hex(ch));
}
else if (ch > 0x7f) {
} else if (ch > 0x7f) {
stringBuilder.append("\\u00").append(hex(ch));
}
else if (ch < 32) {
} else if (ch < 32) {
switch (ch) {
case '\b':
stringBuilder.append('\\').append('b');
@ -62,17 +60,15 @@ public abstract class StringEscapeUtils {
case '\r':
stringBuilder.append('\\').append('r');
break;
default :
default:
if (ch > 0xf) {
stringBuilder.append("\\u00").append(hex(ch));
}
else {
} else {
stringBuilder.append("\\u000").append(hex(ch));
}
break;
}
}
else {
} else {
switch (ch) {
case '\'':
stringBuilder.append('\\').append('\'');
@ -86,7 +82,7 @@ public abstract class StringEscapeUtils {
case '/':
stringBuilder.append('\\').append('/');
break;
default :
default:
stringBuilder.append(ch);
break;
}

View File

@ -154,11 +154,9 @@ public final class TypedProperties {
Object value = doGetProperty(key);
if (value == null) {
return Boolean.valueOf(null);
}
else if (value instanceof Boolean) {
} else if (value instanceof Boolean) {
return (Boolean) value;
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
return Boolean.valueOf(((SimpleString) value).toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -168,11 +166,9 @@ public final class TypedProperties {
Object value = doGetProperty(key);
if (value == null) {
return Byte.valueOf(null);
}
else if (value instanceof Byte) {
} else if (value instanceof Byte) {
return (Byte) value;
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
return Byte.parseByte(((SimpleString) value).toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -194,8 +190,7 @@ public final class TypedProperties {
Object value = doGetProperty(key);
if (value == null) {
return null;
}
else if (value instanceof byte[]) {
} else if (value instanceof byte[]) {
return (byte[]) value;
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -205,14 +200,11 @@ public final class TypedProperties {
Object value = doGetProperty(key);
if (value == null) {
return Double.valueOf(null);
}
else if (value instanceof Float) {
} else if (value instanceof Float) {
return ((Float) value).doubleValue();
}
else if (value instanceof Double) {
} else if (value instanceof Double) {
return (Double) value;
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
return Double.parseDouble(((SimpleString) value).toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -222,17 +214,13 @@ public final class TypedProperties {
Object value = doGetProperty(key);
if (value == null) {
return Integer.valueOf(null);
}
else if (value instanceof Integer) {
} else if (value instanceof Integer) {
return (Integer) value;
}
else if (value instanceof Byte) {
} else if (value instanceof Byte) {
return ((Byte) value).intValue();
}
else if (value instanceof Short) {
} else if (value instanceof Short) {
return ((Short) value).intValue();
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
return Integer.parseInt(((SimpleString) value).toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -242,20 +230,15 @@ public final class TypedProperties {
Object value = doGetProperty(key);
if (value == null) {
return Long.valueOf(null);
}
else if (value instanceof Long) {
} else if (value instanceof Long) {
return (Long) value;
}
else if (value instanceof Byte) {
} else if (value instanceof Byte) {
return ((Byte) value).longValue();
}
else if (value instanceof Short) {
} else if (value instanceof Short) {
return ((Short) value).longValue();
}
else if (value instanceof Integer) {
} else if (value instanceof Integer) {
return ((Integer) value).longValue();
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
return Long.parseLong(((SimpleString) value).toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -265,14 +248,11 @@ public final class TypedProperties {
Object value = doGetProperty(key);
if (value == null) {
return Short.valueOf(null);
}
else if (value instanceof Byte) {
} else if (value instanceof Byte) {
return ((Byte) value).shortValue();
}
else if (value instanceof Short) {
} else if (value instanceof Short) {
return (Short) value;
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
return Short.parseShort(((SimpleString) value).toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -300,29 +280,21 @@ public final class TypedProperties {
if (value instanceof SimpleString) {
return (SimpleString) value;
}
else if (value instanceof Boolean) {
} else if (value instanceof Boolean) {
return new SimpleString(value.toString());
}
else if (value instanceof Character) {
} else if (value instanceof Character) {
return new SimpleString(value.toString());
}
else if (value instanceof Byte) {
} else if (value instanceof Byte) {
return new SimpleString(value.toString());
}
else if (value instanceof Short) {
} else if (value instanceof Short) {
return new SimpleString(value.toString());
}
else if (value instanceof Integer) {
} else if (value instanceof Integer) {
return new SimpleString(value.toString());
}
else if (value instanceof Long) {
} else if (value instanceof Long) {
return new SimpleString(value.toString());
}
else if (value instanceof Float) {
} else if (value instanceof Float) {
return new SimpleString(value.toString());
}
else if (value instanceof Double) {
} else if (value instanceof Double) {
return new SimpleString(value.toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
@ -336,8 +308,7 @@ public final class TypedProperties {
if (size == 0) {
return false;
}
else {
} else {
return properties.containsKey(key);
}
}
@ -345,8 +316,7 @@ public final class TypedProperties {
public Set<SimpleString> getPropertyNames() {
if (size == 0) {
return Collections.emptySet();
}
else {
} else {
return properties.keySet();
}
}
@ -356,8 +326,7 @@ public final class TypedProperties {
if (b == DataConstants.NULL) {
properties = null;
}
else {
} else {
int numHeaders = buffer.readInt();
properties = new HashMap<>(numHeaders);
@ -440,8 +409,7 @@ public final class TypedProperties {
public synchronized void encode(final ActiveMQBuffer buffer) {
if (properties == null) {
buffer.writeByte(DataConstants.NULL);
}
else {
} else {
buffer.writeByte(DataConstants.NOT_NULL);
buffer.writeInt(properties.size());
@ -460,8 +428,7 @@ public final class TypedProperties {
public int getEncodeSize() {
if (properties == null) {
return DataConstants.SIZE_BYTE;
}
else {
} else {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + size;
}
}
@ -491,8 +458,7 @@ public final class TypedProperties {
if (theValue == null) {
sb.append("NULL-value");
}
else if (theValue instanceof byte[]) {
} else if (theValue instanceof byte[]) {
sb.append("[" + ByteUtil.maxString(ByteUtil.bytesToHex((byte[]) theValue, 2), 150) + ")");
if (iterItem.getKey().toString().startsWith("_AMQ_ROUTE_TO")) {
@ -506,14 +472,12 @@ public final class TypedProperties {
sb.append(",");
}
}
}
catch (Throwable e) {
} catch (Throwable e) {
sb.append("error-converting-longs=" + e.getMessage());
}
sb.append("]");
}
}
else {
} else {
sb.append(theValue.toString());
}
@ -542,8 +506,7 @@ public final class TypedProperties {
PropertyValue oldValue = properties.put(key, value);
if (oldValue != null) {
size += value.encodeSize() - oldValue.encodeSize();
}
else {
} else {
size += SimpleString.sizeofString(key) + value.encodeSize();
}
}
@ -557,8 +520,7 @@ public final class TypedProperties {
if (val == null) {
return null;
}
else {
} else {
size -= SimpleString.sizeofString(key) + val.encodeSize();
return val.getValue();
@ -574,8 +536,7 @@ public final class TypedProperties {
if (val == null) {
return null;
}
else {
} else {
return val.getValue();
}
}
@ -924,8 +885,7 @@ public final class TypedProperties {
Object val = entry.getValue().getValue();
if (val instanceof SimpleString) {
m.put(entry.getKey().toString(), ((SimpleString) val).toString());
}
else {
} else {
m.put(entry.getKey().toString(), val);
}
}
@ -942,41 +902,29 @@ public final class TypedProperties {
public static void setObjectProperty(final SimpleString key, final Object value, final TypedProperties properties) {
if (value == null) {
properties.putNullValue(key);
}
else if (value instanceof Boolean) {
} else if (value instanceof Boolean) {
properties.putBooleanProperty(key, (Boolean) value);
}
else if (value instanceof Byte) {
} else if (value instanceof Byte) {
properties.putByteProperty(key, (Byte) value);
}
else if (value instanceof Character) {
} else if (value instanceof Character) {
properties.putCharProperty(key, (Character) value);
}
else if (value instanceof Short) {
} else if (value instanceof Short) {
properties.putShortProperty(key, (Short) value);
}
else if (value instanceof Integer) {
} else if (value instanceof Integer) {
properties.putIntProperty(key, (Integer) value);
}
else if (value instanceof Long) {
} else if (value instanceof Long) {
properties.putLongProperty(key, (Long) value);
}
else if (value instanceof Float) {
} else if (value instanceof Float) {
properties.putFloatProperty(key, (Float) value);
}
else if (value instanceof Double) {
} else if (value instanceof Double) {
properties.putDoubleProperty(key, (Double) value);
}
else if (value instanceof String) {
} else if (value instanceof String) {
properties.putSimpleStringProperty(key, new SimpleString((String) value));
}
else if (value instanceof SimpleString) {
} else if (value instanceof SimpleString) {
properties.putSimpleStringProperty(key, (SimpleString) value);
}
else if (value instanceof byte[]) {
} else if (value instanceof byte[]) {
properties.putBytesProperty(key, (byte[]) value);
}
else {
} else {
throw new ActiveMQPropertyConversionException(value.getClass() + " is not a valid property type");
}
}

View File

@ -61,8 +61,7 @@ public final class UTF8Util {
buffer.byteBuffer[byteLocation] = (byte) buffer.charBuffer[byteLocation];
}
out.writeBytes(buffer.byteBuffer, 0, len);
}
else {
} else {
if (UTF8Util.isTrace) {
// This message is too verbose for debug, that's why we are using trace here
ActiveMQUtilLogger.LOGGER.trace("Saving string with utfSize=" + len + " stringSize=" + str.length());
@ -76,13 +75,11 @@ public final class UTF8Util {
char charAtPos = buffer.charBuffer[i];
if (charAtPos >= 1 && charAtPos < 0x7f) {
buffer.byteBuffer[charCount++] = (byte) charAtPos;
}
else if (charAtPos >= 0x800) {
} else if (charAtPos >= 0x800) {
buffer.byteBuffer[charCount++] = (byte) (0xE0 | charAtPos >> 12 & 0x0F);
buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 6 & 0x3F);
buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 0 & 0x3F);
}
else {
} else {
buffer.byteBuffer[charCount++] = (byte) (0xC0 | charAtPos >> 6 & 0x1F);
buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 0 & 0x3F);
}
@ -120,8 +117,7 @@ public final class UTF8Util {
if (byte1 > 0 && byte1 <= 0x7F) {
buffer.charBuffer[charCount++] = (char) byte1;
}
else {
} else {
int c = byte1 & 0xff;
switch (c >> 4) {
case 0xc:
@ -151,8 +147,7 @@ public final class UTF8Util {
value = new StringUtilBuffer();
softReference = new SoftReference<>(value);
UTF8Util.currenBuffer.set(softReference);
}
else {
} else {
value = softReference.get();
}
@ -188,11 +183,9 @@ public final class UTF8Util {
if (c >= 1 && c < 0x7f) {
calculatedLen++;
}
else if (c >= 0x800) {
} else if (c >= 0x800) {
calculatedLen += 3;
}
else {
} else {
calculatedLen += 2;
}
}

View File

@ -140,8 +140,7 @@ public final class UUID {
if (shift > 16) {
result ^= curr << shift | curr >>> 32 - shift;
}
else {
} else {
result ^= curr << shift;
}
}
@ -155,8 +154,7 @@ public final class UUID {
// Let's not accept hash 0 as it indicates 'not hashed yet':
if (result == 0) {
mHashCode = -1;
}
else {
} else {
mHashCode = result;
}
}
@ -220,8 +218,7 @@ public final class UUID {
int c2Bytes = Character.digit(c2, 16);
data[dataIdx++] = (byte) ((c1Bytes << 4) + c2Bytes);
}
}
catch (RuntimeException e) {
} catch (RuntimeException e) {
throw new IllegalArgumentException(e);
}
return data;

View File

@ -135,8 +135,7 @@ public final class UUIDGenerator {
// check if we have enough security permissions to create and shutdown an executor
ExecutorService executor = Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory());
executor.shutdownNow();
}
catch (Throwable t) {
} catch (Throwable t) {
// not enough security permission
return null;
}
@ -156,8 +155,7 @@ public final class UUIDGenerator {
return address;
}
return null;
}
catch (Exception e) {
} catch (Exception e) {
return null;
}
}
@ -179,8 +177,7 @@ public final class UUIDGenerator {
if (address == null) {
return java.util.UUID.randomUUID().toString();
}
else {
} else {
return generateTimeBasedUUID(address).toString();
}
}
@ -192,8 +189,7 @@ public final class UUIDGenerator {
if (bytes.length > 0 && bytes.length <= 6) {
if (bytes.length == 6) {
return bytes;
}
else {
} else {
// pad with zeroes to have a 6-byte array
byte[] paddedAddress = new byte[6];
System.arraycopy(bytes, 0, paddedAddress, 0, bytes.length);
@ -256,8 +252,7 @@ public final class UUIDGenerator {
ifaces.add(networkInterfaces.nextElement());
}
return ifaces;
}
catch (SocketException e) {
} catch (SocketException e) {
return Collections.emptyList();
}
}
@ -300,11 +295,9 @@ public final class UUIDGenerator {
// we wait 5 seconds to get the first matching hardware address. After that, we give up and return null
byte[] address = executor.invokeAny(tasks, 5, TimeUnit.SECONDS);
return address;
}
catch (Exception e) {
} catch (Exception e) {
return null;
}
finally {
} finally {
executor.shutdownNow();
}
}

View File

@ -179,8 +179,7 @@ public class UUIDTimer {
*/
if (mClockCounter < UUIDTimer.kClockMultiplier) { // yup, still have room
systime = mLastUsedTimestamp;
}
else { // nope, have to roll over to next value and maybe wait
} else { // nope, have to roll over to next value and maybe wait
long actDiff = mLastUsedTimestamp - systime;
long origTime = systime;
systime = mLastUsedTimestamp + 1L;
@ -205,8 +204,7 @@ public class UUIDTimer {
UUIDTimer.slowDown(origTime, actDiff);
}
}
}
else {
} else {
/*
* Clock has advanced normally; just need to make sure counter is reset
* to a low value (need not be 0; good to leave a small residual to
@ -271,14 +269,11 @@ public class UUIDTimer {
if (ratio < 2L) { // 200 msecs or less
delay = 1L;
}
else if (ratio < 10L) { // 1 second or less
} else if (ratio < 10L) { // 1 second or less
delay = 2L;
}
else if (ratio < 600L) { // 1 minute or less
} else if (ratio < 600L) { // 1 minute or less
delay = 3L;
}
else {
} else {
delay = 5L;
}
// Logger.logWarning("Need to wait for "+delay+" milliseconds; virtual
@ -288,8 +283,7 @@ public class UUIDTimer {
do {
try {
Thread.sleep(delay);
}
catch (InterruptedException ie) {
} catch (InterruptedException ie) {
}
delay = 1L;
/*

View File

@ -62,7 +62,7 @@ public class BeanSupport {
return obj;
}
public static <P> P setData( P obj, Map<String, Object> data) throws Exception {
public static <P> P setData(P obj, Map<String, Object> data) throws Exception {
synchronized (beanUtils) {
beanUtils.populate(obj, data);
}
@ -86,8 +86,7 @@ public class BeanSupport {
for (Map.Entry<String, String> entry : query.entrySet()) {
if (allowableProperties.contains(entry.getKey())) {
properties.put(entry.getKey(), entry.getValue());
}
else {
} else {
extraProps.put(entry.getKey(), entry.getValue());
}
}
@ -136,7 +135,6 @@ public class BeanSupport {
(type == String.class);
}
public static String decodeURI(String value) throws UnsupportedEncodingException {
return URLDecoder.decode(value, "UTF-8");
}

View File

@ -29,6 +29,7 @@ import org.apache.commons.beanutils.IntrospectionContext;
import org.jboss.logging.Logger;
public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBeanIntrospector {
static Logger logger = Logger.getLogger(FluentPropertyBeanIntrospectorWithIgnores.class);
private static ConcurrentHashSet<Pair<String, String>> ignores = new ConcurrentHashSet<>();
@ -56,12 +57,10 @@ public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBea
try {
if (pd == null) {
icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName));
}
else if (pd.getWriteMethod() == null) {
} else if (pd.getWriteMethod() == null) {
pd.setWriteMethod(m);
}
}
catch (IntrospectionException e) {
} catch (IntrospectionException e) {
logger.debug(e.getMessage(), e);
}
}

View File

@ -73,7 +73,6 @@ public class URIFactory<T, P> {
schemaFactory.populateObject(uri, bean);
}
public void populateObject(String uri, T bean) throws Exception {
populateObject(new URI(uri), bean);
}
@ -106,8 +105,7 @@ public class URIFactory<T, P> {
if (factoryQuery != null && factoryQuery.length() > 0) {
if (connectorURIS[0].contains("?")) {
builder.append("&").append(factoryQuery.substring(1));
}
else {
} else {
builder.append(factoryQuery);
}
}

View File

@ -60,8 +60,7 @@ public abstract class URISchema<T, P> {
URIFactory<T, P> factory = getFactory();
if (factory == null) {
return null;
}
else {
} else {
return factory.getDefaultURI();
}
}
@ -112,8 +111,7 @@ public abstract class URISchema<T, P> {
String name = BeanSupport.decodeURI(parameter.substring(0, p));
String value = BeanSupport.decodeURI(parameter.substring(p + 1));
rc.put(name, value);
}
else {
} else {
if (!parameter.trim().isEmpty()) {
rc.put(parameter, null);
}
@ -127,8 +125,7 @@ public abstract class URISchema<T, P> {
}
}
return rc;
}
catch (UnsupportedEncodingException e) {
} catch (UnsupportedEncodingException e) {
throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e);
}
}

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -83,8 +83,7 @@ public class URISupport {
if (host != null && host.length() != 0) {
sb.append(host);
}
else {
} else {
sb.append('(');
for (int i = 0; i < components.length; i++) {
if (i != 0) {
@ -127,8 +126,7 @@ public class URISupport {
parseParameters(rc, uri.split(";"));
}
return rc;
}
catch (UnsupportedEncodingException e) {
} catch (UnsupportedEncodingException e) {
throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e);
}
}
@ -141,8 +139,7 @@ public class URISupport {
String name = URLDecoder.decode(parameter.substring(0, p), "UTF-8");
String value = URLDecoder.decode(parameter.substring(p + 1), "UTF-8");
rc.put(name, value);
}
else {
} else {
rc.put(parameter, null);
}
}
@ -161,8 +158,7 @@ public class URISupport {
public static Map<String, String> parseParameters(URI uri) throws URISyntaxException {
if (!isCompositeURI(uri)) {
return uri.getQuery() == null ? emptyMap() : parseQuery(stripPrefix(uri.getQuery(), "?"));
}
else {
} else {
CompositeData data = URISupport.parseComposite(uri);
Map<String, String> parameters = new HashMap<>();
parameters.putAll(data.getParameters());
@ -317,8 +313,7 @@ public class URISupport {
char current = array[index];
if (current == '(') {
depth++;
}
else if (current == ')') {
} else if (current == ')') {
if (--depth == 0) {
break;
}
@ -366,8 +361,7 @@ public class URISupport {
componentString = ssp.substring(initialParen + 1, p);
params = ssp.substring(p + 1).trim();
}
else {
} else {
componentString = ssp;
params = "";
}
@ -384,8 +378,7 @@ public class URISupport {
rc.path = stripPrefix(params.substring(0, p), "/");
}
rc.parameters = parseQuery(params.substring(p + 1));
}
else {
} else {
if (params.length() > 0) {
rc.path = stripPrefix(params, "/");
}
@ -479,8 +472,7 @@ public class URISupport {
for (String key : keys) {
if (first) {
first = false;
}
else {
} else {
rc.append("&");
}
String value = (String) options.get(key);
@ -489,12 +481,10 @@ public class URISupport {
rc.append(URLEncoder.encode(value, "UTF-8"));
}
return rc.toString();
}
else {
} else {
return "";
}
}
catch (UnsupportedEncodingException e) {
} catch (UnsupportedEncodingException e) {
throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e);
}
}

View File

@ -34,10 +34,11 @@ import org.junit.Test;
public class ActiveMQScheduledComponentTest {
@Rule
public ThreadLeakCheckRule rule = new ThreadLeakCheckRule();
public ThreadLeakCheckRule rule = new ThreadLeakCheckRule();
ScheduledExecutorService scheduledExecutorService;
ExecutorService executorService;
@Before
public void before() {
scheduledExecutorService = new ScheduledThreadPoolExecutor(5);
@ -54,15 +55,13 @@ public class ActiveMQScheduledComponentTest {
public void testAccumulation() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
final ActiveMQScheduledComponent local = new ActiveMQScheduledComponent(scheduledExecutorService, executorService, 100, TimeUnit.MILLISECONDS, false) {
@Override
public void run() {
if (count.get() == 0) {
try {
Thread.sleep(800);
}
catch (Exception e) {
} catch (Exception e) {
}
}
count.incrementAndGet();

View File

@ -16,12 +16,12 @@
*/
package org.apache.activemq.artemis.utils;
import java.util.Iterator;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Iterator;
public class ConcurrentHashSetTest extends Assert {
// Constants -----------------------------------------------------

View File

@ -16,10 +16,9 @@
*/
package org.apache.activemq.artemis.utils;
import org.junit.Test;
import org.junit.Assert;
import org.apache.activemq.artemis.api.core.Pair;
import org.junit.Assert;
import org.junit.Test;
public class PairTest extends Assert {

View File

@ -75,8 +75,7 @@ public class ReferenceCounterTest extends Assert {
if (executor == null) {
ref = new ReferenceCounterUtil(runner);
}
else {
} else {
ref = new ReferenceCounterUtil(runner, executor);
}

View File

@ -34,6 +34,7 @@ import org.junit.rules.ExternalResource;
* This is useful to make sure you won't have leaking threads between tests
*/
public class ThreadLeakCheckRule extends ExternalResource {
private static Logger log = Logger.getLogger(ThreadLeakCheckRule.class);
private static Set<String> knownThreads = new HashSet<>();
@ -79,26 +80,22 @@ public class ThreadLeakCheckRule extends ExternalResource {
forceGC();
try {
Thread.sleep(500);
}
catch (Throwable e) {
} catch (Throwable e) {
}
}
}
if (failed) {
Assert.fail("Thread leaked");
}
else if (failedOnce) {
} else if (failedOnce) {
System.out.println("******************** Threads cleared after retries ********************");
System.out.println();
}
}
else {
} else {
enabled = true;
}
}
finally {
} finally {
// clearing just to help GC
previousThreads = null;
}
@ -125,16 +122,14 @@ public class ThreadLeakCheckRule extends ExternalResource {
System.runFinalization();
try {
finalized.await(100, TimeUnit.MILLISECONDS);
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
}
}
if (dumbReference.get() != null) {
failedGCCalls++;
log.info("It seems that GC is disabled at your VM");
}
else {
} else {
// a success would reset the count
failedGCCalls = 0;
}
@ -154,8 +149,7 @@ public class ThreadLeakCheckRule extends ExternalResource {
System.gc();
try {
Thread.sleep(500);
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
}
}
}
@ -175,7 +169,6 @@ public class ThreadLeakCheckRule extends ExternalResource {
if (postThreads != null && previousThreads != null && postThreads.size() > previousThreads.size()) {
for (Thread aliveThread : postThreads.keySet()) {
if (aliveThread.isAlive() && !isExpectedThread(aliveThread) && !previousThreads.containsKey(aliveThread)) {
if (!failedThread) {
@ -197,11 +190,9 @@ public class ThreadLeakCheckRule extends ExternalResource {
}
}
return failedThread;
}
/**
* if it's an expected thread... we will just move along ignoring it
*
@ -216,50 +207,39 @@ public class ThreadLeakCheckRule extends ExternalResource {
if (threadName.contains("SunPKCS11")) {
return true;
}
else if (threadName.contains("Attach Listener")) {
} else if (threadName.contains("Attach Listener")) {
return true;
}
else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("process reaper")) {
} else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("process reaper")) {
return true;
}
else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("ClassCache Reaper")) {
} else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("ClassCache Reaper")) {
return true;
}
else if (javaVendor.contains("IBM") && threadName.equals("MemoryPoolMXBean notification dispatcher")) {
} else if (javaVendor.contains("IBM") && threadName.equals("MemoryPoolMXBean notification dispatcher")) {
return true;
}
else if (threadName.contains("globalEventExecutor")) {
} else if (threadName.contains("globalEventExecutor")) {
return true;
}
else if (threadName.contains("threadDeathWatcher")) {
} else if (threadName.contains("threadDeathWatcher")) {
return true;
}
else if (threadName.contains("netty-threads")) {
} else if (threadName.contains("netty-threads")) {
// This is ok as we use EventLoopGroup.shutdownGracefully() which will shutdown things with a bit of delay
// if the EventLoop's are still busy.
return true;
}
else if (threadName.contains("threadDeathWatcher")) {
} else if (threadName.contains("threadDeathWatcher")) {
//another netty thread
return true;
}
else if (threadName.contains("Abandoned connection cleanup thread")) {
} else if (threadName.contains("Abandoned connection cleanup thread")) {
// MySQL Engine checks for abandoned connections
return true;
}
else if (threadName.contains("hawtdispatch")) {
} else if (threadName.contains("hawtdispatch")) {
// Static workers used by MQTT client.
return true;
}
else {
} else {
for (StackTraceElement element : thread.getStackTrace()) {
if (element.getClassName().contains("org.jboss.byteman.agent.TransformListener")) {
return true;
}
}
for (String known: knownThreads) {
for (String known : knownThreads) {
if (threadName.contains(known)) {
return true;
}
@ -269,7 +249,6 @@ public class ThreadLeakCheckRule extends ExternalResource {
}
}
protected static class DumbReference {
private CountDownLatch finalized;

View File

@ -61,8 +61,7 @@ public class TypedPropertiesConversionTest {
props.putByteProperty(key, RandomUtil.randomByte());
props.getBooleanProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
Assert.assertFalse(props.getBooleanProperty(unknownKey));
@ -80,15 +79,13 @@ public class TypedPropertiesConversionTest {
props.putByteProperty(key, RandomUtil.randomByte());
props.getCharProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getCharProperty(unknownKey);
Assert.fail();
}
catch (NullPointerException e) {
} catch (NullPointerException e) {
}
}
@ -107,15 +104,13 @@ public class TypedPropertiesConversionTest {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getByteProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getByteProperty(unknownKey);
Assert.fail();
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
}
}
@ -138,15 +133,13 @@ public class TypedPropertiesConversionTest {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getIntProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getIntProperty(unknownKey);
Assert.fail();
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
}
}
@ -177,15 +170,13 @@ public class TypedPropertiesConversionTest {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getLongProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getLongProperty(unknownKey);
Assert.fail();
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
}
}
@ -204,15 +195,13 @@ public class TypedPropertiesConversionTest {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getDoubleProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getDoubleProperty(unknownKey);
Assert.fail();
}
catch (Exception e) {
} catch (Exception e) {
}
}
@ -232,15 +221,13 @@ public class TypedPropertiesConversionTest {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getFloatProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getFloatProperty(unknownKey);
Assert.fail();
}
catch (Exception e) {
} catch (Exception e) {
}
}
@ -264,15 +251,13 @@ public class TypedPropertiesConversionTest {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getShortProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getShortProperty(unknownKey);
Assert.fail();
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
}
}
@ -294,8 +279,7 @@ public class TypedPropertiesConversionTest {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getBytesProperty(key);
Assert.fail();
}
catch (ActiveMQPropertyConversionException e) {
} catch (ActiveMQPropertyConversionException e) {
}
Assert.assertNull(props.getBytesProperty(unknownKey));

View File

@ -41,8 +41,7 @@ public class TypedPropertiesTest {
byte[] expectedBytes = (byte[]) expectedValue;
byte[] actualBytes = (byte[]) actualValue;
Assert.assertArrayEquals(expectedBytes, actualBytes);
}
else {
} else {
Assert.assertEquals(expectedValue, actualValue);
}
}

View File

@ -63,13 +63,11 @@ public class URIParserTest {
myFruit.setFluentName("apples&bananas with &host=3344");
URI uri = parser.createSchema("fruit", myFruit);
Fruit newFruit = (Fruit)parser.newObject(uri, "something");
Fruit newFruit = (Fruit) parser.newObject(uri, "something");
Assert.assertEquals(myFruit.getHost(), newFruit.getHost());
Assert.assertEquals(myFruit.getFluentName(), newFruit.getFluentName());
}
/**

View File

@ -14,7 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -93,7 +94,8 @@
<maxmemory>512m</maxmemory>
<quiet>false</quiet>
<aggregate>true</aggregate>
<excludePackageNames>org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils</excludePackageNames>
<excludePackageNames>org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils
</excludePackageNames>
</configuration>
<executions>
<execution>

View File

@ -526,7 +526,9 @@ public final class ActiveMQDefaultConfiguration {
return DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS;
}
/** The default Cluster address for the Cluster connection*/
/**
* The default Cluster address for the Cluster connection
*/
public static String getDefaultClusterAddress() {
return DEFAULT_CLUSTER_ADDRESS;
}
@ -733,6 +735,7 @@ public final class ActiveMQDefaultConfiguration {
/**
* How many journal files can be resued
*
* @return
*/
public static int getDefaultJournalPoolFiles() {
@ -1060,14 +1063,14 @@ public final class ActiveMQDefaultConfiguration {
/**
* if we have to start as a replicated server this is the delay to wait before fail-back occurs
* @deprecated use getDefaultInitialReplicationSyncTimeout()
*
* @deprecated use getDefaultInitialReplicationSyncTimeout()
*/
@Deprecated
public static long getDefaultFailbackDelay() {
return 5000;
}
/**
* Will this backup server come live on a normal server shutdown
*/
@ -1151,7 +1154,9 @@ public final class ActiveMQDefaultConfiguration {
return DEFAULT_CONFIGURATION_FILE_REFRESH_PERIOD;
}
/** The default global max size. -1 = no global max size. */
/**
* The default global max size. -1 = no global max size.
*/
public static long getDefaultMaxGlobalSize() {
return DEFAULT_GLOBAL_MAX_SIZE;
}

View File

@ -101,20 +101,17 @@ public final class BroadcastGroupConfiguration implements Serializable {
if (connectorInfos == null) {
if (other.connectorInfos != null)
return false;
}
else if (!connectorInfos.equals(other.connectorInfos))
} else if (!connectorInfos.equals(other.connectorInfos))
return false;
if (endpointFactory == null) {
if (other.endpointFactory != null)
return false;
}
else if (!endpointFactory.equals(other.endpointFactory))
} else if (!endpointFactory.equals(other.endpointFactory))
return false;
if (name == null) {
if (other.name != null)
return false;
}
else if (!name.equals(other.name))
} else if (!name.equals(other.name))
return false;
return true;
}

View File

@ -72,7 +72,6 @@ public final class FilterConstants {
*/
public static final SimpleString ACTIVEMQ_PREFIX = new SimpleString("AMQ");
private FilterConstants() {
// Utility class
}

View File

@ -16,12 +16,13 @@
*/
package org.apache.activemq.artemis.api.core;
import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.api.core.jgroups.JChannelManager;
import org.apache.activemq.artemis.api.core.jgroups.JChannelWrapper;
import org.apache.activemq.artemis.api.core.jgroups.JGroupsReceiver;
import org.jboss.logging.Logger;
import org.jgroups.JChannel;
import java.util.concurrent.TimeUnit;
/**
* This class is the implementation of ActiveMQ Artemis members discovery that will use JGroups.
@ -49,7 +50,8 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
@Override
public void broadcast(final byte[] data) throws Exception {
if (logger.isTraceEnabled()) logger.trace("Broadcasting: BroadCastOpened=" + broadcastOpened + ", channelOPen=" + channel.getChannel().isOpen());
if (logger.isTraceEnabled())
logger.trace("Broadcasting: BroadCastOpened=" + broadcastOpened + ", channelOPen=" + channel.getChannel().isOpen());
if (broadcastOpened) {
org.jgroups.Message msg = new org.jgroups.Message();
@ -61,22 +63,22 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
@Override
public byte[] receiveBroadcast() throws Exception {
if (logger.isTraceEnabled()) logger.trace("Receiving Broadcast: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen());
if (logger.isTraceEnabled())
logger.trace("Receiving Broadcast: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen());
if (clientOpened) {
return receiver.receiveBroadcast();
}
else {
} else {
return null;
}
}
@Override
public byte[] receiveBroadcast(long time, TimeUnit unit) throws Exception {
if (logger.isTraceEnabled()) logger.trace("Receiving Broadcast2: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen());
if (logger.isTraceEnabled())
logger.trace("Receiving Broadcast2: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen());
if (clientOpened) {
return receiver.receiveBroadcast(time, unit);
}
else {
} else {
return null;
}
}
@ -115,8 +117,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
public synchronized void close(boolean isBroadcast) throws Exception {
if (isBroadcast) {
broadcastOpened = false;
}
else {
} else {
channel.removeReceiver(receiver);
clientOpened = false;
}
@ -126,6 +127,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
/**
* Closes the channel used in this JGroups Broadcast.
* Can be overridden by implementations that use an externally managed channel.
*
* @param channel
*/
protected synchronized void internalCloseChannel(JChannelWrapper channel) {

View File

@ -29,7 +29,7 @@ public class JGroupsChannelBroadcastEndpoint extends JGroupsBroadcastEndpoint {
private final JChannel jChannel;
public JGroupsChannelBroadcastEndpoint(JChannelManager manager, JChannel jChannel, final String channelName) {
public JGroupsChannelBroadcastEndpoint(JChannelManager manager, JChannel jChannel, final String channelName) {
super(manager, channelName);
this.jChannel = jChannel;
}

View File

@ -16,11 +16,11 @@
*/
package org.apache.activemq.artemis.api.core;
import java.net.URL;
import org.apache.activemq.artemis.api.core.jgroups.JChannelManager;
import org.jgroups.JChannel;
import java.net.URL;
/**
* This class is the implementation of ActiveMQ Artemis members discovery that will use JGroups.
*/
@ -28,7 +28,9 @@ public final class JGroupsFileBroadcastEndpoint extends JGroupsBroadcastEndpoint
private String file;
public JGroupsFileBroadcastEndpoint(final JChannelManager manager, final String file, final String channelName) throws Exception {
public JGroupsFileBroadcastEndpoint(final JChannelManager manager,
final String file,
final String channelName) throws Exception {
super(manager, channelName);
this.file = file;
}

View File

@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.api.core;
import org.apache.activemq.artemis.api.core.jgroups.JChannelManager;
public class JGroupsFileBroadcastEndpointFactory implements BroadcastEndpointFactory {

View File

@ -23,11 +23,13 @@ import org.jgroups.conf.PlainConfigurator;
/**
* This class is the implementation of ActiveMQ Artemis members discovery that will use JGroups.
*/
public final class JGroupsPropertiesBroadcastEndpoint extends JGroupsBroadcastEndpoint {
public final class JGroupsPropertiesBroadcastEndpoint extends JGroupsBroadcastEndpoint {
private String properties;
public JGroupsPropertiesBroadcastEndpoint(final JChannelManager manager, final String properties, final String channelName) throws Exception {
public JGroupsPropertiesBroadcastEndpoint(final JChannelManager manager,
final String properties,
final String channelName) throws Exception {
super(manager, channelName);
this.properties = properties;
}

View File

@ -16,12 +16,6 @@
*/
package org.apache.activemq.artemis.api.core;
import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
import org.apache.activemq.artemis.utils.StringEscapeUtils;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
@ -39,7 +33,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
import org.apache.activemq.artemis.utils.StringEscapeUtils;
public final class JsonUtil {
public static JsonArray toJSONArray(final Object[] array) throws Exception {
JsonArrayBuilder jsonArray = JsonLoader.createArrayBuilder();
@ -58,15 +59,13 @@ public final class JsonUtil {
if (val.getClass().isArray()) {
JsonArray objectArray = toJSONArray((Object[]) val);
jsonObject.add(key, objectArray);
}
else {
} else {
addToObject(key, val, jsonObject);
}
}
}
jsonArray.add(jsonObject);
}
else {
} else {
if (parameter != null) {
Class<?> clz = parameter.getClass();
@ -82,16 +81,13 @@ public final class JsonUtil {
JsonObjectBuilder jsonObject = JsonLoader.createObjectBuilder();
jsonObject.add(CompositeData.class.getName(), innerJsonArray);
jsonArray.add(jsonObject);
}
else {
} else {
jsonArray.add(toJSONArray(innerArray));
}
}
else {
} else {
addToArray(parameter, jsonArray);
}
}
else {
} else {
jsonArray.addNull();
}
}
@ -109,8 +105,7 @@ public final class JsonUtil {
Object[] inner = fromJsonArray((JsonArray) val);
array[i] = inner;
}
else if (val instanceof JsonObject) {
} else if (val instanceof JsonObject) {
JsonObject jsonObject = (JsonObject) val;
Map<String, Object> map = new HashMap<>();
@ -122,26 +117,20 @@ public final class JsonUtil {
if (innerVal instanceof JsonArray) {
innerVal = fromJsonArray(((JsonArray) innerVal));
}
else if (innerVal instanceof JsonString) {
innerVal = ((JsonString)innerVal).getString();
}
else if (innerVal == JsonValue.FALSE) {
} else if (innerVal instanceof JsonString) {
innerVal = ((JsonString) innerVal).getString();
} else if (innerVal == JsonValue.FALSE) {
innerVal = Boolean.FALSE;
}
else if (innerVal == JsonValue.TRUE) {
} else if (innerVal == JsonValue.TRUE) {
innerVal = Boolean.TRUE;
}
else if (innerVal instanceof JsonNumber) {
JsonNumber jsonNumber = (JsonNumber)innerVal;
} else if (innerVal instanceof JsonNumber) {
JsonNumber jsonNumber = (JsonNumber) innerVal;
if (jsonNumber.isIntegral()) {
innerVal = jsonNumber.longValue();
}
else {
} else {
innerVal = jsonNumber.doubleValue();
}
}
else if (innerVal instanceof JsonObject) {
} else if (innerVal instanceof JsonObject) {
Map<String, Object> innerMap = new HashMap<>();
JsonObject o = (JsonObject) innerVal;
Set<String> innerKeys = o.keySet();
@ -154,7 +143,7 @@ public final class JsonUtil {
Object[] data = (Object[]) innerVal;
CompositeData[] cds = new CompositeData[data.length];
for (int i1 = 0; i1 < data.length; i1++) {
String dataConverted = convertJsonValue(data[i1], String.class).toString();
String dataConverted = convertJsonValue(data[i1], String.class).toString();
ObjectInputStreamWithClassLoader ois = new ObjectInputStreamWithClassLoader(new ByteArrayInputStream(Base64.decode(dataConverted)));
ois.setWhiteList("java.util,java.lang,javax.management");
cds[i1] = (CompositeDataSupport) ois.readObject();
@ -166,30 +155,23 @@ public final class JsonUtil {
}
array[i] = map;
}
else if (val instanceof JsonString) {
array[i] = ((JsonString)val).getString();
}
else if (val == JsonValue.FALSE) {
} else if (val instanceof JsonString) {
array[i] = ((JsonString) val).getString();
} else if (val == JsonValue.FALSE) {
array[i] = Boolean.FALSE;
}
else if (val == JsonValue.TRUE) {
} else if (val == JsonValue.TRUE) {
array[i] = Boolean.TRUE;
}
else if (val instanceof JsonNumber) {
JsonNumber jsonNumber = (JsonNumber)val;
} else if (val instanceof JsonNumber) {
JsonNumber jsonNumber = (JsonNumber) val;
if (jsonNumber.isIntegral()) {
array[i] = jsonNumber.longValue();
}
else {
} else {
array[i] = jsonNumber.doubleValue();
}
}
else {
} else {
if (val == JsonValue.NULL) {
array[i] = null;
}
else {
} else {
array[i] = val;
}
}
@ -205,36 +187,26 @@ public final class JsonUtil {
public static void addToObject(final String key, final Object param, final JsonObjectBuilder jsonObjectBuilder) {
if (param instanceof Integer) {
jsonObjectBuilder.add(key, (Integer) param);
}
else if (param instanceof Long) {
} else if (param instanceof Long) {
jsonObjectBuilder.add(key, (Long) param);
}
else if (param instanceof Double) {
} else if (param instanceof Double) {
jsonObjectBuilder.add(key, (Double) param);
}
else if (param instanceof String) {
} else if (param instanceof String) {
jsonObjectBuilder.add(key, (String) param);
}
else if (param instanceof Boolean) {
} else if (param instanceof Boolean) {
jsonObjectBuilder.add(key, (Boolean) param);
}
else if (param instanceof Map) {
JsonObject mapObject = toJsonObject((Map<String,Object>) param);
} else if (param instanceof Map) {
JsonObject mapObject = toJsonObject((Map<String, Object>) param);
jsonObjectBuilder.add(key, mapObject);
}
else if (param instanceof Short) {
} else if (param instanceof Short) {
jsonObjectBuilder.add(key, (Short) param);
}
else if (param instanceof Byte) {
} else if (param instanceof Byte) {
jsonObjectBuilder.add(key, ((Byte) param).shortValue());
}
else if (param instanceof SimpleString) {
} else if (param instanceof SimpleString) {
jsonObjectBuilder.add(key, param.toString());
}
else if (param == null) {
} else if (param == null) {
jsonObjectBuilder.addNull(key);
}
else {
} else {
throw ActiveMQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName());
}
}
@ -242,33 +214,24 @@ public final class JsonUtil {
public static void addToArray(final Object param, final JsonArrayBuilder jsonArrayBuilder) {
if (param instanceof Integer) {
jsonArrayBuilder.add((Integer) param);
}
else if (param instanceof Long) {
} else if (param instanceof Long) {
jsonArrayBuilder.add((Long) param);
}
else if (param instanceof Double) {
} else if (param instanceof Double) {
jsonArrayBuilder.add((Double) param);
}
else if (param instanceof String) {
} else if (param instanceof String) {
jsonArrayBuilder.add((String) param);
}
else if (param instanceof Boolean) {
} else if (param instanceof Boolean) {
jsonArrayBuilder.add((Boolean) param);
}
else if (param instanceof Map) {
JsonObject mapObject = toJsonObject((Map<String,Object>) param);
} else if (param instanceof Map) {
JsonObject mapObject = toJsonObject((Map<String, Object>) param);
jsonArrayBuilder.add(mapObject);
}
else if (param instanceof Short) {
} else if (param instanceof Short) {
jsonArrayBuilder.add((Short) param);
}
else if (param instanceof Byte) {
} else if (param instanceof Byte) {
jsonArrayBuilder.add(((Byte) param).shortValue());
}
else if (param == null) {
} else if (param == null) {
jsonArrayBuilder.addNull();
}
else {
} else {
throw ActiveMQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName());
}
}
@ -307,75 +270,59 @@ public final class JsonUtil {
if (desiredType == null || desiredType == Long.class || desiredType == Long.TYPE) {
return number.longValue();
}
else if (desiredType == Integer.class || desiredType == Integer.TYPE) {
} else if (desiredType == Integer.class || desiredType == Integer.TYPE) {
return number.intValue();
}
else if (desiredType == Double.class || desiredType == Double.TYPE) {
} else if (desiredType == Double.class || desiredType == Double.TYPE) {
return number.doubleValue();
}
else {
} else {
return number.longValue();
}
}
else if (jsonValue instanceof JsonString) {
} else if (jsonValue instanceof JsonString) {
return ((JsonString) jsonValue).getString();
}
else if (jsonValue instanceof JsonValue) {
} else if (jsonValue instanceof JsonValue) {
if (jsonValue == JsonValue.TRUE) {
return true;
}
else if (jsonValue == JsonValue.FALSE) {
} else if (jsonValue == JsonValue.FALSE) {
return false;
}
else {
} else {
return jsonValue.toString();
}
}
else if (jsonValue instanceof Number) {
Number jsonNumber = (Number)jsonValue;
} else if (jsonValue instanceof Number) {
Number jsonNumber = (Number) jsonValue;
if (desiredType == Integer.TYPE || desiredType == Integer.class) {
return jsonNumber.intValue();
}
else if (desiredType == Long.TYPE || desiredType == Long.class) {
return jsonNumber.intValue();
} else if (desiredType == Long.TYPE || desiredType == Long.class) {
return jsonNumber.longValue();
}
else if (desiredType == Double.TYPE || desiredType == Double.class) {
} else if (desiredType == Double.TYPE || desiredType == Double.class) {
return jsonNumber.doubleValue();
}
else if (desiredType == Short.TYPE || desiredType == Short.class) {
} else if (desiredType == Short.TYPE || desiredType == Short.class) {
return jsonNumber.shortValue();
}
else {
} else {
return jsonValue;
}
}
else if (jsonValue instanceof Object[]) {
} else if (jsonValue instanceof Object[]) {
Object[] array = (Object[]) jsonValue;
for (int i = 0; i < array.length; i++) {
array[i] = convertJsonValue(array[i], desiredType);
}
return array;
}
else {
} else {
return jsonValue;
}
}
private JsonUtil() {
}
private static class NullableJsonString implements JsonValue, JsonString {
private final String value;
private String escape;
NullableJsonString(String value) {
if (value == null || value.length() == 0) {
this.value = null;
}
else {
} else {
this.value = value;
}
}

View File

@ -53,7 +53,8 @@ public interface Message {
/**
* the actual time the message was expired.
* * * */
* * *
*/
SimpleString HDR_ACTUAL_EXPIRY_TIME = new SimpleString("_AMQ_ACTUAL_EXPIRY");
/**
@ -585,7 +586,6 @@ public interface Message {
*/
Map<String, Object> toMap();
/**
* @return Returns the message properties in Map form, useful when encoding to JSON
*/

View File

@ -16,6 +16,7 @@
*/
package org.apache.activemq.artemis.api.core;
import javax.json.JsonObject;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@ -26,8 +27,6 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.UUIDGenerator;
import javax.json.JsonObject;
/**
* A TransportConfiguration is used by a client to specify connections to a server and its backup if
* one exists.
@ -65,12 +64,7 @@ public class TransportConfiguration implements Serializable {
private static final byte TYPE_STRING = 3;
public JsonObject toJson() {
return JsonLoader.createObjectBuilder()
.add("name", name)
.add("factoryClassName", factoryClassName)
.add("params", JsonUtil.toJsonObject(params))
.add("extraProps", JsonUtil.toJsonObject(extraProps))
.build();
return JsonLoader.createObjectBuilder().add("name", name).add("factoryClassName", factoryClassName).add("params", JsonUtil.toJsonObject(params)).add("extraProps", JsonUtil.toJsonObject(extraProps)).build();
}
/**
@ -114,18 +108,20 @@ public class TransportConfiguration implements Serializable {
* Creates a TransportConfiguration with a specific name providing the class name of the {@link org.apache.activemq.artemis.spi.core.remoting.ConnectorFactory}
* and any parameters needed.
*
* @param className The class name of the ConnectorFactory
* @param params The parameters needed by the ConnectorFactory
* @param name The name of this TransportConfiguration
* @param extraProps The extra properties that specific to protocols
* @param className The class name of the ConnectorFactory
* @param params The parameters needed by the ConnectorFactory
* @param name The name of this TransportConfiguration
* @param extraProps The extra properties that specific to protocols
*/
public TransportConfiguration(final String className, final Map<String, Object> params, final String name, final Map<String, Object> extraProps) {
public TransportConfiguration(final String className,
final Map<String, Object> params,
final String name,
final Map<String, Object> extraProps) {
factoryClassName = className;
if (params == null || params.isEmpty()) {
this.params = TransportConfigurationUtil.getDefaults(className);
}
else {
} else {
this.params = params;
}
@ -134,7 +130,7 @@ public class TransportConfiguration implements Serializable {
}
public TransportConfiguration newTransportConfig(String newName) {
return new TransportConfiguration(factoryClassName, params, newName);
return new TransportConfiguration(factoryClassName, params, newName);
}
/**
@ -236,14 +232,11 @@ public class TransportConfiguration implements Serializable {
public boolean isEquivalent(TransportConfiguration otherConfig) {
if (this.getFactoryClassName().equals(otherConfig.getFactoryClassName())) {
return true;
}
else if (this.getFactoryClassName().contains("Netty") && otherConfig.getFactoryClassName().contains("Netty")) {
} else if (this.getFactoryClassName().contains("Netty") && otherConfig.getFactoryClassName().contains("Netty")) {
return true;
}
else if (this.getFactoryClassName().contains("InVM") && otherConfig.getFactoryClassName().contains("InVM")) {
} else if (this.getFactoryClassName().contains("InVM") && otherConfig.getFactoryClassName().contains("InVM")) {
return true;
}
else {
} else {
return false;
}
}
@ -271,8 +264,7 @@ public class TransportConfiguration implements Serializable {
String val;
if (key.equals(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME) || key.equals(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME)) {
val = "****";
}
else {
} else {
val = entry.getValue() == null ? "null" : entry.getValue().toString();
}
@ -307,20 +299,16 @@ public class TransportConfiguration implements Serializable {
if (val instanceof Boolean) {
buffer.writeByte(TransportConfiguration.TYPE_BOOLEAN);
buffer.writeBoolean((Boolean) val);
}
else if (val instanceof Integer) {
} else if (val instanceof Integer) {
buffer.writeByte(TransportConfiguration.TYPE_INT);
buffer.writeInt((Integer) val);
}
else if (val instanceof Long) {
} else if (val instanceof Long) {
buffer.writeByte(TransportConfiguration.TYPE_LONG);
buffer.writeLong((Long) val);
}
else if (val instanceof String) {
} else if (val instanceof String) {
buffer.writeByte(TransportConfiguration.TYPE_STRING);
buffer.writeString((String) val);
}
else {
} else {
throw ActiveMQClientMessageBundle.BUNDLE.invalidEncodeType(val);
}
}
@ -364,8 +352,7 @@ public class TransportConfiguration implements Serializable {
if (num > 0) {
params = new HashMap<>();
}
}
else {
} else {
params.clear();
}

View File

@ -150,12 +150,10 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
while (open) {
try {
receivingSocket.receive(packet);
}
// TODO: Do we need this?
catch (InterruptedIOException e) {
} catch (InterruptedIOException e) {
// TODO: Do we need this?
continue;
}
catch (IOException e) {
} catch (IOException e) {
if (open) {
ActiveMQClientLogger.LOGGER.warn(this + " getting exception when receiving broadcasting.", e);
}
@ -176,8 +174,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
public void openBroadcaster() throws Exception {
if (localBindPort != -1) {
broadcastingSocket = new DatagramSocket(localBindPort, localAddress);
}
else {
} else {
if (localAddress != null) {
for (int i = 0; i < 100; i++) {
int nextPort = RandomUtil.randomInterval(3000, 4000);
@ -185,8 +182,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
broadcastingSocket = new DatagramSocket(nextPort, localAddress);
ActiveMQClientLogger.LOGGER.broadcastGroupBindError(localAddress.toString() + ":" + nextPort);
break;
}
catch (Exception e) {
} catch (Exception e) {
ActiveMQClientLogger.LOGGER.broadcastGroupBindErrorRetry(localAddress.toString() + ":" + nextPort, e);
}
}
@ -205,14 +201,12 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
if (checkForLinux() || checkForSolaris() || checkForHp()) {
try {
receivingSocket = new MulticastSocket(new InetSocketAddress(groupAddress, groupPort));
}
catch (IOException e) {
} catch (IOException e) {
ActiveMQClientLogger.LOGGER.ioDiscoveryError(groupAddress.getHostAddress(), groupAddress instanceof Inet4Address ? "IPv4" : "IPv6");
receivingSocket = new MulticastSocket(groupPort);
}
}
else {
} else {
receivingSocket = new MulticastSocket(groupPort);
}
@ -267,8 +261,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
tmp = defaultValue;
}
return tmp;
}
catch (Throwable t) {
} catch (Throwable t) {
ActiveMQClientLogger.LOGGER.warn(t);
return defaultValue;
}
@ -279,8 +272,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
try {
return Integer.parseInt(value);
}
catch (Throwable t) {
} catch (Throwable t) {
ActiveMQClientLogger.LOGGER.warn(t.getMessage(), t);
return Integer.parseInt(defaultValue);
}
@ -308,8 +300,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
if (groupAddress == null) {
if (other.groupAddress != null)
return false;
}
else if (!groupAddress.equals(other.groupAddress))
} else if (!groupAddress.equals(other.groupAddress))
return false;
if (groupPort != other.groupPort)
return false;

View File

@ -144,7 +144,6 @@ public final class ActiveMQClient {
private static ScheduledExecutorService globalScheduledThreadPool;
static {
initializeGlobalThreadPoolProperties();
}
@ -153,7 +152,6 @@ public final class ActiveMQClient {
clearThreadPools(10, TimeUnit.SECONDS);
}
public static synchronized void clearThreadPools(long time, TimeUnit unit) {
if (injectedPools) {
@ -170,11 +168,9 @@ public final class ActiveMQClient {
globalThreadPool.shutdownNow();
ActiveMQClientLogger.LOGGER.warn("Couldn't finish the client globalThreadPool in less than 10 seconds, interrupting it now");
}
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
throw new ActiveMQInterruptedException(e);
}
finally {
} finally {
globalThreadPool = null;
}
}
@ -186,18 +182,19 @@ public final class ActiveMQClient {
globalScheduledThreadPool.shutdownNow();
ActiveMQClientLogger.LOGGER.warn("Couldn't finish the client scheduled in less than 10 seconds, interrupting it now");
}
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
throw new ActiveMQInterruptedException(e);
}
finally {
} finally {
globalScheduledThreadPool = null;
}
}
}
/** Warning: This method has to be called before any clients or servers is started on the JVM otherwise previous ServerLocator would be broken after this call. */
public static synchronized void injectPools(ExecutorService globalThreadPool, ScheduledExecutorService scheduledThreadPool) {
/**
* Warning: This method has to be called before any clients or servers is started on the JVM otherwise previous ServerLocator would be broken after this call.
*/
public static synchronized void injectPools(ExecutorService globalThreadPool,
ScheduledExecutorService scheduledThreadPool) {
if (globalThreadPool == null || scheduledThreadPool == null)
throw new IllegalArgumentException("thread pools must not be null");
@ -220,8 +217,7 @@ public final class ActiveMQClient {
if (globalThreadPoolSize == -1) {
globalThreadPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), factory);
}
else {
} else {
globalThreadPool = new ActiveMQThreadPoolExecutor(0, ActiveMQClient.globalThreadPoolSize, 60L, TimeUnit.SECONDS, factory);
}
}
@ -237,7 +233,7 @@ public final class ActiveMQClient {
}
});
globalScheduledThreadPool = new ScheduledThreadPoolExecutor(ActiveMQClient.globalScheduledThreadPoolSize, factory);
globalScheduledThreadPool = new ScheduledThreadPoolExecutor(ActiveMQClient.globalScheduledThreadPoolSize, factory);
}
return globalScheduledThreadPool;
}
@ -279,7 +275,8 @@ public final class ActiveMQClient {
*/
public static void setGlobalThreadPoolProperties(int globalThreadMaxPoolSize, int globalScheduledThreadPoolSize) {
if (globalThreadMaxPoolSize < 2 && globalThreadMaxPoolSize != -1) globalThreadMaxPoolSize = 2;
if (globalThreadMaxPoolSize < 2 && globalThreadMaxPoolSize != -1)
globalThreadMaxPoolSize = 2;
ActiveMQClient.globalScheduledThreadPoolSize = globalScheduledThreadPoolSize;
ActiveMQClient.globalThreadPoolSize = globalThreadMaxPoolSize;

View File

@ -20,8 +20,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
/**
* A ClientMessage represents a message sent and/or received by ActiveMQ Artemis.

View File

@ -92,6 +92,5 @@ public interface TopologyMember {
*/
boolean isMember(TransportConfiguration configuration);
String toURI();
}

View File

@ -42,8 +42,7 @@ public final class RoundRobinConnectionLoadBalancingPolicy implements Connection
pos = RandomUtil.randomInterval(0, max);
first = false;
}
else {
} else {
pos++;
if (pos >= max) {

View File

@ -31,6 +31,7 @@ import org.jgroups.ReceiverAdapter;
* will be disconnected.
*/
public class JChannelWrapper {
private static final Logger logger = Logger.getLogger(JChannelWrapper.class);
private boolean connected = false;
@ -46,7 +47,6 @@ public class JChannelWrapper {
this.channel = channel;
this.manager = manager;
if (logger.isTraceEnabled() && channel.getReceiver() != null) {
logger.trace(this + "The channel already had a receiver previously!!!! == " + channel.getReceiver(), new Exception("trace"));
}
@ -83,7 +83,8 @@ public class JChannelWrapper {
public synchronized void close(boolean closeWrappedChannel) {
refCount--;
if (logger.isTraceEnabled()) logger.trace(this + "::RefCount-- " + refCount + " on channel " + channelName, new Exception("Trace"));
if (logger.isTraceEnabled())
logger.trace(this + "::RefCount-- " + refCount + " on channel " + channelName, new Exception("Trace"));
if (refCount == 0) {
if (closeWrappedChannel) {
closeChannel();
@ -102,7 +103,8 @@ public class JChannelWrapper {
}
public void removeReceiver(JGroupsReceiver receiver) {
if (logger.isTraceEnabled()) logger.trace(this + "::removeReceiver: " + receiver + " on " + channelName, new Exception("Trace"));
if (logger.isTraceEnabled())
logger.trace(this + "::removeReceiver: " + receiver + " on " + channelName, new Exception("Trace"));
synchronized (receivers) {
receivers.remove(receiver);
}
@ -127,13 +129,15 @@ public class JChannelWrapper {
public void addReceiver(JGroupsReceiver jGroupsReceiver) {
synchronized (receivers) {
if (logger.isTraceEnabled()) logger.trace(this + "::Add Receiver: " + jGroupsReceiver + " on " + channelName);
if (logger.isTraceEnabled())
logger.trace(this + "::Add Receiver: " + jGroupsReceiver + " on " + channelName);
receivers.add(jGroupsReceiver);
}
}
public void send(org.jgroups.Message msg) throws Exception {
if (logger.isTraceEnabled()) logger.trace(this + "::Sending JGroups Message: Open=" + channel.isOpen() + " on channel " + channelName + " msg=" + msg);
if (logger.isTraceEnabled())
logger.trace(this + "::Sending JGroups Message: Open=" + channel.isOpen() + " on channel " + channelName + " msg=" + msg);
if (!manager.isLoopbackMessages()) {
msg.setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
}
@ -142,7 +146,8 @@ public class JChannelWrapper {
public JChannelWrapper addRef() {
this.refCount++;
if (logger.isTraceEnabled()) logger.trace(this + "::RefCount++ = " + refCount + " on channel " + channelName);
if (logger.isTraceEnabled())
logger.trace(this + "::RefCount++ = " + refCount + " on channel " + channelName);
return this;
}

View File

@ -36,7 +36,8 @@ public class JGroupsReceiver extends ReceiverAdapter {
@Override
public void receive(org.jgroups.Message msg) {
if (logger.isTraceEnabled()) logger.trace("sending message " + msg);
if (logger.isTraceEnabled())
logger.trace("sending message " + msg);
dequeue.add(msg.getBuffer());
}
@ -52,8 +53,7 @@ public class JGroupsReceiver extends ReceiverAdapter {
private void logBytes(String methodName, byte[] bytes) {
if (bytes != null) {
logger.trace(methodName + "::" + bytes.length + " bytes");
}
else {
} else {
logger.trace(methodName + ":: no bytes");
}
}

View File

@ -16,10 +16,10 @@
*/
package org.apache.activemq.artemis.api.core.management;
import org.apache.activemq.artemis.api.core.JsonUtil;
import javax.json.JsonObject;
import org.apache.activemq.artemis.api.core.JsonUtil;
// XXX no javadocs
public final class AddressSettingsInfo {
@ -67,19 +67,7 @@ public final class AddressSettingsInfo {
public static AddressSettingsInfo from(final String jsonString) {
JsonObject object = JsonUtil.readJsonObject(jsonString);
return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"),
object.getJsonNumber("maxSizeBytes").longValue(), object.getInt("pageSizeBytes"), object.getInt("pageCacheMaxSize"),
object.getInt("maxDeliveryAttempts"),
object.getJsonNumber("redeliveryDelay").longValue(),
object.getJsonNumber("redeliveryMultiplier").doubleValue(),
object.getJsonNumber("maxRedeliveryDelay").longValue(),
object.getString("DLA"), object.getString("expiryAddress"), object.getBoolean("lastValueQueue"),
object.getJsonNumber("redistributionDelay").longValue(), object.getBoolean("sendToDLAOnNoRoute"),
object.getJsonNumber("slowConsumerThreshold").longValue(),
object.getJsonNumber("slowConsumerCheckPeriod").longValue(),
object.getString("slowConsumerPolicy"), object.getBoolean("autoCreateJmsQueues"),
object.getBoolean("autoDeleteJmsQueues"), object.getBoolean("autoCreateJmsTopics"),
object.getBoolean("autoDeleteJmsTopics"));
return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"), object.getJsonNumber("maxSizeBytes").longValue(), object.getInt("pageSizeBytes"), object.getInt("pageCacheMaxSize"), object.getInt("maxDeliveryAttempts"), object.getJsonNumber("redeliveryDelay").longValue(), object.getJsonNumber("redeliveryMultiplier").doubleValue(), object.getJsonNumber("maxRedeliveryDelay").longValue(), object.getString("DLA"), object.getString("expiryAddress"), object.getBoolean("lastValueQueue"), object.getJsonNumber("redistributionDelay").longValue(), object.getBoolean("sendToDLAOnNoRoute"), object.getJsonNumber("slowConsumerThreshold").longValue(), object.getJsonNumber("slowConsumerCheckPeriod").longValue(), object.getString("slowConsumerPolicy"), object.getBoolean("autoCreateJmsQueues"), object.getBoolean("autoDeleteJmsQueues"), object.getBoolean("autoCreateJmsTopics"), object.getBoolean("autoDeleteJmsTopics"));
}
// Constructors --------------------------------------------------

View File

@ -30,5 +30,6 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Attribute {
String desc() default "";
}

Some files were not shown because too many files have changed in this diff Show More