Skip to content

Commit

Permalink
ARTEMIS-4740 reduce unnecessary boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
jbertram committed Apr 27, 2024
1 parent 659b17c commit fc6f0ee
Show file tree
Hide file tree
Showing 70 changed files with 267 additions and 267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private static void printPages(DescribeJournal describeJournal,
out.print(" (ACK)");
}

if (cursorACKs.getCompletePages(q[i]).contains(Long.valueOf(pgid))) {
if (cursorACKs.getCompletePages(q[i]).contains(pgid)) {
acked = true;
out.print(" (PG-COMPLETE)");
}
Expand Down Expand Up @@ -398,8 +398,8 @@ private static PageCursorsInfo calculateCursorsInfo(List<RecordInfo> records) th
CursorAckRecordEncoding encoding = new CursorAckRecordEncoding();
encoding.decode(buff);

Long queueID = Long.valueOf(encoding.queueID);
Long pageNR = Long.valueOf(encoding.position.getPageNr());
Long queueID = encoding.queueID;
Long pageNR = encoding.position.getPageNr();

if (!cursorInfo.getCompletePages(queueID).add(pageNR)) {
System.err.println("Page " + pageNR + " has been already set as complete on queue " + queueID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ public static int getServer(Connection connection) {
ClientSession session = ((ActiveMQConnection) connection).getInitialSession();
TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration();
String port = (String) transportConfiguration.getParams().get("port");
return Integer.valueOf(port) - 61616;
return Integer.parseInt(port) - 61616;
}

public static Connection getServerConnection(int server, Connection... connections) {
for (Connection connection : connections) {
ClientSession session = ((ActiveMQConnection) connection).getInitialSession();
TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration();
String port = (String) transportConfiguration.getParams().get("port");
if (Integer.valueOf(port) == server + 61616) {
if (Integer.parseInt(port) == server + 61616) {
return connection;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1288,14 +1288,14 @@ public void testProducerRetry() throws Exception {
* it will read from the InputStream in the ActionContext. It can't read the password since it's using
* System.console.readPassword() for that.
*/
assertEquals(Long.valueOf(100), Artemis.internalExecute(false, null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin"}, context));
assertEquals(100L, Artemis.internalExecute(false, null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin"}, context));

/*
* This is the same as above except it will prompt the user to re-enter both the URL and the username.
*/
in = new ByteArrayInputStream("tcp://localhost:61616\nadmin\n".getBytes());
context = new ActionContext(in, System.out, System.err);
assertEquals(Long.valueOf(100), Artemis.internalExecute(false, null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin", "--url", "tcp://badhost:11111"}, context));
assertEquals(100L, Artemis.internalExecute(false, null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin", "--url", "tcp://badhost:11111"}, context));
} finally {
stopServer();
}
Expand Down Expand Up @@ -1380,14 +1380,14 @@ public void testSimpleRun(String folderName, int acceptorPort) throws Exception
}
Artemis.internalExecute("data", "print", "--f");

assertEquals(Long.valueOf(100), Artemis.internalExecute("producer", "--destination", "queue://q1", "--message-count", "100", "--user", "admin", "--password", "admin"));
assertEquals(Long.valueOf(100), Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(Long.valueOf(10), Artemis.internalExecute("producer", "--destination", "queue://q1", "--text-size", "500", "--message-count", "10", "--user", "admin", "--password", "admin"));
assertEquals(Long.valueOf(10), Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(Long.valueOf(10), Artemis.internalExecute("producer", "--destination", "queue://q1", "--message-size", "500", "--message-count", "10", "--user", "admin", "--password", "admin"));
assertEquals(Long.valueOf(10), Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(Long.valueOf(10), Artemis.internalExecute("producer", "--destination", "queue://q1", "--message", "message", "--message-count", "10", "--user", "admin", "--password", "admin"));
assertEquals(Long.valueOf(10), Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(100L, Artemis.internalExecute("producer", "--destination", "queue://q1", "--message-count", "100", "--user", "admin", "--password", "admin"));
assertEquals(100L, Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(10L, Artemis.internalExecute("producer", "--destination", "queue://q1", "--text-size", "500", "--message-count", "10", "--user", "admin", "--password", "admin"));
assertEquals(10L, Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(10L, Artemis.internalExecute("producer", "--destination", "queue://q1", "--message-size", "500", "--message-count", "10", "--user", "admin", "--password", "admin"));
assertEquals(10L, Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(10L, Artemis.internalExecute("producer", "--destination", "queue://q1", "--message", "message", "--message-count", "10", "--user", "admin", "--password", "admin"));
assertEquals(10L, Artemis.internalExecute("consumer", "--destination", "queue://q1", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));

ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:" + acceptorPort);
Connection connection = cf.createConnection("admin", "admin");
Expand All @@ -1408,20 +1408,20 @@ public void testSimpleRun(String folderName, int acceptorPort) throws Exception
connection.close();
cf.close();

assertEquals(Long.valueOf(1), Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--filter", "fruit='banana'", "--user", "admin", "--password", "admin"));
assertEquals(1L, Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--filter", "fruit='banana'", "--user", "admin", "--password", "admin"));

assertEquals(Long.valueOf(100), Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--filter", "fruit='orange'", "--user", "admin", "--password", "admin"));
assertEquals(100L, Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--filter", "fruit='orange'", "--user", "admin", "--password", "admin"));

assertEquals(Long.valueOf(101), Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--user", "admin", "--password", "admin"));
assertEquals(101L, Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--user", "admin", "--password", "admin"));

// should only receive 10 messages on browse as I'm setting messageCount=10
assertEquals(Long.valueOf(10), Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--message-count", "10", "--user", "admin", "--password", "admin"));
assertEquals(10L, Artemis.internalExecute("browser", "--destination", "queue://q1", "--txt-size", "50", "--message-count", "10", "--user", "admin", "--password", "admin"));

// Nothing was consumed until here as it was only browsing, check it's receiving again
assertEquals(Long.valueOf(1), Artemis.internalExecute("consumer", "--destination", "queue://q1", "--txt-size", "50", "--break-on-null", "--receive-timeout", "100", "--filter", "fruit='banana'", "--user", "admin", "--password", "admin"));
assertEquals(1L, Artemis.internalExecute("consumer", "--destination", "queue://q1", "--txt-size", "50", "--break-on-null", "--receive-timeout", "100", "--filter", "fruit='banana'", "--user", "admin", "--password", "admin"));

// Checking it was acked before
assertEquals(Long.valueOf(100), Artemis.internalExecute("consumer", "--destination", "queue://q1", "--txt-size", "50", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));
assertEquals(100L, Artemis.internalExecute("consumer", "--destination", "queue://q1", "--txt-size", "50", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin"));

//add a simple user
AddUser addCmd = new AddUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,22 @@ public static long convertTextBytes(final String text) {
try {
Matcher m = ONE.matcher(text);
if (m.matches()) {
return Long.valueOf(Long.parseLong(m.group(1)));
return Long.parseLong(m.group(1));
}

m = KILO.matcher(text);
if (m.matches()) {
return Long.valueOf(Long.parseLong(m.group(1)) * 1024);
return Long.parseLong(m.group(1)) * 1024;
}

m = MEGA.matcher(text);
if (m.matches()) {
return Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024);
return Long.parseLong(m.group(1)) * 1024 * 1024;
}

m = GIGA.matcher(text);
if (m.matches()) {
return Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024 * 1024);
return Long.parseLong(m.group(1)) * 1024 * 1024 * 1024;
}

return Long.parseLong(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class PairTest extends Assert {

@Test
public void testPair() {
Pair<Integer, Integer> p = new Pair<>(Integer.valueOf(12), Integer.valueOf(13));
Pair<Integer, Integer> p = new Pair<>(12, 13);
int hash = p.hashCode();
p.setA(null);
assertTrue(hash != p.hashCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public static int getGlobalFlowControlThreadPoolSize() {
*/
public static void initializeGlobalThreadPoolProperties() {

setGlobalThreadPoolProperties(Integer.valueOf(System.getProperty(ActiveMQClient.THREAD_POOL_MAX_SIZE_PROPERTY_KEY, "" + ActiveMQClient.DEFAULT_GLOBAL_THREAD_POOL_MAX_SIZE)), Integer.valueOf(System.getProperty(ActiveMQClient.SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY, "" + ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE)), Integer.valueOf(System.getProperty(ActiveMQClient.FLOW_CONTROL_THREAD_POOL_SIZE_PROPERTY_KEY, "" + ActiveMQClient.DEFAULT_FLOW_CONTROL_THREAD_POOL_MAX_SIZE)));
setGlobalThreadPoolProperties(Integer.parseInt(System.getProperty(ActiveMQClient.THREAD_POOL_MAX_SIZE_PROPERTY_KEY, "" + ActiveMQClient.DEFAULT_GLOBAL_THREAD_POOL_MAX_SIZE)), Integer.parseInt(System.getProperty(ActiveMQClient.SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY, "" + ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE)), Integer.parseInt(System.getProperty(ActiveMQClient.FLOW_CONTROL_THREAD_POOL_SIZE_PROPERTY_KEY, "" + ActiveMQClient.DEFAULT_FLOW_CONTROL_THREAD_POOL_MAX_SIZE)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static Map<String, Object> escapeIPv6Host(Map<String, Object> params) {
private static int getPort(Map<String, Object> params) {
Object port = params.get("port");
if (port instanceof String) {
return Integer.valueOf((String) port);
return Integer.parseInt((String) port);
}
return port != null ? (int) port : 61616;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static int getIntProperty(final String propName, final int def, final Map
// The resource adapter will aways send Strings, hence the conversion here
if (prop instanceof String) {
try {
return Integer.valueOf((String) prop);
return Integer.parseInt((String) prop);
} catch (NumberFormatException e) {
ActiveMQClientLogger.LOGGER.propertyNotInteger(propName, prop.getClass().getName());

Expand Down Expand Up @@ -84,7 +84,7 @@ public static long getLongProperty(final String propName, final long def, final
// The resource adapter will aways send Strings, hence the conversion here
if (prop instanceof String) {
try {
return Long.valueOf((String) prop);
return Long.parseLong((String) prop);
} catch (NumberFormatException e) {
ActiveMQClientLogger.LOGGER.propertyNotLong(propName, prop.getClass().getName());
return def;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ private static Version[] load() {
try {
versionProps.load(in);
String versionName = versionProps.getProperty("activemq.version.versionName");
int majorVersion = Integer.valueOf(versionProps.getProperty("activemq.version.majorVersion"));
int minorVersion = Integer.valueOf(versionProps.getProperty("activemq.version.minorVersion"));
int microVersion = Integer.valueOf(versionProps.getProperty("activemq.version.microVersion"));
int majorVersion = Integer.parseInt(versionProps.getProperty("activemq.version.majorVersion"));
int minorVersion = Integer.parseInt(versionProps.getProperty("activemq.version.minorVersion"));
int microVersion = Integer.parseInt(versionProps.getProperty("activemq.version.microVersion"));
int[] incrementingVersions = parseCompatibleVersionList(versionProps.getProperty("activemq.version.incrementingVersion"));
int[] compatibleVersionArray = parseCompatibleVersionList(versionProps.getProperty("activemq.version.compatibleVersionList"));
List<Version> definedVersions = new ArrayList<>(incrementingVersions.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected PropertySQLProvider(Factory.SQLDialect dialect, String tableName, Prop

@Override
public long getMaxBlobSize() {
return Long.valueOf(sql("max-blob-size"));
return Long.parseLong(sql("max-blob-size"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class ActiveMQConnectionMetaData implements ConnectionMetaData {
} catch (IOException e) {
}
JMS_VERSION_NAME = versionProps.getProperty("activemq.version.implementation.versionName", "2.0");
JMS_MAJOR_VERSION = Integer.valueOf(versionProps.getProperty("activemq.version.implementation.majorVersion", "2"));
JMS_MINOR_VERSION = Integer.valueOf(versionProps.getProperty("activemq.version.implementation.minorVersion", "0"));
JMS_MAJOR_VERSION = Integer.parseInt(versionProps.getProperty("activemq.version.implementation.majorVersion", "2"));
JMS_MINOR_VERSION = Integer.parseInt(versionProps.getProperty("activemq.version.implementation.minorVersion", "0"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1687,13 +1687,13 @@ public final SimpleString getSimpleStringProperty(String key) throws ActiveMQPro

@Override
public final org.apache.activemq.artemis.api.core.Message putBooleanProperty(String key, boolean value) {
getApplicationPropertiesMap(true).put(key, Boolean.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

@Override
public final org.apache.activemq.artemis.api.core.Message putByteProperty(String key, byte value) {
getApplicationPropertiesMap(true).put(key, Byte.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

Expand All @@ -1705,43 +1705,43 @@ public final org.apache.activemq.artemis.api.core.Message putBytesProperty(Strin

@Override
public final org.apache.activemq.artemis.api.core.Message putShortProperty(String key, short value) {
getApplicationPropertiesMap(true).put(key, Short.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

@Override
public final org.apache.activemq.artemis.api.core.Message putCharProperty(String key, char value) {
getApplicationPropertiesMap(true).put(key, Character.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

@Override
public final org.apache.activemq.artemis.api.core.Message putIntProperty(String key, int value) {
getApplicationPropertiesMap(true).put(key, Integer.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

@Override
public final org.apache.activemq.artemis.api.core.Message putLongProperty(String key, long value) {
getApplicationPropertiesMap(true).put(key, Long.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

@Override
public final org.apache.activemq.artemis.api.core.Message putFloatProperty(String key, float value) {
getApplicationPropertiesMap(true).put(key, Float.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

@Override
public final org.apache.activemq.artemis.api.core.Message putDoubleProperty(String key, double value) {
getApplicationPropertiesMap(true).put(key, Double.valueOf(value));
getApplicationPropertiesMap(true).put(key, value);
return this;
}

@Override
public final org.apache.activemq.artemis.api.core.Message putBooleanProperty(SimpleString key, boolean value) {
getApplicationPropertiesMap(true).put(key.toString(), Boolean.valueOf(value));
getApplicationPropertiesMap(true).put(key.toString(), value);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ public void testToCompositeDataHeaderSectionPriority() throws Exception {
Object priorityObj = cd.get(CompositeDataConstants.PRIORITY);
assertTrue(priorityObj instanceof Byte);

assertEquals(Byte.valueOf((byte) 4), priorityObj);
assertEquals((byte) 4, priorityObj);

// With section present, but value not set (defaults 4)
Header protonHeader = new Header();
Expand All @@ -2233,7 +2233,7 @@ public void testToCompositeDataHeaderSectionPriority() throws Exception {
priorityObj = cd.get(CompositeDataConstants.PRIORITY);
assertTrue(priorityObj instanceof Byte);

assertEquals(Byte.valueOf((byte) 4), priorityObj);
assertEquals((byte) 4, priorityObj);

// With section present, value set to 5 explicitly
protonHeader = new Header();
Expand All @@ -2247,7 +2247,7 @@ public void testToCompositeDataHeaderSectionPriority() throws Exception {
priorityObj = cd.get(CompositeDataConstants.PRIORITY);
assertTrue(priorityObj instanceof Byte);

assertEquals(Byte.valueOf((byte) 5), priorityObj);
assertEquals((byte) 5, priorityObj);
}

@Test
Expand Down
Loading

0 comments on commit fc6f0ee

Please sign in to comment.