Skip to content

Commit

Permalink
Remove unnecessary boxing unboxing (apache#12790)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoothzj authored and eolivelli committed Nov 29, 2021
1 parent d9f9b4d commit 8161335
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 33 deletions.
Expand Up @@ -41,7 +41,7 @@
*/
public class FailFastNotifier
implements IInvokedMethodListener, ITestListener {
private static final boolean FAIL_FAST_ENABLED = Boolean.valueOf(
private static final boolean FAIL_FAST_ENABLED = Boolean.parseBoolean(
System.getProperty("testFailFast", "true"));

static class FailFastEventsSingleton {
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class FastThreadLocalCleanupListener extends BetweenTestClassesListenerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(FastThreadLocalCleanupListener.class);
private static final boolean FAST_THREAD_LOCAL_CLEANUP_ENABLED =
Boolean.valueOf(System.getProperty("testFastThreadLocalCleanup", "true"));
Boolean.parseBoolean(System.getProperty("testFastThreadLocalCleanup", "true"));
private static final String FAST_THREAD_LOCAL_CLEANUP_PACKAGE =
System.getProperty("testFastThreadLocalCleanupPackage", "org.apache.pulsar");
private static final FastThreadLocalStateCleaner CLEANER = new FastThreadLocalStateCleaner(object -> {
Expand Down
Expand Up @@ -32,7 +32,7 @@
public class MockitoCleanupListener extends BetweenTestClassesListenerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(MockitoCleanupListener.class);
private static final boolean
MOCKITO_CLEANUP_ENABLED = Boolean.valueOf(System.getProperty("testMockitoCleanup", "true"));
MOCKITO_CLEANUP_ENABLED = Boolean.parseBoolean(System.getProperty("testMockitoCleanup", "true"));

@Override
protected void onBetweenTestClasses(Class<?> endedTestClass, Class<?> startedTestClass) {
Expand Down
Expand Up @@ -32,9 +32,7 @@
*/
public class ThreadLeakDetectorListener extends BetweenTestClassesListenerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(ThreadLeakDetectorListener.class);
private static final boolean
THREAD_LEAK_DETECTOR_ENABLED = Boolean.valueOf(System.getProperty("testThreadLeakDetector",
"true"));

private Set<ThreadKey> capturedThreadKeys;

@Override
Expand Down
Expand Up @@ -2251,7 +2251,7 @@ public void findEntryFailed(ManagedLedgerException exception, Optional<Position>
c1.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries, entry -> {

try {
long publishTime = Long.valueOf(new String(entry.getData()));
long publishTime = Long.parseLong(new String(entry.getData()));
return publishTime <= timestamp;
} catch (Exception e) {
log.error("Error de-serializing message for message position find", e);
Expand Down
Expand Up @@ -206,7 +206,7 @@ public boolean authenticateHttpRequest(HttpServletRequest request, HttpServletRe
}
}
);
return authenticated.booleanValue();
return authenticated;
}

@Override
Expand Down
Expand Up @@ -1059,7 +1059,7 @@ protected void internalGetSubscriptions(AsyncResponse asyncResponse, boolean aut
existsFutures.put(i, topicResources().persistentTopicExists(topicName.getPartition(i)));
}
FutureUtil.waitForAll(Lists.newArrayList(existsFutures.values())).thenApply(__ ->
existsFutures.entrySet().stream().filter(e -> e.getValue().join().booleanValue())
existsFutures.entrySet().stream().filter(e -> e.getValue().join())
.map(item -> topicName.getPartition(item.getKey()).toString())
.collect(Collectors.toList())
).thenAccept(topics -> {
Expand Down
Expand Up @@ -641,7 +641,7 @@ private List<Message> buildMessage(ProducerMessages producerMessages, Schema sch
}
}
if (null != message.getEventTime() && !message.getEventTime().isEmpty()) {
messageMetadata.setEventTime(Long.valueOf(message.getEventTime()));
messageMetadata.setEventTime(Long.parseLong(message.getEventTime()));
}
if (message.isDisableReplication()) {
messageMetadata.clearReplicateTo();
Expand Down
Expand Up @@ -194,7 +194,7 @@ public TransactionBufferReader newReader(long sequenceId) throws

final SortedMap<Long, ByteBuf> entriesToRead = new TreeMap<>();
synchronized (entries) {
SortedMap<Long, ByteBuf> subEntries = entries.tailMap(Long.valueOf(sequenceId));
SortedMap<Long, ByteBuf> subEntries = entries.tailMap(sequenceId);
subEntries.values().forEach(value -> value.retain());
entriesToRead.putAll(subEntries);
}
Expand Down
Expand Up @@ -1398,7 +1398,7 @@ public void testRemovePublishRate() throws Exception {

@Test
public void testCheckMaxConsumers() throws Exception {
Integer maxProducers = new Integer(-1);
Integer maxProducers = -1;
log.info("MaxConsumers: {} will set to the topic: {}", maxProducers, testTopic);
try {
admin.topics().setMaxConsumers(testTopic, maxProducers);
Expand Down
Expand Up @@ -159,7 +159,7 @@ private void setAuthParams(Map<String, String> authParams) {
}

this.keyId = authParams.getOrDefault("keyId", "0");
this.autoPrefetchEnabled = Boolean.valueOf(authParams.getOrDefault("autoPrefetchEnabled", "false"));
this.autoPrefetchEnabled = Boolean.parseBoolean(authParams.getOrDefault("autoPrefetchEnabled", "false"));

if (isNotBlank(authParams.get("athenzConfPath"))) {
System.setProperty("athenz.athenz_conf", authParams.get("athenzConfPath"));
Expand Down
Expand Up @@ -289,7 +289,7 @@ static List<SubjectName> getSubjectAltNames(final X509Certificate cert) {
if (type != null) {
final Object o = entry.get(1);
if (o instanceof String) {
result.add(new SubjectName((String) o, type.intValue()));
result.add(new SubjectName((String) o, type));
} else if (o instanceof byte[]) {
// TODO ASN.1 DER encoded form
}
Expand Down
Expand Up @@ -56,13 +56,13 @@ public static BrokerUsage populateFrom(Map<String, Object> metrics) {
BrokerUsage brokerUsage = null;
if (metrics.containsKey("brk_conn_cnt")) {
brokerUsage = new BrokerUsage();
brokerUsage.connectionCount = ((Long) metrics.get("brk_conn_cnt")).longValue();
brokerUsage.connectionCount = (Long) metrics.get("brk_conn_cnt");
}
if (metrics.containsKey("brk_repl_conn_cnt")) {
if (brokerUsage == null) {
brokerUsage = new BrokerUsage();
}
brokerUsage.replicationConnectionCount = ((Long) metrics.get("brk_repl_conn_cnt")).longValue();
brokerUsage.replicationConnectionCount = (Long) metrics.get("brk_repl_conn_cnt");
}
return brokerUsage;
}
Expand Down
Expand Up @@ -83,7 +83,7 @@ private void handleWaterMarkEvent(Event<T> waterMarkEvent) {
List<Long> eventTs = windowManager.getSlidingCountTimestamps(lastProcessedTs, watermarkTs,
count);
for (long ts : eventTs) {
evictionPolicy.setContext(new DefaultEvictionContext(ts, null, Long.valueOf(count)));
evictionPolicy.setContext(new DefaultEvictionContext(ts, null, (long) count));
handler.onTrigger();
lastProcessedTs = ts;
}
Expand Down
Expand Up @@ -89,7 +89,7 @@ public long extractTimestamp(Long input) {
private static class TestWrongTimestampExtractor implements TimestampExtractor<String> {
@Override
public long extractTimestamp(String input) {
return Long.valueOf(input);
return Long.parseLong(input);
}
}

Expand Down
Expand Up @@ -56,7 +56,7 @@
@Slf4j
public class FunctionConfigUtils {

static final Integer MAX_PENDING_ASYNC_REQUESTS_DEFAULT = Integer.valueOf(1000);
static final Integer MAX_PENDING_ASYNC_REQUESTS_DEFAULT = 1000;
static final Boolean FORWARD_SOURCE_MESSAGE_PROPERTY_DEFAULT = Boolean.TRUE;

private static final ObjectMapper OBJECT_MAPPER = ObjectMapperFactory.create();
Expand Down
Expand Up @@ -365,7 +365,7 @@ private void processUncompactedMetaDataTopicMessage(Message<byte[]> message) thr
}

private void processCompactedMetaDataTopicMessage(Message<byte[]> message) throws IOException {
long version = Long.valueOf(message.getProperty(versionTag));
long version = Long.parseLong(message.getProperty(versionTag));
String tenant = FunctionCommon.extractTenantFromFullyQualifiedName(message.getKey());
String namespace = FunctionCommon.extractNamespaceFromFullyQualifiedName(message.getKey());
String functionName = FunctionCommon.extractNameFromFullyQualifiedName(message.getKey());
Expand Down
Expand Up @@ -341,10 +341,9 @@ private void deleteStatestoreTableAsync(String namespace, String table) {
StorageAdminClient adminClient = worker().getStateStoreAdminClient();
if (adminClient != null) {
adminClient.deleteStream(namespace, table).whenComplete((res, throwable) -> {
if ((throwable == null && res.booleanValue())
|| (throwable != null &&
(throwable instanceof NamespaceNotFoundException
|| throwable instanceof StreamNotFoundException) )) {
if ((throwable == null && res)
|| ((throwable instanceof NamespaceNotFoundException
|| throwable instanceof StreamNotFoundException))) {
log.info("{}/{} table deleted successfully", namespace, table);
} else {
if (throwable != null) {
Expand Down
Expand Up @@ -98,7 +98,7 @@ private void createClient(String roots) {
String[] hostPort = hosts[i].split(":");
b.addContactPoint(hostPort[0]);
if (hostPort.length > 1) {
b.withPort(Integer.valueOf(hostPort[1]));
b.withPort(Integer.parseInt(hostPort[1]));
}
}
cluster = b.build();
Expand Down
Expand Up @@ -79,12 +79,12 @@ public Optional<Map<DecoderColumnHandle, FieldValueProvider>> decodeRow(ByteBuf
primitiveColumn.put(columnHandle, booleanValueProvider(Boolean.valueOf((Boolean) value)));
} else if (type instanceof TinyintType || type instanceof SmallintType || type instanceof IntegerType
|| type instanceof BigintType) {
primitiveColumn.put(columnHandle, longValueProvider(Long.valueOf(value.toString())));
primitiveColumn.put(columnHandle, longValueProvider(Long.parseLong(value.toString())));
} else if (type instanceof DoubleType) {
primitiveColumn.put(columnHandle, doubleValueProvider(Double.valueOf(value.toString())));
primitiveColumn.put(columnHandle, doubleValueProvider(Double.parseDouble(value.toString())));
} else if (type instanceof RealType) {
primitiveColumn.put(columnHandle, longValueProvider(
Float.floatToIntBits((Float.valueOf(value.toString())))));
Float.floatToIntBits((Float.parseFloat(value.toString())))));
} else if (type instanceof VarbinaryType) {
primitiveColumn.put(columnHandle, bytesValueProvider((byte[]) value));
} else if (type instanceof VarcharType) {
Expand Down
Expand Up @@ -101,7 +101,7 @@ public void testTopics() throws Exception {
assertEquals(pulsarRecordCursor.getSlice(i).getBytes(), ((String) fooFunctions.get("field2").apply(count)).getBytes());
columnsSeen.add(fooColumnHandles.get(i).getName());
} else if (fooColumnHandles.get(i).getName().equals("field3")) {
assertEquals(pulsarRecordCursor.getLong(i), Float.floatToIntBits(((Float) fooFunctions.get("field3").apply(count)).floatValue()));
assertEquals(pulsarRecordCursor.getLong(i), Float.floatToIntBits((Float) fooFunctions.get("field3").apply(count)));
columnsSeen.add(fooColumnHandles.get(i).getName());
} else if (fooColumnHandles.get(i).getName().equals("field4")) {
assertEquals(pulsarRecordCursor.getDouble(i), ((Double) fooFunctions.get("field4").apply(count)).doubleValue());
Expand Down
Expand Up @@ -141,7 +141,7 @@ public void testPrimitiveType() {
.copiedBuffer(schemaFloat.encode(floatValue))).get();
checkValue(decodedRowFloat, new PulsarColumnHandle(getPulsarConnectorId().toString(),
PRIMITIVE_COLUMN_NAME, REAL, false, false, PRIMITIVE_COLUMN_NAME, null, null,
PulsarColumnHandle.HandleKeyValueType.NONE), Long.valueOf(Float.floatToIntBits(floatValue)));
PulsarColumnHandle.HandleKeyValueType.NONE), Float.floatToIntBits(floatValue));

double doubleValue = 0.22d;
SchemaInfo schemaInfoDouble = SchemaInfo.builder().type(SchemaType.DOUBLE).build();
Expand Down
Expand Up @@ -103,7 +103,7 @@ public ConsumerHandler(WebSocketService service, HttpServletRequest request, Ser
this.numMsgsDelivered = new LongAdder();
this.numBytesDelivered = new LongAdder();
this.numMsgsAcked = new LongAdder();
this.pullMode = Boolean.valueOf(queryParams.get("pullMode"));
this.pullMode = Boolean.parseBoolean(queryParams.get("pullMode"));

try {
// checkAuth() and getConsumerConfiguration() should be called after assigning a value to this.subscription
Expand Down
Expand Up @@ -244,7 +244,7 @@ public Integer getMaxBlockSizeInBytes() {
return Integer.valueOf(configProperties.get(key));
}
}
return new Integer(64 * MB);
return 64 * MB;
}

public Integer getMinBlockSizeInBytes() {
Expand All @@ -262,7 +262,7 @@ public Integer getReadBufferSizeInBytes() {
return Integer.valueOf(configProperties.get(key));
}
}
return new Integer(MB);
return MB;
}

public Integer getWriteBufferSizeInBytes() {
Expand Down

0 comments on commit 8161335

Please sign in to comment.