Avoid potential overflow in int multiplication before it is converted to long.

This commit is contained in:
Pascal Schumacher 2020-03-08 11:50:21 +01:00
parent 4a4880301f
commit b43f5b8cf2
6 changed files with 7 additions and 7 deletions

View File

@ -118,7 +118,7 @@ public class TransportStatusDetector implements Service, Runnable {
public void stop() throws Exception {
started.set(false);
if (runner != null) {
runner.join(getSweepInterval() * 5);
runner.join(getSweepInterval() * 5L);
}
}
}

View File

@ -175,7 +175,7 @@ public class BitArrayBin implements Serializable {
last = list.get(lastBitArrayIndex);
if (last != null) {
result += last.length() -1;
result += lastBitArrayIndex * BitArray.LONG_SIZE;
result += lastBitArrayIndex * (long) BitArray.LONG_SIZE;
break;
}
}

View File

@ -1237,7 +1237,7 @@ public class PageFile {
}
private long recoveryFileSizeForPages(int pageCount) {
return RECOVERY_FILE_HEADER_SIZE + ((pageSize + 8) * pageCount);
return RECOVERY_FILE_HEADER_SIZE + ((pageSize + 8L) * pageCount);
}
private void releaseCheckpointWaiter() {

View File

@ -726,7 +726,7 @@ public class Transaction implements Iterable<Page> {
Long key = page.getPageId();
// how much pages we have for this transaction
size = writes.size() * pageFile.getPageSize();
size = writes.size() * (long) pageFile.getPageSize();
PageWrite write;

View File

@ -694,7 +694,7 @@ public class MQTTProtocolConverter {
// Client has sent a valid CONNECT frame, we can stop the connect checker.
monitor.stopConnectChecker();
long keepAliveMS = keepAliveSeconds * 1000;
long keepAliveMS = keepAliveSeconds * 1000L;
LOG.debug("MQTT Client {} requests heart beat of {} ms", getClientId(), keepAliveMS);

View File

@ -95,7 +95,7 @@ public class JMSMemtest {
reportName = settings.getProperty("reportName");
destinationName = settings.getProperty("destinationName");
reportDirectory = settings.getProperty("reportDirectory");
connectionInterval = connectionCheckpointSize * 1024;
connectionInterval = connectionCheckpointSize * 1024L;
}
public static void main(String[] args) {
@ -171,7 +171,7 @@ public class JMSMemtest {
protected boolean resetConnection(int counter) {
if (connectionInterval > 0) {
long totalMsgSizeConsumed = counter * 1024;
long totalMsgSizeConsumed = counter * 1024L;
if (connectionInterval < totalMsgSizeConsumed) {
return true;
}