You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/08/10 17:13:24 UTC
[25/53] [abbrv] [partial] activemq-artemis git commit: automatic
checkstyle change
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java
index 327e63a..5bbad37 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java
@@ -26,35 +26,28 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
-public class InVMServerLocatorSchema extends AbstractServerLocatorSchema
-{
+public class InVMServerLocatorSchema extends AbstractServerLocatorSchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.VM;
}
@Override
- protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
TransportConfiguration tc = InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory");
ServerLocator factory = ActiveMQClient.createServerLocatorWithoutHA(tc);
return URISchema.setData(uri, factory, query);
}
-
-
@Override
- protected URI internalNewURI(ServerLocator bean) throws Exception
- {
+ protected URI internalNewURI(ServerLocator bean) throws Exception {
return getUri(bean.getStaticTransportConfigurations());
}
- public static URI getUri(TransportConfiguration[] configurations) throws URISyntaxException
- {
+ public static URI getUri(TransportConfiguration[] configurations) throws URISyntaxException {
String host = "0";
- if (configurations != null && configurations.length > 0)
- {
+ if (configurations != null && configurations.length > 0) {
TransportConfiguration configuration = configurations[0];
Map<String, Object> params = configuration.getParams();
host = params.get("serverId") == null ? host : params.get("serverId").toString();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java
index f393ff6..b473ba4 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java
@@ -25,44 +25,43 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class InVMTransportConfigurationSchema extends AbstractTransportConfigurationSchema
-{
+public class InVMTransportConfigurationSchema extends AbstractTransportConfigurationSchema {
+
/* This is the same as org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED,
* but this Maven module can't see that class.
*/
public static final String CONNECTIONS_ALLOWED = "connectionsAllowed";
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.VM;
}
@Override
- protected List<TransportConfiguration> internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected List<TransportConfiguration> internalNewObject(URI uri,
+ Map<String, String> query,
+ String name) throws Exception {
List<TransportConfiguration> configurations = new ArrayList<>();
configurations.add(createTransportConfiguration(uri, query, name, getFactoryName()));
return configurations;
}
@Override
- protected URI internalNewURI(List<TransportConfiguration> bean) throws Exception
- {
+ protected URI internalNewURI(List<TransportConfiguration> bean) throws Exception {
return null;
}
- protected String getFactoryName()
- {
+ protected String getFactoryName() {
return "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory";
}
- public static TransportConfiguration createTransportConfiguration(URI uri, Map<String, String> query, String name, String factoryName)
- {
+ public static TransportConfiguration createTransportConfiguration(URI uri,
+ Map<String, String> query,
+ String name,
+ String factoryName) {
Map<String, Object> inVmTransportConfig = new HashMap<>();
inVmTransportConfig.put("serverId", uri.getHost());
- if (query.containsKey(CONNECTIONS_ALLOWED))
- {
+ if (query.containsKey(CONNECTIONS_ALLOWED)) {
inVmTransportConfig.put(CONNECTIONS_ALLOWED, query.get(CONNECTIONS_ALLOWED));
}
return new TransportConfiguration(factoryName, inVmTransportConfig, name);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsServerLocatorSchema.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsServerLocatorSchema.java
index 0d313b9..1749d9d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsServerLocatorSchema.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsServerLocatorSchema.java
@@ -28,63 +28,54 @@ import java.io.NotSerializableException;
import java.net.URI;
import java.util.Map;
-public class JGroupsServerLocatorSchema extends AbstractServerLocatorSchema
-{
+public class JGroupsServerLocatorSchema extends AbstractServerLocatorSchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.JGROUPS;
}
@Override
- protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
ConnectionOptions options = newConnectionOptions(uri, query);
DiscoveryGroupConfiguration dcConfig = getDiscoveryGroupConfiguration(uri, query, name);
- if (options.isHa())
- {
+ if (options.isHa()) {
return ActiveMQClient.createServerLocatorWithHA(dcConfig);
}
- else
- {
+ else {
return ActiveMQClient.createServerLocatorWithoutHA(dcConfig);
}
}
@Override
- protected URI internalNewURI(ServerLocator bean) throws Exception
- {
+ protected URI internalNewURI(ServerLocator bean) throws Exception {
DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration();
- BroadcastEndpointFactory endpoint = dgc.getBroadcastEndpointFactory();
+ BroadcastEndpointFactory endpoint = dgc.getBroadcastEndpointFactory();
String auth;
- if (endpoint instanceof JGroupsFileBroadcastEndpointFactory)
- {
+ if (endpoint instanceof JGroupsFileBroadcastEndpointFactory) {
auth = ((JGroupsFileBroadcastEndpointFactory) endpoint).getChannelName();
}
- else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory)
- {
+ else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) {
auth = ((JGroupsPropertiesBroadcastEndpointFactory) endpoint).getChannelName();
}
- else
- {
+ else {
throw new NotSerializableException(endpoint + "not serializable");
}
String query = getData(null, bean, dgc, endpoint);
dgc.setBroadcastEndpointFactory(endpoint);
- return new URI(SchemaConstants.JGROUPS, null, auth, -1, null, query, null);
+ return new URI(SchemaConstants.JGROUPS, null, auth, -1, null, query, null);
}
- public static DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(URI uri, Map<String, String> query, String name) throws Exception
- {
+ public static DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(URI uri,
+ Map<String, String> query,
+ String name) throws Exception {
BroadcastEndpointFactory endpointFactory;
- if (query.containsKey("file"))
- {
+ if (query.containsKey("file")) {
endpointFactory = new JGroupsFileBroadcastEndpointFactory().setChannelName(uri.getAuthority());
}
- else
- {
+ else {
endpointFactory = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName(uri.getAuthority());
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/ServerLocatorParser.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/ServerLocatorParser.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/ServerLocatorParser.java
index 6cb564b..2bf11a4 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/ServerLocatorParser.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/ServerLocatorParser.java
@@ -19,10 +19,9 @@ package org.apache.activemq.artemis.uri;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.utils.uri.URIFactory;
-public class ServerLocatorParser extends URIFactory<ServerLocator, String>
-{
- public ServerLocatorParser()
- {
+public class ServerLocatorParser extends URIFactory<ServerLocator, String> {
+
+ public ServerLocatorParser() {
registerSchema(new InVMServerLocatorSchema());
registerSchema(new TCPServerLocatorSchema());
registerSchema(new UDPServerLocatorSchema());
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPServerLocatorSchema.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPServerLocatorSchema.java
index c1e771d..c4701a7 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPServerLocatorSchema.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPServerLocatorSchema.java
@@ -28,95 +28,76 @@ import java.net.URI;
import java.util.List;
import java.util.Map;
-public class TCPServerLocatorSchema extends AbstractServerLocatorSchema
-{
+public class TCPServerLocatorSchema extends AbstractServerLocatorSchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.TCP;
}
-
@Override
- protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
ConnectionOptions options = newConnectionOptions(uri, query);
- List<TransportConfiguration> configurations =
- TCPTransportConfigurationSchema.getTransportConfigurations(uri, query, TransportConstants.ALLOWABLE_CONNECTOR_KEYS, name, NettyConnectorFactory.class.getName());
+ List<TransportConfiguration> configurations = TCPTransportConfigurationSchema.getTransportConfigurations(uri, query, TransportConstants.ALLOWABLE_CONNECTOR_KEYS, name, NettyConnectorFactory.class.getName());
TransportConfiguration[] tcs = new TransportConfiguration[configurations.size()];
configurations.toArray(tcs);
- if (options.isHa())
- {
+ if (options.isHa()) {
return ActiveMQClient.createServerLocatorWithHA(tcs);
}
- else
- {
+ else {
return ActiveMQClient.createServerLocatorWithoutHA(tcs);
}
}
@Override
- protected URI internalNewURI(ServerLocator bean) throws Exception
- {
+ protected URI internalNewURI(ServerLocator bean) throws Exception {
String query = URISchema.getData(null, bean);
TransportConfiguration[] staticConnectors = bean.getStaticTransportConfigurations();
return getURI(query, staticConnectors);
}
- public static URI getURI(String query, TransportConfiguration[] staticConnectors) throws Exception
- {
- if (staticConnectors == null || staticConnectors.length < 1)
- {
+ public static URI getURI(String query, TransportConfiguration[] staticConnectors) throws Exception {
+ if (staticConnectors == null || staticConnectors.length < 1) {
throw new Exception();
}
StringBuilder fragment = new StringBuilder();
- for (int i = 1; i < staticConnectors.length; i++)
- {
+ for (int i = 1; i < staticConnectors.length; i++) {
TransportConfiguration connector = staticConnectors[i];
Map<String, Object> params = connector.getParams();
URI extraUri = new URI(SchemaConstants.TCP, null, getHost(params), getPort(params), null, createQuery(params, null), null);
- if (i > 1)
- {
+ if (i > 1) {
fragment.append(",");
}
fragment.append(extraUri.toASCIIString());
}
Map<String, Object> params = staticConnectors[0].getParams();
- return new URI(SchemaConstants.TCP, null, getHost(params), getPort(params), null, createQuery(params, query), fragment.toString());
+ return new URI(SchemaConstants.TCP, null, getHost(params), getPort(params), null, createQuery(params, query), fragment.toString());
}
- private static int getPort(Map<String, Object> params)
- {
+ private static int getPort(Map<String, Object> params) {
Object port = params.get("port");
- if (port instanceof String)
- {
+ if (port instanceof String) {
return Integer.valueOf((String) port);
}
return port != null ? (int) port : 61616;
}
- private static String getHost(Map<String, Object> params)
- {
+ private static String getHost(Map<String, Object> params) {
return params.get("host") != null ? (String) params.get("host") : "localhost";
}
- private static String createQuery(Map<String, Object> params, String query)
- {
+ private static String createQuery(Map<String, Object> params, String query) {
StringBuilder cb;
- if (query == null)
- {
+ if (query == null) {
cb = new StringBuilder();
}
- else
- {
+ else {
cb = new StringBuilder(query);
}
- for (String param : params.keySet())
- {
- if (cb.length() > 0)
- {
+ for (String param : params.keySet()) {
+ if (cb.length() > 0) {
cb.append("&");
}
cb.append(param).append("=").append(params.get(param));
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPTransportConfigurationSchema.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPTransportConfigurationSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPTransportConfigurationSchema.java
index ecb22d6..10fda78 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPTransportConfigurationSchema.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/TCPTransportConfigurationSchema.java
@@ -29,67 +29,60 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactor
import org.apache.activemq.artemis.utils.uri.SchemaConstants;
import org.apache.activemq.artemis.utils.uri.URISchema;
-public class TCPTransportConfigurationSchema extends AbstractTransportConfigurationSchema
-{
+public class TCPTransportConfigurationSchema extends AbstractTransportConfigurationSchema {
+
private final Set<String> allowableProperties;
- public TCPTransportConfigurationSchema(Set<String> allowableProperties)
- {
+ public TCPTransportConfigurationSchema(Set<String> allowableProperties) {
this.allowableProperties = allowableProperties;
}
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.TCP;
}
@Override
- protected List<TransportConfiguration> internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected List<TransportConfiguration> internalNewObject(URI uri,
+ Map<String, String> query,
+ String name) throws Exception {
return getTransportConfigurations(uri, query, allowableProperties, name, getFactoryName(uri));
}
@Override
- protected URI internalNewURI(List<TransportConfiguration> bean) throws Exception
- {
+ protected URI internalNewURI(List<TransportConfiguration> bean) throws Exception {
return null;
}
- public static List<TransportConfiguration> getTransportConfigurations(URI uri, Map<String, String> query, Set<String> allowableProperties, String name, String factoryName) throws URISyntaxException
- {
+ public static List<TransportConfiguration> getTransportConfigurations(URI uri,
+ Map<String, String> query,
+ Set<String> allowableProperties,
+ String name,
+ String factoryName) throws URISyntaxException {
HashMap<String, Object> props = new HashMap<>();
URISchema.setData(uri, props, allowableProperties, query);
List<TransportConfiguration> transportConfigurations = new ArrayList<>();
- transportConfigurations.add(new TransportConfiguration(factoryName,
- props,
- name));
+ transportConfigurations.add(new TransportConfiguration(factoryName, props, name));
String connectors = uri.getFragment();
- if (connectors != null && !connectors.trim().isEmpty())
- {
+ if (connectors != null && !connectors.trim().isEmpty()) {
String[] split = connectors.split(",");
- for (String s : split)
- {
+ for (String s : split) {
URI extraUri = new URI(s);
HashMap<String, Object> newProps = new HashMap<>();
URISchema.setData(extraUri, newProps, allowableProperties, query);
URISchema.setData(extraUri, newProps, allowableProperties, URISchema.parseQuery(extraUri.getQuery(), null));
- transportConfigurations.add(new TransportConfiguration(factoryName,
- newProps,
- name + ":" + extraUri.toString()));
+ transportConfigurations.add(new TransportConfiguration(factoryName, newProps, name + ":" + extraUri.toString()));
}
}
return transportConfigurations;
}
- protected String getFactoryName(URI uri)
- {
+ protected String getFactoryName(URI uri) {
//here for backwards compatibility
- if (uri.getPath() != null && uri.getPath().contains("hornetq"))
- {
+ if (uri.getPath() != null && uri.getPath().contains("hornetq")) {
return "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory";
}
return NettyConnectorFactory.class.getName();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/UDPServerLocatorSchema.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/UDPServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/UDPServerLocatorSchema.java
index 96cd818..b3a85fc 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/UDPServerLocatorSchema.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/UDPServerLocatorSchema.java
@@ -28,58 +28,53 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-public class UDPServerLocatorSchema extends AbstractServerLocatorSchema
-{
+public class UDPServerLocatorSchema extends AbstractServerLocatorSchema {
+
protected static List<String> IGNORED = new ArrayList<>();
- static
- {
+
+ static {
IGNORED.add("localBindAddress");
IGNORED.add("localBindPort");
}
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.UDP;
}
@Override
- protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
ConnectionOptions options = newConnectionOptions(uri, query);
DiscoveryGroupConfiguration dgc = getDiscoveryGroupConfiguration(uri, query, getHost(uri), getPort(uri), name);
- if (options.isHa())
- {
+ if (options.isHa()) {
return ActiveMQClient.createServerLocatorWithHA(dgc);
}
- else
- {
+ else {
return ActiveMQClient.createServerLocatorWithoutHA(dgc);
}
}
@Override
- protected URI internalNewURI(ServerLocator bean) throws Exception
- {
+ protected URI internalNewURI(ServerLocator bean) throws Exception {
DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration();
UDPBroadcastEndpointFactory endpoint = (UDPBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory();
dgc.setBroadcastEndpointFactory(endpoint);
String query = URISchema.getData(IGNORED, bean, dgc, endpoint);
- return new URI(SchemaConstants.UDP, null, endpoint.getGroupAddress(), endpoint.getGroupPort(), null, query, null);
+ return new URI(SchemaConstants.UDP, null, endpoint.getGroupAddress(), endpoint.getGroupPort(), null, query, null);
}
- public static DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(URI uri, Map<String, String> query, String host, int port, String name) throws Exception
- {
- UDPBroadcastEndpointFactory endpointFactoryConfiguration = new UDPBroadcastEndpointFactory()
- .setGroupAddress(host)
- .setGroupPort(port);
+ public static DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(URI uri,
+ Map<String, String> query,
+ String host,
+ int port,
+ String name) throws Exception {
+ UDPBroadcastEndpointFactory endpointFactoryConfiguration = new UDPBroadcastEndpointFactory().setGroupAddress(host).setGroupPort(port);
URISchema.setData(uri, endpointFactoryConfiguration, query);
- DiscoveryGroupConfiguration dgc = URISchema.setData(uri, new DiscoveryGroupConfiguration(), query)
- .setName(name)
- .setBroadcastEndpointFactory(endpointFactoryConfiguration);
+ DiscoveryGroupConfiguration dgc = URISchema.setData(uri, new DiscoveryGroupConfiguration(), query).setName(name).setBroadcastEndpointFactory(endpointFactoryConfiguration);
URISchema.setData(uri, dgc, query);
return dgc;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java
index 7854997..3cbaac9 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java
@@ -24,8 +24,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
/**
* Used to send large messages
*/
-public class ActiveMQBufferInputStream extends InputStream
-{
+public class ActiveMQBufferInputStream extends InputStream {
/* (non-Javadoc)
* @see java.io.InputStream#read()
@@ -41,34 +40,27 @@ public class ActiveMQBufferInputStream extends InputStream
// Public --------------------------------------------------------
- public ActiveMQBufferInputStream(final ActiveMQBuffer paramByteBuffer)
- {
+ public ActiveMQBufferInputStream(final ActiveMQBuffer paramByteBuffer) {
bb = paramByteBuffer;
}
@Override
- public int read() throws IOException
- {
- if (bb == null)
- {
+ public int read() throws IOException {
+ if (bb == null) {
throw new IOException("read on a closed InputStream");
}
- if (remainingBytes() == 0)
- {
+ if (remainingBytes() == 0) {
return -1;
}
- else
- {
+ else {
return bb.readByte() & 0xFF;
}
}
@Override
- public int read(final byte[] byteArray) throws IOException
- {
- if (bb == null)
- {
+ public int read(final byte[] byteArray) throws IOException {
+ if (bb == null) {
throw new IOException("read on a closed InputStream");
}
@@ -76,30 +68,24 @@ public class ActiveMQBufferInputStream extends InputStream
}
@Override
- public int read(final byte[] byteArray, final int off, final int len) throws IOException
- {
- if (bb == null)
- {
+ public int read(final byte[] byteArray, final int off, final int len) throws IOException {
+ if (bb == null) {
throw new IOException("read on a closed InputStream");
}
- if (byteArray == null)
- {
+ if (byteArray == null) {
throw new NullPointerException();
}
- if (off < 0 || off > byteArray.length || len < 0 || off + len > byteArray.length || off + len < 0)
- {
+ if (off < 0 || off > byteArray.length || len < 0 || off + len > byteArray.length || off + len < 0) {
throw new IndexOutOfBoundsException();
}
- if (len == 0)
- {
+ if (len == 0) {
return 0;
}
int size = Math.min(remainingBytes(), len);
- if (size == 0)
- {
+ if (size == 0) {
return -1;
}
@@ -108,15 +94,12 @@ public class ActiveMQBufferInputStream extends InputStream
}
@Override
- public long skip(final long len) throws IOException
- {
- if (bb == null)
- {
+ public long skip(final long len) throws IOException {
+ if (bb == null) {
throw new IOException("skip on a closed InputStream");
}
- if (len <= 0L)
- {
+ if (len <= 0L) {
return 0L;
}
@@ -128,10 +111,8 @@ public class ActiveMQBufferInputStream extends InputStream
}
@Override
- public int available() throws IOException
- {
- if (bb == null)
- {
+ public int available() throws IOException {
+ if (bb == null) {
throw new IOException("available on a closed InputStream");
}
@@ -139,25 +120,21 @@ public class ActiveMQBufferInputStream extends InputStream
}
@Override
- public void close() throws IOException
- {
+ public void close() throws IOException {
bb = null;
}
@Override
- public synchronized void mark(final int paramInt)
- {
+ public synchronized void mark(final int paramInt) {
}
@Override
- public synchronized void reset() throws IOException
- {
+ public synchronized void reset() throws IOException {
throw new IOException("mark/reset not supported");
}
@Override
- public boolean markSupported()
- {
+ public boolean markSupported() {
return false;
}
@@ -170,12 +147,10 @@ public class ActiveMQBufferInputStream extends InputStream
/**
* @return
*/
- private int remainingBytes()
- {
+ private int remainingBytes() {
return bb.writerIndex() - bb.readerIndex();
}
-
// Inner classes -------------------------------------------------
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java
index 603379b..6659424 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java
@@ -22,72 +22,62 @@ import org.apache.activemq.artemis.api.core.SimpleString;
/**
* Helper methods to read and write from ActiveMQBuffer.
*/
-public class BufferHelper
-{
-
- /** Size of a String as if it was a Nullable Simple String */
- public static int sizeOfNullableSimpleString(String str)
- {
- if (str == null)
- {
+public class BufferHelper {
+
+ /**
+ * Size of a String as if it was a Nullable Simple String
+ */
+ public static int sizeOfNullableSimpleString(String str) {
+ if (str == null) {
return DataConstants.SIZE_BOOLEAN;
}
- else
- {
+ else {
return DataConstants.SIZE_BOOLEAN + sizeOfSimpleString(str);
}
}
- /** Size of a String as it if was a Simple String*/
- public static int sizeOfSimpleString(String str)
- {
+ /**
+ * Size of a String as it if was a Simple String
+ */
+ public static int sizeOfSimpleString(String str) {
return DataConstants.SIZE_INT + str.length() * 2;
}
- public static void writeAsNullableSimpleString(ActiveMQBuffer buffer, String str)
- {
+ public static void writeAsNullableSimpleString(ActiveMQBuffer buffer, String str) {
buffer.writeNullableSimpleString(SimpleString.toSimpleString(str));
}
- public static String readNullableSimpleStringAsString(ActiveMQBuffer buffer)
- {
+ public static String readNullableSimpleStringAsString(ActiveMQBuffer buffer) {
SimpleString str = buffer.readNullableSimpleString();
return str != null ? str.toString() : null;
}
- public static void writeAsSimpleString(ActiveMQBuffer buffer, String str)
- {
+ public static void writeAsSimpleString(ActiveMQBuffer buffer, String str) {
buffer.writeSimpleString(new SimpleString(str));
}
/**
* @param buffer
*/
- public static void writeNullableBoolean(ActiveMQBuffer buffer, Boolean value)
- {
+ public static void writeNullableBoolean(ActiveMQBuffer buffer, Boolean value) {
buffer.writeBoolean(value != null);
- if (value != null)
- {
+ if (value != null) {
buffer.writeBoolean(value.booleanValue());
}
}
- public static int sizeOfNullableBoolean(Boolean value)
- {
+ public static int sizeOfNullableBoolean(Boolean value) {
return DataConstants.SIZE_BOOLEAN + (value != null ? DataConstants.SIZE_BOOLEAN : 0);
}
- public static Boolean readNullableBoolean(ActiveMQBuffer buffer)
- {
+ public static Boolean readNullableBoolean(ActiveMQBuffer buffer) {
boolean isNotNull = buffer.readBoolean();
- if (isNotNull)
- {
+ if (isNotNull) {
return buffer.readBoolean();
}
- else
- {
+ else {
return null;
}
}
@@ -95,12 +85,10 @@ public class BufferHelper
/**
* @param buffer
*/
- public static void writeNullableLong(ActiveMQBuffer buffer, Long value)
- {
+ public static void writeNullableLong(ActiveMQBuffer buffer, Long value) {
buffer.writeBoolean(value != null);
- if (value != null)
- {
+ if (value != null) {
buffer.writeLong(value.longValue());
}
}
@@ -108,37 +96,29 @@ public class BufferHelper
/**
* @param buffer
*/
- public static void writeNullableDouble(ActiveMQBuffer buffer, Double value)
- {
+ public static void writeNullableDouble(ActiveMQBuffer buffer, Double value) {
buffer.writeBoolean(value != null);
- if (value != null)
- {
+ if (value != null) {
buffer.writeDouble(value.doubleValue());
}
}
- public static int sizeOfNullableLong(Long value)
- {
+ public static int sizeOfNullableLong(Long value) {
return DataConstants.SIZE_BOOLEAN + (value != null ? DataConstants.SIZE_LONG : 0);
}
- public static int sizeOfNullableDouble(Double value)
- {
+ public static int sizeOfNullableDouble(Double value) {
return DataConstants.SIZE_BOOLEAN + (value != null ? DataConstants.SIZE_DOUBLE : 0);
}
-
- public static Long readNullableLong(ActiveMQBuffer buffer)
- {
+ public static Long readNullableLong(ActiveMQBuffer buffer) {
boolean isNotNull = buffer.readBoolean();
- if (isNotNull)
- {
+ if (isNotNull) {
return buffer.readLong();
}
- else
- {
+ else {
return null;
}
}
@@ -146,45 +126,36 @@ public class BufferHelper
/**
* @param buffer
*/
- public static void writeNullableInteger(ActiveMQBuffer buffer, Integer value)
- {
+ public static void writeNullableInteger(ActiveMQBuffer buffer, Integer value) {
buffer.writeBoolean(value != null);
- if (value != null)
- {
+ if (value != null) {
buffer.writeInt(value.intValue());
}
}
- public static int sizeOfNullableInteger(Integer value)
- {
+ public static int sizeOfNullableInteger(Integer value) {
return DataConstants.SIZE_BOOLEAN + (value != null ? DataConstants.SIZE_INT : 0);
}
- public static Integer readNullableInteger(ActiveMQBuffer buffer)
- {
+ public static Integer readNullableInteger(ActiveMQBuffer buffer) {
boolean isNotNull = buffer.readBoolean();
- if (isNotNull)
- {
+ if (isNotNull) {
return buffer.readInt();
}
- else
- {
+ else {
return null;
}
}
- public static Double readNullableDouble(ActiveMQBuffer buffer)
- {
+ public static Double readNullableDouble(ActiveMQBuffer buffer) {
boolean isNotNull = buffer.readBoolean();
- if (isNotNull)
- {
+ if (isNotNull) {
return buffer.readDouble();
}
- else
- {
+ else {
return null;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
index 1743ba6..76326b6 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
@@ -24,170 +24,133 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+public class ConfigurationHelper {
-public class ConfigurationHelper
-{
- public static String getStringProperty(final String propName, final String def, final Map<String, Object> props)
- {
- if (props == null)
- {
+ public static String getStringProperty(final String propName, final String def, final Map<String, Object> props) {
+ if (props == null) {
return def;
}
Object prop = props.get(propName);
- if (prop == null)
- {
+ if (prop == null) {
return def;
}
- else
- {
- if (prop instanceof String == false)
- {
+ else {
+ if (prop instanceof String == false) {
return prop.toString();
}
- else
- {
- return (String)prop;
+ else {
+ return (String) prop;
}
}
}
- public static int getIntProperty(final String propName, final int def, final Map<String, Object> props)
- {
- if (props == null)
- {
+ public static int getIntProperty(final String propName, final int def, final Map<String, Object> props) {
+ if (props == null) {
return def;
}
Object prop = props.get(propName);
- if (prop == null)
- {
+ if (prop == null) {
return def;
}
- else
- {
+ else {
// The resource adapter will aways send Strings, hence the conversion here
- if (prop instanceof String)
- {
- return Integer.valueOf((String)prop);
+ if (prop instanceof String) {
+ return Integer.valueOf((String) prop);
}
- else if (prop instanceof Number == false)
- {
+ else if (prop instanceof Number == false) {
ActiveMQClientLogger.LOGGER.propertyNotInteger(propName, prop.getClass().getName());
return def;
}
- else
- {
- return ((Number)prop).intValue();
+ else {
+ return ((Number) prop).intValue();
}
}
}
- public static long getLongProperty(final String propName, final long def, final Map<String, Object> props)
- {
- if (props == null)
- {
+ public static long getLongProperty(final String propName, final long def, final Map<String, Object> props) {
+ if (props == null) {
return def;
}
Object prop = props.get(propName);
- if (prop == null)
- {
+ if (prop == null) {
return def;
}
- else
- {
+ else {
// The resource adapter will aways send Strings, hence the conversion here
- if (prop instanceof String)
- {
- return Long.valueOf((String)prop);
+ if (prop instanceof String) {
+ return Long.valueOf((String) prop);
}
- else if (prop instanceof Number == false)
- {
+ else if (prop instanceof Number == false) {
ActiveMQClientLogger.LOGGER.propertyNotLong(propName, prop.getClass().getName());
return def;
}
- else
- {
- return ((Number)prop).longValue();
+ else {
+ return ((Number) prop).longValue();
}
}
}
- public static boolean getBooleanProperty(final String propName, final boolean def, final Map<String, Object> props)
- {
- if (props == null)
- {
+ public static boolean getBooleanProperty(final String propName, final boolean def, final Map<String, Object> props) {
+ if (props == null) {
return def;
}
Object prop = props.get(propName);
- if (prop == null)
- {
+ if (prop == null) {
return def;
}
- else
- {
+ else {
// The resource adapter will aways send Strings, hence the conversion here
- if (prop instanceof String)
- {
- return Boolean.valueOf((String)prop);
+ if (prop instanceof String) {
+ return Boolean.valueOf((String) prop);
}
- else if (prop instanceof Boolean == false)
- {
+ else if (prop instanceof Boolean == false) {
ActiveMQClientLogger.LOGGER.propertyNotBoolean(propName, prop.getClass().getName());
return def;
}
- else
- {
- return (Boolean)prop;
+ else {
+ return (Boolean) prop;
}
}
}
- public static Set<String> checkKeys(final Set<String> allowableKeys, final Set<String> keys)
- {
+ public static Set<String> checkKeys(final Set<String> allowableKeys, final Set<String> keys) {
Set<String> invalid = new HashSet<String>();
- for (String key : keys)
- {
- if (!allowableKeys.contains(key))
- {
+ for (String key : keys) {
+ if (!allowableKeys.contains(key)) {
invalid.add(key);
}
}
return invalid;
}
- public static Set<String> checkKeysExist(final Set<String> requiredKeys, final Set<String> keys)
- {
+ public static Set<String> checkKeysExist(final Set<String> requiredKeys, final Set<String> keys) {
Set<String> invalid = new HashSet<String>(requiredKeys);
- for (String key : keys)
- {
- if (requiredKeys.contains(key))
- {
+ for (String key : keys) {
+ if (requiredKeys.contains(key)) {
invalid.remove(key);
}
}
return invalid;
}
- public static String stringSetToCommaListString(final Set<String> invalid)
- {
+ public static String stringSetToCommaListString(final Set<String> invalid) {
StringBuilder sb = new StringBuilder();
int count = 0;
- for (String key : invalid)
- {
+ for (String key : invalid) {
sb.append(key);
- if (count != invalid.size() - 1)
- {
+ if (count != invalid.size() - 1) {
sb.append(", ");
}
count++;
@@ -196,51 +159,44 @@ public class ConfigurationHelper
}
public static String getPasswordProperty(final String propName,
- final String def, final Map<String, Object> props,
- String defaultMaskPassword, String defaultPasswordCodec)
- {
- if (props == null)
- {
+ final String def,
+ final Map<String, Object> props,
+ String defaultMaskPassword,
+ String defaultPasswordCodec) {
+ if (props == null) {
return def;
}
Object prop = props.get(propName);
- if (prop == null)
- {
+ if (prop == null) {
return def;
}
String value = prop.toString();
Boolean useMask = (Boolean) props.get(defaultMaskPassword);
- if (useMask == null || (!useMask))
- {
+ if (useMask == null || (!useMask)) {
return value;
}
final String classImpl = (String) props.get(defaultPasswordCodec);
- if (classImpl == null)
- {
+ if (classImpl == null) {
throw ActiveMQClientMessageBundle.BUNDLE.noCodec();
}
SensitiveDataCodec<String> codec = null;
- try
- {
+ try {
codec = PasswordMaskingUtil.getCodec(classImpl);
}
- catch (ActiveMQException e1)
- {
+ catch (ActiveMQException e1) {
throw ActiveMQClientMessageBundle.BUNDLE.failedToGetDecoder(e1);
}
- try
- {
+ try {
return codec.decode(value);
}
- catch (Exception e)
- {
+ catch (Exception e) {
throw ActiveMQClientMessageBundle.BUNDLE.errordecodingPassword(e);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfirmationWindowWarning.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfirmationWindowWarning.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfirmationWindowWarning.java
index f1f12a5..c318858 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfirmationWindowWarning.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfirmationWindowWarning.java
@@ -21,16 +21,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
* TODO: get rid of this
*/
-public final class ConfirmationWindowWarning
-{
+public final class ConfirmationWindowWarning {
+
public final boolean disabled;
public final AtomicBoolean warningIssued;
/**
*
*/
- public ConfirmationWindowWarning(boolean disabled)
- {
+ public ConfirmationWindowWarning(boolean disabled) {
this.disabled = disabled;
warningIssued = new AtomicBoolean(false);
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java
index 03c8e94..028720f 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java
@@ -26,8 +26,8 @@ import java.util.zip.Deflater;
* The reader takes an inputstream and compress it.
* Not for concurrent use.
*/
-public class DeflaterReader extends InputStream
-{
+public class DeflaterReader extends InputStream {
+
private final Deflater deflater = new Deflater();
private boolean isFinished = false;
private boolean compressDone = false;
@@ -36,23 +36,19 @@ public class DeflaterReader extends InputStream
private final AtomicLong bytesRead;
- public DeflaterReader(final InputStream inData, final AtomicLong bytesRead)
- {
+ public DeflaterReader(final InputStream inData, final AtomicLong bytesRead) {
input = inData;
this.bytesRead = bytesRead;
}
@Override
- public int read() throws IOException
- {
+ public int read() throws IOException {
byte[] buffer = new byte[1];
int n = read(buffer, 0, 1);
- if (n == 1)
- {
+ if (n == 1) {
return buffer[0] & 0xFF;
}
- if (n == -1 || n == 0)
- {
+ if (n == -1 || n == 0) {
return -1;
}
throw new IOException("Error reading data, invalid n: " + n);
@@ -67,10 +63,8 @@ public class DeflaterReader extends InputStream
* @throws IOException
*/
@Override
- public int read(final byte[] buffer, int offset, int len) throws IOException
- {
- if (compressDone)
- {
+ public int read(final byte[] buffer, int offset, int len) throws IOException {
+ if (compressDone) {
return -1;
}
@@ -80,44 +74,35 @@ public class DeflaterReader extends InputStream
int n = 0;
int read = 0;
- while (len > 0)
- {
+ while (len > 0) {
n = deflater.deflate(buffer, offset, len);
- if (n == 0)
- {
- if (isFinished)
- {
+ if (n == 0) {
+ if (isFinished) {
deflater.end();
compressDone = true;
break;
}
- else if (deflater.needsInput())
- {
+ else if (deflater.needsInput()) {
// read some data from inputstream
int m = input.read(readBuffer);
- if (m == -1)
- {
+ if (m == -1) {
deflater.finish();
isFinished = true;
}
- else
- {
- if (bytesRead != null)
- {
+ else {
+ if (bytesRead != null) {
bytesRead.addAndGet(m);
}
deflater.setInput(readBuffer, 0, m);
}
}
- else
- {
+ else {
deflater.finish();
isFinished = true;
}
}
- else
- {
+ else {
read += n;
offset += n;
len -= n;
@@ -126,14 +111,12 @@ public class DeflaterReader extends InputStream
return read;
}
- public void closeStream() throws IOException
- {
+ public void closeStream() throws IOException {
super.close();
input.close();
}
- public long getTotalSize()
- {
+ public long getTotalSize() {
return bytesRead.get();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ExecutorFactory.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ExecutorFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ExecutorFactory.java
index 94a87dd..dd0209b 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ExecutorFactory.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ExecutorFactory.java
@@ -18,7 +18,7 @@ package org.apache.activemq.artemis.utils;
import java.util.concurrent.Executor;
-public interface ExecutorFactory
-{
+public interface ExecutorFactory {
+
Executor getExecutor();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java
index 6e1b9f8..b391161 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java
@@ -19,42 +19,35 @@ package org.apache.activemq.artemis.utils;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-public class FutureLatch implements Runnable
-{
+public class FutureLatch implements Runnable {
+
private final CountDownLatch latch;
- public FutureLatch()
- {
+ public FutureLatch() {
super();
latch = new CountDownLatch(1);
}
- public FutureLatch(int latches)
- {
+ public FutureLatch(int latches) {
super();
- latch = new CountDownLatch(latches);
+ latch = new CountDownLatch(latches);
}
- public boolean await(final long timeout)
- {
- try
- {
+ public boolean await(final long timeout) {
+ try {
return latch.await(timeout, TimeUnit.MILLISECONDS);
}
- catch (InterruptedException e)
- {
+ catch (InterruptedException e) {
return false;
}
}
- public void run()
- {
+ public void run() {
latch.countDown();
}
@Override
- public String toString()
- {
+ public String toString() {
return FutureLatch.class.getSimpleName() + "(latch=" + latch + ")";
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/IDGenerator.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/IDGenerator.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/IDGenerator.java
index 13577a7..4cbc2ff 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/IDGenerator.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/IDGenerator.java
@@ -26,8 +26,8 @@ package org.apache.activemq.artemis.utils;
* a record indicates a server crash. During server restart, if the journals lack a
* {@literal next-recordID} record, we use the last recorded ID plus {@code MAX_INT}.
*/
-public interface IDGenerator
-{
+public interface IDGenerator {
+
long generateID();
long getCurrentID();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java
index 363391a..3bc34b6 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java
@@ -26,8 +26,8 @@ import java.util.zip.Inflater;
* It takes a compressed input stream and decompressed it as it is being read.
* Not for concurrent use.
*/
-public class InflaterReader extends InputStream
-{
+public class InflaterReader extends InputStream {
+
private Inflater inflater = new Inflater();
private InputStream input;
@@ -36,33 +36,26 @@ public class InflaterReader extends InputStream
private int pointer;
private int length;
- public InflaterReader(InputStream input)
- {
+ public InflaterReader(InputStream input) {
this(input, 1024);
}
- public InflaterReader(InputStream input, int bufferSize)
- {
+ public InflaterReader(InputStream input, int bufferSize) {
this.input = input;
this.readBuffer = new byte[bufferSize];
this.pointer = -1;
}
- public int read() throws IOException
- {
- if (pointer == -1)
- {
- try
- {
+ public int read() throws IOException {
+ if (pointer == -1) {
+ try {
length = doRead(readBuffer, 0, readBuffer.length);
- if (length == 0)
- {
+ if (length == 0) {
return -1;
}
pointer = 0;
}
- catch (DataFormatException e)
- {
+ catch (DataFormatException e) {
IOException e2 = new IOException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -71,8 +64,7 @@ public class InflaterReader extends InputStream
int value = readBuffer[pointer] & 0xFF;
pointer++;
- if (pointer == length)
- {
+ if (pointer == length) {
pointer = -1;
}
@@ -84,52 +76,42 @@ public class InflaterReader extends InputStream
* decompressed output.
* returns number of bytes actually got
*/
- private int doRead(byte[] buf, int offset, int len) throws DataFormatException, IOException
- {
+ private int doRead(byte[] buf, int offset, int len) throws DataFormatException, IOException {
int read = 0;
int n = 0;
byte[] inputBuffer = new byte[len];
- while (len > 0)
- {
+ while (len > 0) {
n = inflater.inflate(buf, offset, len);
- if (n == 0)
- {
- if (inflater.finished())
- {
+ if (n == 0) {
+ if (inflater.finished()) {
break;
}
- else if (inflater.needsInput())
- {
+ else if (inflater.needsInput()) {
//feeding
int m = input.read(inputBuffer);
- if (m == -1)
- {
+ if (m == -1) {
//it shouldn't be here, throw exception
throw new DataFormatException("Input is over while inflater still expecting data");
}
- else
- {
+ else {
//feed the data in
inflater.setInput(inputBuffer, 0, m);
n = inflater.inflate(buf, offset, len);
- if (n > 0)
- {
+ if (n > 0) {
read += n;
offset += n;
len -= n;
}
}
}
- else
- {
+ else {
//it shouldn't be here, throw
throw new DataFormatException("Inflater is neither finished nor needing input.");
}
}
- else
- {
+ else {
read += n;
offset += n;
len -= n;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java
index ddb34a1..767ef6c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java
@@ -30,8 +30,8 @@ import java.util.zip.Inflater;
* <p>
* Not for concurrent use.
*/
-public class InflaterWriter extends OutputStream
-{
+public class InflaterWriter extends OutputStream {
+
private final Inflater inflater = new Inflater();
private final OutputStream output;
@@ -42,8 +42,7 @@ public class InflaterWriter extends OutputStream
private final byte[] outputBuffer = new byte[writeBuffer.length * 2];
- public InflaterWriter(final OutputStream output)
- {
+ public InflaterWriter(final OutputStream output) {
this.output = output;
}
@@ -51,20 +50,16 @@ public class InflaterWriter extends OutputStream
* Write a compressed byte.
*/
@Override
- public void write(final int b) throws IOException
- {
- writeBuffer[writePointer] = (byte)(b & 0xFF);
+ public void write(final int b) throws IOException {
+ writeBuffer[writePointer] = (byte) (b & 0xFF);
writePointer++;
- if (writePointer == writeBuffer.length)
- {
+ if (writePointer == writeBuffer.length) {
writePointer = 0;
- try
- {
+ try {
doWrite();
}
- catch (DataFormatException e)
- {
+ catch (DataFormatException e) {
IOException ie = new IOException("Error decompressing data");
ie.initCause(e);
throw ie;
@@ -73,23 +68,18 @@ public class InflaterWriter extends OutputStream
}
@Override
- public void close() throws IOException
- {
- if (writePointer > 0)
- {
+ public void close() throws IOException {
+ if (writePointer > 0) {
inflater.setInput(writeBuffer, 0, writePointer);
- try
- {
+ try {
int n = inflater.inflate(outputBuffer);
- while (n > 0)
- {
+ while (n > 0) {
output.write(outputBuffer, 0, n);
n = inflater.inflate(outputBuffer);
}
output.close();
}
- catch (DataFormatException e)
- {
+ catch (DataFormatException e) {
IOException io = new IOException(e.getMessage());
io.initCause(e);
throw io;
@@ -97,13 +87,11 @@ public class InflaterWriter extends OutputStream
}
}
- private void doWrite() throws DataFormatException, IOException
- {
+ private void doWrite() throws DataFormatException, IOException {
inflater.setInput(writeBuffer);
int n = inflater.inflate(outputBuffer);
- while (n > 0)
- {
+ while (n > 0) {
output.write(outputBuffer, 0, n);
n = inflater.inflate(outputBuffer);
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java
index ddbeb04..bbdaaff 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java
@@ -24,8 +24,7 @@ import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-public class JNDIUtil
-{
+public class JNDIUtil {
// Constants -----------------------------------------------------
// Static --------------------------------------------------------
@@ -33,25 +32,20 @@ public class JNDIUtil
/**
* Create a context path recursively.
*/
- public static Context createContext(final Context c, final String path) throws NamingException
- {
+ public static Context createContext(final Context c, final String path) throws NamingException {
Context crtContext = c;
- for (StringTokenizer st = new StringTokenizer(path, "/"); st.hasMoreTokens();)
- {
+ for (StringTokenizer st = new StringTokenizer(path, "/"); st.hasMoreTokens(); ) {
String tok = st.nextToken();
- try
- {
+ try {
Object o = crtContext.lookup(tok);
- if (!(o instanceof Context))
- {
+ if (!(o instanceof Context)) {
throw new NamingException("Path " + path + " overwrites and already bound object");
}
- crtContext = (Context)o;
+ crtContext = (Context) o;
continue;
}
- catch (NameNotFoundException e)
- {
+ catch (NameNotFoundException e) {
// OK
}
crtContext = crtContext.createSubcontext(tok);
@@ -59,16 +53,13 @@ public class JNDIUtil
return crtContext;
}
- public static void tearDownRecursively(final Context c) throws Exception
- {
- for (NamingEnumeration<Binding> ne = c.listBindings(""); ne.hasMore();)
- {
+ public static void tearDownRecursively(final Context c) throws Exception {
+ for (NamingEnumeration<Binding> ne = c.listBindings(""); ne.hasMore(); ) {
Binding b = ne.next();
String name = b.getName();
Object object = b.getObject();
- if (object instanceof Context)
- {
- JNDIUtil.tearDownRecursively((Context)object);
+ if (object instanceof Context) {
+ JNDIUtil.tearDownRecursively((Context) object);
}
c.unbind(name);
}
@@ -80,28 +71,23 @@ public class JNDIUtil
* NameNotFoundException is thrown. This method behaves similar to Context.rebind(), but creates
* intermediate contexts, if necessary.
*/
- public static void rebind(final Context c, final String jndiName, final Object o) throws NamingException
- {
+ public static void rebind(final Context c, final String jndiName, final Object o) throws NamingException {
Context context = c;
String name = jndiName;
int idx = jndiName.lastIndexOf('/');
- if (idx != -1)
- {
+ if (idx != -1) {
context = JNDIUtil.createContext(c, jndiName.substring(0, idx));
name = jndiName.substring(idx + 1);
}
boolean failed = false;
- try
- {
+ try {
context.rebind(name, o);
}
- catch (Exception ignored)
- {
+ catch (Exception ignored) {
failed = true;
}
- if (failed)
- {
+ if (failed) {
context.bind(name, o);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedList.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedList.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedList.java
index 4966ca2..fd64aaf 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedList.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedList.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.utils;
-public interface LinkedList<E>
-{
+public interface LinkedList<E> {
+
void addHead(E e);
void addTail(E e);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java
index 20ad38e..5d8fa57 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java
@@ -19,15 +19,14 @@ package org.apache.activemq.artemis.utils;
import java.lang.reflect.Array;
import java.util.NoSuchElementException;
-
/**
* A linked list implementation which allows multiple iterators to exist at the same time on the queue, and which see any
* elements added or removed from the queue either directly or via iterators.
*
* This class is not thread safe.
*/
-public class LinkedListImpl<E> implements LinkedList<E>
-{
+public class LinkedListImpl<E> implements LinkedList<E> {
+
private static final int INITIAL_ITERATOR_ARRAY_SIZE = 10;
private final Node<E> head = new Node<E>(null);
@@ -43,13 +42,11 @@ public class LinkedListImpl<E> implements LinkedList<E>
private int nextIndex;
- public LinkedListImpl()
- {
+ public LinkedListImpl() {
iters = createIteratorArray(INITIAL_ITERATOR_ARRAY_SIZE);
}
- public void addHead(E e)
- {
+ public void addHead(E e) {
Node<E> node = new Node<E>(e);
node.next = head.next;
@@ -58,12 +55,10 @@ public class LinkedListImpl<E> implements LinkedList<E>
head.next = node;
- if (size == 0)
- {
+ if (size == 0) {
tail = node;
}
- else
- {
+ else {
// Need to set the previous element on the former head
node.next.prev = node;
}
@@ -71,14 +66,11 @@ public class LinkedListImpl<E> implements LinkedList<E>
size++;
}
- public void addTail(E e)
- {
- if (size == 0)
- {
+ public void addTail(E e) {
+ if (size == 0) {
addHead(e);
}
- else
- {
+ else {
Node<E> node = new Node<E>(e);
node.prev = tail;
@@ -91,51 +83,42 @@ public class LinkedListImpl<E> implements LinkedList<E>
}
}
- public E poll()
- {
+ public E poll() {
Node<E> ret = head.next;
- if (ret != null)
- {
+ if (ret != null) {
removeAfter(head);
return ret.val;
}
- else
- {
+ else {
return null;
}
}
- public void clear()
- {
+ public void clear() {
tail = head.next = null;
size = 0;
}
- public int size()
- {
+ public int size() {
return size;
}
- public LinkedListIterator<E> iterator()
- {
+ public LinkedListIterator<E> iterator() {
return new Iterator();
}
- public String toString()
- {
+ public String toString() {
StringBuilder str = new StringBuilder("LinkedListImpl [ ");
Node<E> node = head;
- while (node != null)
- {
+ while (node != null) {
str.append(node.toString());
- if (node.next != null)
- {
+ if (node.next != null) {
str.append(", ");
}
@@ -145,36 +128,30 @@ public class LinkedListImpl<E> implements LinkedList<E>
return str.toString();
}
- public int numIters()
- {
+ public int numIters() {
return numIters;
}
- private Iterator[] createIteratorArray(int size)
- {
- return (Iterator[])Array.newInstance(Iterator.class, size);
+ private Iterator[] createIteratorArray(int size) {
+ return (Iterator[]) Array.newInstance(Iterator.class, size);
}
- private void removeAfter(Node<E> node)
- {
+ private void removeAfter(Node<E> node) {
Node<E> toRemove = node.next;
node.next = toRemove.next;
- if (toRemove.next != null)
- {
+ if (toRemove.next != null) {
toRemove.next.prev = node;
}
- if (toRemove == tail)
- {
+ if (toRemove == tail) {
tail = node;
}
size--;
- if (toRemove.iterCount != 0)
- {
+ if (toRemove.iterCount != 0) {
LinkedListImpl.this.nudgeIterators(toRemove);
}
@@ -183,22 +160,17 @@ public class LinkedListImpl<E> implements LinkedList<E>
toRemove.next = toRemove.prev = null;
}
- private synchronized void nudgeIterators(Node<E> node)
- {
- for (int i = 0; i < numIters; i++)
- {
+ private synchronized void nudgeIterators(Node<E> node) {
+ for (int i = 0; i < numIters; i++) {
Iterator iter = iters[i];
- if (iter != null)
- {
+ if (iter != null) {
iter.nudged(node);
}
}
}
- private synchronized void addIter(Iterator iter)
- {
- if (numIters == iters.length)
- {
+ private synchronized void addIter(Iterator iter) {
+ if (numIters == iters.length) {
resize(2 * numIters);
}
@@ -207,8 +179,7 @@ public class LinkedListImpl<E> implements LinkedList<E>
numIters++;
}
- private synchronized void resize(int newSize)
- {
+ private synchronized void resize(int newSize) {
Iterator[] newIters = createIteratorArray(newSize);
System.arraycopy(iters, 0, newIters, 0, numIters);
@@ -216,16 +187,12 @@ public class LinkedListImpl<E> implements LinkedList<E>
iters = newIters;
}
- private synchronized void removeIter(Iterator iter)
- {
- for (int i = 0; i < numIters; i++)
- {
- if (iter == iters[i])
- {
+ private synchronized void removeIter(Iterator iter) {
+ for (int i = 0; i < numIters; i++) {
+ if (iter == iters[i]) {
iters[i] = null;
- if (i != numIters - 1)
- {
+ if (i != numIters - 1) {
// Fill in the hole
System.arraycopy(iters, i + 1, iters, i, numIters - i - 1);
@@ -233,8 +200,7 @@ public class LinkedListImpl<E> implements LinkedList<E>
numIters--;
- if (numIters >= INITIAL_ITERATOR_ARRAY_SIZE && numIters == iters.length / 2)
- {
+ if (numIters >= INITIAL_ITERATOR_ARRAY_SIZE && numIters == iters.length / 2) {
resize(numIters);
}
@@ -247,8 +213,8 @@ public class LinkedListImpl<E> implements LinkedList<E>
throw new IllegalStateException("Cannot find iter to remove");
}
- private static final class Node<E>
- {
+ private static final class Node<E> {
+
Node<E> next;
Node<E> prev;
@@ -257,91 +223,75 @@ public class LinkedListImpl<E> implements LinkedList<E>
int iterCount;
- Node(E e)
- {
+ Node(E e) {
val = e;
}
- public String toString()
- {
+ public String toString() {
return "Node, value = " + val;
}
}
- private class Iterator implements LinkedListIterator<E>
- {
+ private class Iterator implements LinkedListIterator<E> {
+
Node<E> last;
Node<E> current = head.next;
boolean repeat;
- Iterator()
- {
- if (current != null)
- {
+ Iterator() {
+ if (current != null) {
current.iterCount++;
}
addIter(this);
}
- public void repeat()
- {
+ public void repeat() {
repeat = true;
}
- public boolean hasNext()
- {
+ public boolean hasNext() {
Node<E> e = getNode();
- if (e != null && (e != last || repeat))
- {
+ if (e != null && (e != last || repeat)) {
return true;
}
return canAdvance();
}
- public E next()
- {
+ public E next() {
Node<E> e = getNode();
- if (repeat)
- {
+ if (repeat) {
repeat = false;
- if (e != null)
- {
+ if (e != null) {
return e.val;
}
- else
- {
- if (canAdvance())
- {
+ else {
+ if (canAdvance()) {
advance();
e = getNode();
return e.val;
}
- else
- {
+ else {
throw new NoSuchElementException();
}
}
}
- if (e == null || e == last)
- {
- if (canAdvance())
- {
+ if (e == null || e == last) {
+ if (canAdvance()) {
advance();
e = getNode();
}
- else
- {
+ else {
throw new NoSuchElementException();
}
}
@@ -353,15 +303,12 @@ public class LinkedListImpl<E> implements LinkedList<E>
return e.val;
}
- public void remove()
- {
- if (last == null)
- {
+ public void remove() {
+ if (last == null) {
throw new NoSuchElementException();
}
- if (current == null)
- {
+ if (current == null) {
throw new NoSuchElementException();
}
@@ -370,67 +317,52 @@ public class LinkedListImpl<E> implements LinkedList<E>
last = null;
}
- public void close()
- {
+ public void close() {
removeIter(this);
}
- public void nudged(Node<E> node)
- {
- if (current == node)
- {
- if (canAdvance())
- {
+ public void nudged(Node<E> node) {
+ if (current == node) {
+ if (canAdvance()) {
advance();
}
- else
- {
- if (current.prev != head)
- {
+ else {
+ if (current.prev != head) {
current.iterCount--;
current = current.prev;
current.iterCount++;
}
- else
- {
+ else {
current = null;
}
}
}
}
- private Node<E> getNode()
- {
- if (current == null)
- {
+ private Node<E> getNode() {
+ if (current == null) {
current = head.next;
- if (current != null)
- {
+ if (current != null) {
current.iterCount++;
}
}
- if (current != null)
- {
+ if (current != null) {
return current;
}
- else
- {
+ else {
return null;
}
}
- private boolean canAdvance()
- {
- if (current == null)
- {
+ private boolean canAdvance() {
+ if (current == null) {
current = head.next;
- if (current != null)
- {
+ if (current != null) {
current.iterCount++;
}
}
@@ -438,10 +370,8 @@ public class LinkedListImpl<E> implements LinkedList<E>
return current != null && current.next != null;
}
- private void advance()
- {
- if (current == null || current.next == null)
- {
+ private void advance() {
+ if (current == null || current.next == null) {
throw new NoSuchElementException();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListIterator.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListIterator.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListIterator.java
index 83579e5..db0461f 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListIterator.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListIterator.java
@@ -18,14 +18,13 @@ package org.apache.activemq.artemis.utils;
import java.util.Iterator;
-
/**
* A LinkedListIterator
*
* This iterator allows the last element to be repeated in the next call to hasNext or next
*/
-public interface LinkedListIterator<E> extends Iterator<E>, AutoCloseable
-{
+public interface LinkedListIterator<E> extends Iterator<E>, AutoCloseable {
+
void repeat();
void close();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java
index 098d0e5..dfb3f01 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java
@@ -20,44 +20,37 @@ import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
import java.lang.ref.WeakReference;
+public class MemorySize {
-public class MemorySize
-{
private static final int numberOfObjects = 10000;
- private static Object newObject(final ObjectFactory factory) throws Exception
- {
+ private static Object newObject(final ObjectFactory factory) throws Exception {
return factory.createObject();
}
- public static boolean is64bitArch()
- {
+ public static boolean is64bitArch() {
boolean is64bit = true; // Default to 64 e.g. if can't retrieve property
- try
- {
+ try {
String arch = System.getProperty("os.arch");
- if (arch != null)
- {
+ if (arch != null) {
is64bit = arch.contains("64");
}
}
- catch (Exception e)
- {
+ catch (Exception e) {
// Ignore
}
return is64bit;
}
- public interface ObjectFactory
- {
+ public interface ObjectFactory {
+
Object createObject();
}
- public static int calculateSize(final ObjectFactory factory) throws Exception
- {
+ public static int calculateSize(final ObjectFactory factory) throws Exception {
final Runtime runtime = Runtime.getRuntime();
MemorySize.getMemorySize(runtime);
@@ -74,8 +67,7 @@ public class MemorySize
Object[] obj = new Object[MemorySize.numberOfObjects * 2];
- for (i = 0; i < MemorySize.numberOfObjects * 2; i++)
- {
+ for (i = 0; i < MemorySize.numberOfObjects * 2; i++) {
obj[i] = MemorySize.newObject(factory);
}
@@ -85,8 +77,7 @@ public class MemorySize
totalMemory1 = runtime.totalMemory();
- for (i = 0; i < MemorySize.numberOfObjects; i++)
- {
+ for (i = 0; i < MemorySize.numberOfObjects; i++) {
obj[i] = MemorySize.newObject(factory);
}
@@ -94,10 +85,9 @@ public class MemorySize
totalMemory2 = runtime.totalMemory();
- final int size = Math.round((float)(heap2 - heap1) / MemorySize.numberOfObjects);
+ final int size = Math.round((float) (heap2 - heap1) / MemorySize.numberOfObjects);
- if (totalMemory1 != totalMemory2)
- {
+ if (totalMemory1 != totalMemory2) {
// throw new IllegalStateException("Warning: JVM allocated more data what would make results invalid " +
// totalMemory1 + ":" + totalMemory2);
@@ -107,28 +97,22 @@ public class MemorySize
return size;
}
- private static long getMemorySize(final Runtime runtime)
- {
- for (int i = 0; i < 5; i++)
- {
+ private static long getMemorySize(final Runtime runtime) {
+ for (int i = 0; i < 5; i++) {
MemorySize.forceGC();
}
return runtime.totalMemory() - runtime.freeMemory();
}
- private static void forceGC()
- {
+ private static void forceGC() {
WeakReference<Object> dumbReference = new WeakReference<Object>(new Object());
// A loop that will wait GC, using the minimal time as possible
- while (dumbReference.get() != null)
- {
+ while (dumbReference.get() != null) {
System.gc();
- try
- {
+ try {
Thread.sleep(500);
}
- catch (InterruptedException e)
- {
+ catch (InterruptedException e) {
}
}
}