geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [geode] 01/01: GEODE-5985 Possible integer overflow before assigning result to a long variable
Date Mon, 05 Nov 2018 19:30:08 GMT
This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-5985
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 2101f9550259ef47ce53ca2d56ce0936f6d5a659
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
AuthorDate: Mon Nov 5 11:26:21 2018 -0800

    GEODE-5985 Possible integer overflow before assigning result to a long variable
    
    We had a number of calculations that were taking place with ints instead
    of longs.  I've modified them to, in most places, just add an L to the
    constant multiplier.  In other places I had to change a variable type
    from int to long.
    
    There were a few places that were also assigning a long to an int
    variable or an int to a byte variable.  In these I added bit AND
    operators to reduce the chances of overflow.
---
 .../geode/cache/query/dunit/PortfolioPdxVersion.java   | 10 +++++-----
 .../src/main/java/org/apache/geode/SystemFailure.java  |  2 +-
 .../admin/internal/DistributedSystemHealthMonitor.java |  2 +-
 .../org/apache/geode/admin/jmx/internal/MBeanUtil.java |  6 +++---
 .../cache/query/internal/index/IndexElemArray.java     |  2 +-
 .../internal/InternalDistributedSystem.java            |  4 ++--
 .../geode/distributed/internal/InternalLocator.java    |  4 ++--
 .../internal/membership/gms/ServiceConfig.java         |  2 +-
 .../membership/gms/messenger/GMSQuorumChecker.java     |  2 +-
 .../membership/gms/mgr/GMSMembershipManager.java       |  4 ++--
 .../org/apache/geode/internal/cache/BucketAdvisor.java |  4 ++--
 .../geode/internal/cache/DiskWriteAttributesImpl.java  |  4 ++--
 .../apache/geode/internal/cache/DistributedRegion.java |  6 +++---
 .../java/org/apache/geode/internal/cache/Oplog.java    |  4 ++--
 .../apache/geode/internal/cache/PartitionedRegion.java | 18 +++++++++---------
 .../org/apache/geode/internal/cache/TXManagerImpl.java |  2 +-
 .../internal/cache/entries/AbstractRegionEntry.java    |  4 ++--
 .../cache/partitioned/rebalance/model/Member.java      |  2 +-
 .../cache/wan/AbstractGatewaySenderEventProcessor.java |  2 +-
 .../cache/wan/serial/SerialGatewaySenderQueue.java     | 16 +---------------
 .../apache/geode/internal/jta/GlobalTransaction.java   |  2 +-
 .../java/org/apache/geode/internal/tcp/Connection.java |  4 ++--
 .../org/apache/geode/internal/tcp/MsgOutputStream.java |  4 ++--
 .../org/apache/geode/internal/tcp/MsgStreamer.java     |  4 ++--
 .../org/apache/geode/internal/util/PasswordUtil.java   |  2 +-
 .../internal/cli/commands/CreateDiskStoreCommand.java  |  2 +-
 .../internal/cli/commands/ShutdownCommand.java         |  2 +-
 .../org/apache/geode/cache/query/data/Numbers.java     |  2 +-
 .../org/apache/geode/cache/query/data/Portfolio.java   | 10 +++++-----
 .../apache/geode/cache/query/data/PortfolioNoDS.java   | 11 ++++++-----
 .../apache/geode/cache/query/data/PortfolioPdx.java    | 10 +++++-----
 .../java/org/apache/geode/cache/query/data/Quote.java  |  2 +-
 .../org/apache/geode/cache/query/data/Restricted.java  |  2 +-
 .../geode/tools/pulse/internal/data/Cluster.java       |  9 ++++-----
 34 files changed, 76 insertions(+), 90 deletions(-)

diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PortfolioPdxVersion.java
b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PortfolioPdxVersion.java
index 5a61c64..478ebd2 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PortfolioPdxVersion.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PortfolioPdxVersion.java
@@ -52,18 +52,18 @@ public class PortfolioPdxVersion {
     status = i % 2 == 0 ? "active" : "inactive";
     type = "type" + (i % 3);
     position1 = new PositionPdxVersion(secIds[PositionPdxVersion.cnt % secIds.length],
-        PositionPdxVersion.cnt * 1000);
+        PositionPdxVersion.cnt * 1000L);
     if (i % 2 != 0) {
       position2 = new PositionPdxVersion(secIds[PositionPdxVersion.cnt % secIds.length],
-          PositionPdxVersion.cnt * 1000);
+          PositionPdxVersion.cnt * 1000L);
     } else {
       position2 = null;
     }
 
     positions.put(secIds[PositionPdxVersion.cnt % secIds.length], new PositionPdxVersion(
-        secIds[PositionPdxVersion.cnt % secIds.length], PositionPdxVersion.cnt * 1000));
+        secIds[PositionPdxVersion.cnt % secIds.length], PositionPdxVersion.cnt * 1000L));
     positions.put(secIds[PositionPdxVersion.cnt % secIds.length], new PositionPdxVersion(
-        secIds[PositionPdxVersion.cnt % secIds.length], PositionPdxVersion.cnt * 1000));
+        secIds[PositionPdxVersion.cnt % secIds.length], PositionPdxVersion.cnt * 1000L));
 
     collectionHolderMap.put("0", new CollectionHolder());
     collectionHolderMap.put("1", new CollectionHolder());
@@ -77,7 +77,7 @@ public class PortfolioPdxVersion {
     this.position1.portfolioId = j;
     this.position3 = new Object[3];
     for (int k = 0; k < position3.length; k++) {
-      PositionPdxVersion p = new PositionPdxVersion(secIds[k], (k + 1) * 1000);
+      PositionPdxVersion p = new PositionPdxVersion(secIds[k], (k + 1) * 1000L);
       p.portfolioId = (k + 1);
       this.position3[k] = p;
     }
diff --git a/geode-core/src/main/java/org/apache/geode/SystemFailure.java b/geode-core/src/main/java/org/apache/geode/SystemFailure.java
index 474e117..01ae8fb 100644
--- a/geode-core/src/main/java/org/apache/geode/SystemFailure.java
+++ b/geode-core/src/main/java/org/apache/geode/SystemFailure.java
@@ -380,7 +380,7 @@ public final class SystemFailure {
           }
           logFine(WATCHDOG_NAME, "Waiting for disaster");
           try {
-            failureSync.wait(WATCHDOG_WAIT * 1000);
+            failureSync.wait(WATCHDOG_WAIT * 1000L);
           } catch (InterruptedException e) {
             // Ignore
           }
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemHealthMonitor.java
b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemHealthMonitor.java
index ae8f659..2eaaf80 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemHealthMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemHealthMonitor.java
@@ -122,7 +122,7 @@ class DistributedSystemHealthMonitor implements Runnable, GemFireVM {
     while (!this.stopRequested) {
       SystemFailure.checkFailure();
       try {
-        Thread.sleep(interval * 1000);
+        Thread.sleep(interval * 1000L);
         List status = new ArrayList();
         eval.evaluate(status);
 
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MBeanUtil.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MBeanUtil.java
index b4b59fe..ca7bc02 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MBeanUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MBeanUtil.java
@@ -303,7 +303,7 @@ public class MBeanUtil {
    * @param refreshInterval the seconds between refreshes
    */
   static void registerRefreshNotification(NotificationListener client, Object userData,
-      RefreshNotificationType type, int refreshInterval) {
+      RefreshNotificationType type, long refreshInterval) {
     if (client == null) {
       throw new IllegalArgumentException(
           "NotificationListener is required");
@@ -371,8 +371,8 @@ public class MBeanUtil {
         timerNotificationId = refreshTimer.addNotification(type.getType(), // type
             type.getMessage(), // message = "refresh"
             userData, // userData
-            new Date(System.currentTimeMillis() + refreshInterval * 1000), // first occurrence
-            refreshInterval * 1000); // period to repeat
+            new Date(System.currentTimeMillis() + refreshInterval * 1000L), // first occurrence
+            refreshInterval * 1000L); // period to repeat
 
         // put an entry into the map for the listener...
         notifications.put(type, timerNotificationId);
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexElemArray.java
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexElemArray.java
index ab22e87..057ecf0 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexElemArray.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexElemArray.java
@@ -243,7 +243,7 @@ public class IndexElemArray implements Iterable, Collection {
     synchronized (lock) {
       ensureCapacity(size + numNew);
       System.arraycopy(a, 0, elementData, size, numNew);
-      size += numNew;
+      size += (byte) (numNew & 0xFF);
     }
     return numNew != 0;
   }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index d1a0ca2..7d8e41e 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -851,7 +851,7 @@ public class InternalDistributedSystem extends DistributedSystem
     if (attemptingToReconnect && !this.isConnected) {
       if (this.quorumChecker != null) {
         logger.info("performing a quorum check to see if location services can be started
early");
-        if (!quorumChecker.checkForQuorum(3 * this.config.getMemberTimeout())) {
+        if (!quorumChecker.checkForQuorum(3L * this.config.getMemberTimeout())) {
           logger.info("quorum check failed - not allowing location services to start early");
           return;
         }
@@ -2798,7 +2798,7 @@ public class InternalDistributedSystem extends DistributedSystem
         if (reconnectDS != null && reconnectDS.isConnected()) {
           // make sure the new DS and cache are stable before exiting this loop
           try {
-            Thread.sleep(config.getMemberTimeout() * 3);
+            Thread.sleep(config.getMemberTimeout() * 3L);
           } catch (InterruptedException e) {
             logger.info("Reconnect thread has been interrupted - exiting");
             Thread.currentThread().interrupt();
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index 9c3ce64..cd99a6d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -961,7 +961,7 @@ public class InternalLocator extends Locator implements ConnectListener
{
           }
         }
         if (checker != null && !tcpServerStarted) {
-          boolean start = checker.checkForQuorum(3 * this.myDs.getConfig().getMemberTimeout());
+          boolean start = checker.checkForQuorum(3L * this.myDs.getConfig().getMemberTimeout());
           if (start) {
             // start up peer location. server location is started after the DS finishes
             // reconnecting
@@ -1188,7 +1188,7 @@ public class InternalLocator extends Locator implements ConnectListener
{
                 // always retry some number of times
                 locatorWaitTime = 30;
               }
-              giveup = System.currentTimeMillis() + locatorWaitTime * 1000;
+              giveup = System.currentTimeMillis() + locatorWaitTime * 1000L;
               try {
                 Thread.sleep(1000);
               } catch (InterruptedException ignored) {
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/ServiceConfig.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/ServiceConfig.java
index 09e2ed8..08edb8a 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/ServiceConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/ServiceConfig.java
@@ -118,7 +118,7 @@ public class ServiceConfig {
 
     // we need to have enough time to figure out that the coordinator has crashed &
     // find a new one
-    long minimumJoinTimeout = dconfig.getMemberTimeout() * 2 + MEMBER_REQUEST_COLLECTION_INTERVAL;
+    long minimumJoinTimeout = dconfig.getMemberTimeout() * 2L + MEMBER_REQUEST_COLLECTION_INTERVAL;
     if (defaultJoinTimeout < minimumJoinTimeout) {
       defaultJoinTimeout = minimumJoinTimeout;
     }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSQuorumChecker.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSQuorumChecker.java
index 32c802e..50b803d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSQuorumChecker.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSQuorumChecker.java
@@ -53,7 +53,7 @@ public class GMSQuorumChecker implements QuorumChecker {
   private boolean quorumAchieved = false;
   private final JChannel channel;
   private JGAddress myAddress;
-  private final int partitionThreshold;
+  private final long partitionThreshold;
   private Set<DistributedMember> oldDistributedMemberIdentifiers;
 
   public GMSQuorumChecker(NetView jgView, int partitionThreshold, JChannel channel,
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
index 9fc2cee..3a017ce 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
@@ -1994,7 +1994,7 @@ public class GMSMembershipManager implements MembershipManager, Manager
{
       // Make sure that the entry isn't stale...
       long shunTime = shunnedMembers.get(m).longValue();
       long now = System.currentTimeMillis();
-      if (shunTime + SHUNNED_SUNSET * 1000 > now) {
+      if (shunTime + SHUNNED_SUNSET * 1000L > now) {
         return true;
       }
 
@@ -2088,7 +2088,7 @@ public class GMSMembershipManager implements MembershipManager, Manager
{
    * @param m the member to add
    */
   private void addShunnedMember(InternalDistributedMember m) {
-    long deathTime = System.currentTimeMillis() - SHUNNED_SUNSET * 1000;
+    long deathTime = System.currentTimeMillis() - SHUNNED_SUNSET * 1000L;
 
     surpriseMembers.remove(m); // for safety
 
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java
index d0633f4..7d47936 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java
@@ -814,10 +814,10 @@ public class BucketAdvisor extends CacheDistributionAdvisor {
     DistributionManager dm = this.regionAdvisor.getDistributionManager();
     DistributionConfig config = dm.getConfig();
     // failure detection period
-    long timeout = config.getMemberTimeout() * 3;
+    long timeout = config.getMemberTimeout() * 3L;
     // plus time for a new member to become primary
     timeout += Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "BucketAdvisor.getPrimaryTimeout",
-        15 * 1000);
+        15000L);
     InternalDistributedMember newPrimary = waitForPrimaryMember(timeout);
     return newPrimary;
   }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskWriteAttributesImpl.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskWriteAttributesImpl.java
index d4c5fff..5f1b662 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskWriteAttributesImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskWriteAttributesImpl.java
@@ -361,7 +361,7 @@ public class DiskWriteAttributesImpl implements DiskWriteAttributes {
    */
   @Override
   public int hashCode() {
-    int result = 0;
+    long result = 0;
 
     if (this.isSynchronous()) {
       if (this.isRollOplogs()) {
@@ -373,7 +373,7 @@ public class DiskWriteAttributesImpl implements DiskWriteAttributes {
       result += this.getBytesThreshold();
     }
     result += this.getMaxOplogSize();
-    return result;
+    return (int) (result & 0xFFFFFFFF);
   }
 
   @Override
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
index f1174a0..3688272 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
@@ -2961,7 +2961,7 @@ public class DistributedRegion extends LocalRegion implements InternalDistribute
     if (getCache().getLockLease() == -1) {
       return -1;
     }
-    return getCache().getLockLease() * 1000;
+    return (getCache().getLockLease()) * 1000L;
   }
 
   /**
@@ -3050,13 +3050,13 @@ public class DistributedRegion extends LocalRegion implements InternalDistribute
         end = start + timeoutMS;
       }
 
-      long ackSAThreshold = getSystem().getConfig().getAckSevereAlertThreshold() * 1000;
+      long ackSAThreshold = getSystem().getConfig().getAckSevereAlertThreshold() * 1000L;
 
       long waitInterval;
       long ackWaitThreshold;
 
       if (ackSAThreshold > 0) {
-        ackWaitThreshold = getSystem().getConfig().getAckWaitThreshold() * 1000;
+        ackWaitThreshold = getSystem().getConfig().getAckWaitThreshold() * 1000L;
         waitInterval = ackWaitThreshold;
       } else {
         waitInterval = timeoutMS;
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java b/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
index 214fa71..6e60745 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
@@ -6648,7 +6648,7 @@ public class Oplog implements CompactableOplog, Flushable {
         long delta = calcDelta(oplogKeyId, this.opCode);
         this.deltaIdBytesLength = bytesNeeded(delta);
         this.size += this.deltaIdBytesLength;
-        this.opCode += this.deltaIdBytesLength - 1;
+        this.opCode += (this.deltaIdBytesLength & 0xFF) - 1;
         for (int i = this.deltaIdBytesLength - 1; i >= 0; i--) {
           this.deltaIdBytes[i] = (byte) (delta & 0xFF);
           delta >>= 8;
@@ -6745,7 +6745,7 @@ public class Oplog implements CompactableOplog, Flushable {
         long delta = calcDelta(keyId, this.opCode);
         this.deltaIdBytesLength = bytesNeeded(delta);
         this.size += this.deltaIdBytesLength;
-        this.opCode += this.deltaIdBytesLength - 1;
+        this.opCode += (byte) (this.deltaIdBytesLength & 0xFF) - 1;
         for (int i = this.deltaIdBytesLength - 1; i >= 0; i--) {
           this.deltaIdBytes[i] = (byte) (delta & 0xFF);
           delta >>= 8;
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
index 11e1bdb..55a239b 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
@@ -6633,7 +6633,7 @@ public class PartitionedRegion extends LocalRegion
         DistributionManager dm = cache.getInternalDistributedSystem().getDistributionManager();
 
         long ackWaitThreshold = 0;
-        long ackSAThreshold = dm.getConfig().getAckSevereAlertThreshold() * 1000;
+        long ackSAThreshold = dm.getConfig().getAckSevereAlertThreshold() * 1000L;
         boolean suspected = false;
         boolean severeAlertIssued = false;
         DistributedMember lockHolder = null;
@@ -6644,11 +6644,11 @@ public class PartitionedRegion extends LocalRegion
         if (!enableAlerts) {
           // Make sure we only attempt the lock long enough not to
           // get a 15 second warning from the reply processor.
-          ackWaitThreshold = dm.getConfig().getAckWaitThreshold() * 1000;
+          ackWaitThreshold = dm.getConfig().getAckWaitThreshold() * 1000L;
           waitInterval = ackWaitThreshold - 1;
           startTime = System.currentTimeMillis();
         } else if (ackSAThreshold > 0) {
-          ackWaitThreshold = dm.getConfig().getAckWaitThreshold() * 1000;
+          ackWaitThreshold = dm.getConfig().getAckWaitThreshold() * 1000L;
           waitInterval = ackWaitThreshold;
           startTime = System.currentTimeMillis();
         } else {
@@ -6719,7 +6719,7 @@ public class PartitionedRegion extends LocalRegion
       }
 
       long ackSAThreshold =
-          cache.getInternalDistributedSystem().getConfig().getAckSevereAlertThreshold() *
1000;
+          cache.getInternalDistributedSystem().getConfig().getAckSevereAlertThreshold() *
1000L;
       boolean suspected = false;
       boolean severeAlertIssued = false;
       DistributedMember lockHolder = null;
@@ -6729,7 +6729,7 @@ public class PartitionedRegion extends LocalRegion
 
       if (ackSAThreshold > 0) {
         ackWaitThreshold =
-            cache.getInternalDistributedSystem().getConfig().getAckWaitThreshold() * 1000;
+            cache.getInternalDistributedSystem().getConfig().getAckWaitThreshold() * 1000L;
         waitInterval = ackWaitThreshold;
         start = System.currentTimeMillis();
       } else {
@@ -7190,7 +7190,7 @@ public class PartitionedRegion extends LocalRegion
           }
         } else {
           try {
-            Thread.sleep(AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME * 1000);
+            Thread.sleep(AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME * 1000L);
           } catch (InterruptedException ignore) {/* ignore */
             // interrupted
           }
@@ -7937,9 +7937,9 @@ public class PartitionedRegion extends LocalRegion
    * synchronization or concurrent safety
    */
   public static class RetryTimeKeeper {
-    private int totalTimeInRetry;
+    private long totalTimeInRetry;
 
-    private final int maxTimeInRetry;
+    private final long maxTimeInRetry;
 
     public RetryTimeKeeper(int maxTime) {
       this.maxTimeInRetry = maxTime;
@@ -7988,7 +7988,7 @@ public class PartitionedRegion extends LocalRegion
       return this.totalTimeInRetry > this.maxTimeInRetry;
     }
 
-    public int getRetryTime() {
+    public long getRetryTime() {
       return this.totalTimeInRetry;
     }
   }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java
index 2843046..f853747 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java
@@ -1799,7 +1799,7 @@ public class TXManagerImpl implements CacheTransactionManager, MembershipListene
     if (this.cache.isClosed()) {
       return;
     }
-    long timeout = getTransactionTimeToLive() * 1000;
+    long timeout = getTransactionTimeToLive() * 1000L;
     if (timeout <= 0) {
       removeTransactionsSentFromDepartedProxy(proxyServer);
     } else {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java
index 3858f89..2134216 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java
@@ -1887,9 +1887,9 @@ public abstract class AbstractRegionEntry implements HashRegionEntry<Object,
Obj
               .append(stampVersion);
         }
         if (difference < 0) {
-          tagVersion += 0x1000000L;
+          tagVersion += 0x1000000;
         } else {
-          stampVersion += 0x1000000L;
+          stampVersion += 0x1000000;
         }
       }
     }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/rebalance/model/Member.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/rebalance/model/Member.java
index ec410e1..8e4b2a9 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/rebalance/model/Member.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/rebalance/model/Member.java
@@ -213,7 +213,7 @@ public class Member implements Comparable<Member> {
   }
 
   void changeTotalBytes(float change) {
-    totalBytes += change;
+    totalBytes += (long) Math.round(change);
   }
 
   @Override
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
index f1ae7d5..0c57ba5 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
@@ -1155,7 +1155,7 @@ public abstract class AbstractGatewaySenderEventProcessor extends LoggingThread
         }
       } else {
         try {
-          Thread.sleep(AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME * 1000);
+          Thread.sleep(AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME * 1000L);
         } catch (InterruptedException e) {/* ignore */
           // interrupted
         }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderQueue.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderQueue.java
index 4e5cc27..e0f38a5 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderQueue.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderQueue.java
@@ -20,7 +20,6 @@ import java.util.Deque;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.PriorityQueue;
 import java.util.Set;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.concurrent.atomic.AtomicLong;
@@ -173,10 +172,6 @@ public class SerialGatewaySenderQueue implements RegionQueue {
 
   private BatchRemovalThread removalThread = null;
 
-  private final boolean keyPutNoSync;
-  private final int maxPendingPuts;
-  private final PriorityQueue<Long> pendingPuts;
-
   private AbstractGatewaySender sender = null;
 
   public SerialGatewaySenderQueue(AbstractGatewaySender abstractSender, String regionName,
@@ -196,15 +191,6 @@ public class SerialGatewaySenderQueue implements RegionQueue {
     } else {
       this.isDiskSynchronous = false;
     }
-    if (Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "gateway-queue-sync")) {
-      this.keyPutNoSync = false;
-      this.maxPendingPuts = 0;
-      this.pendingPuts = null;
-    } else {
-      this.keyPutNoSync = true;
-      this.maxPendingPuts = Math.max(this.batchSize, 100);
-      this.pendingPuts = new PriorityQueue<Long>(this.maxPendingPuts + 5);
-    }
     this.maximumQueueMemory = abstractSender.getMaximumMemeoryPerDispatcherQueue();
     this.stats = abstractSender.getStatistics();
     initializeRegion(abstractSender, listener);
@@ -1005,7 +991,7 @@ public class SerialGatewaySenderQueue implements RegionQueue {
             boolean interrupted = Thread.interrupted();
             try {
               synchronized (this) {
-                this.wait(messageSyncInterval * 1000);
+                this.wait(messageSyncInterval * 1000L);
               }
             } catch (InterruptedException e) {
               interrupted = true;
diff --git a/geode-core/src/main/java/org/apache/geode/internal/jta/GlobalTransaction.java
b/geode-core/src/main/java/org/apache/geode/internal/jta/GlobalTransaction.java
index 53a981e..44f31bc 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/jta/GlobalTransaction.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/jta/GlobalTransaction.java
@@ -661,7 +661,7 @@ public class GlobalTransaction {
         }
       }
     }
-    long newExp = System.currentTimeMillis() + (seconds * 1000);
+    long newExp = System.currentTimeMillis() + (seconds * 1000L);
     if (!resetXATimeOut)
       newExp = -1;
     return newExp;
diff --git a/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java b/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
index e8541c0..d5d20b8 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
@@ -2587,8 +2587,8 @@ public class Connection implements Runnable {
   /** ensure that a task is running to monitor transmission and reading of acks */
   public synchronized void scheduleAckTimeouts() {
     if (ackTimeoutTask == null) {
-      final long msAW = this.owner.getDM().getConfig().getAckWaitThreshold() * 1000;
-      final long msSA = this.owner.getDM().getConfig().getAckSevereAlertThreshold() * 1000;
+      final long msAW = this.owner.getDM().getConfig().getAckWaitThreshold() * 1000L;
+      final long msSA = this.owner.getDM().getConfig().getAckSevereAlertThreshold() * 1000L;
       ackTimeoutTask = new SystemTimer.SystemTimerTask() {
         @Override
         public void run2() {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgOutputStream.java b/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgOutputStream.java
index 7426089..600d967 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgOutputStream.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgOutputStream.java
@@ -48,7 +48,7 @@ public class MsgOutputStream extends OutputStream implements ObjToByteArraySeria
   /** write the low-order 8 bits of the given int */
   @Override
   public void write(int b) {
-    buffer.put((byte) b);
+    buffer.put((byte) (b & 0xff));
   }
 
   /** override OutputStream's write() */
@@ -133,7 +133,7 @@ public class MsgOutputStream extends OutputStream implements ObjToByteArraySeria
    * @exception IOException if an I/O error occurs.
    */
   public void writeShort(int v) throws IOException {
-    buffer.putShort((short) v);
+    buffer.putShort((short) (v & 0xffff));
   }
 
   /**
diff --git a/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgStreamer.java b/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgStreamer.java
index c8cbe56..a09d2f2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgStreamer.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/tcp/MsgStreamer.java
@@ -254,7 +254,7 @@ public class MsgStreamer extends OutputStream
       this.overflowBuf.write(b);
       return;
     }
-    this.buffer.put((byte) b);
+    this.buffer.put((byte) (b & 0xff));
   }
 
   private void ensureCapacity(int amount) {
@@ -502,7 +502,7 @@ public class MsgStreamer extends OutputStream
       this.overflowBuf.writeShort(v);
       return;
     }
-    this.buffer.putShort((short) v);
+    this.buffer.putShort((short) (v & 0xffff));
   }
 
   /**
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
index b5769b3..10fc6b3 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
@@ -61,7 +61,7 @@ public class PasswordUtil {
     for (int i = 0; i < b.length; i++) {
       int index = i * 2;
       int v = Integer.parseInt(s.substring(index, index + 2), 16);
-      b[i] = (byte) v;
+      b[i] = (byte) (v & 0xff);
     }
     return b;
   }
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateDiskStoreCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateDiskStoreCommand.java
index 023923c..f4db0ad 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateDiskStoreCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateDiskStoreCommand.java
@@ -83,7 +83,7 @@ public class CreateDiskStoreCommand extends SingleGfshCommand {
     diskStoreAttributes.allowForceCompaction = allowForceCompaction;
     diskStoreAttributes.autoCompact = autoCompact;
     diskStoreAttributes.compactionThreshold = compactionThreshold;
-    diskStoreAttributes.maxOplogSizeInBytes = maxOplogSize * (1024 * 1024);
+    diskStoreAttributes.maxOplogSizeInBytes = maxOplogSize * (1024L * 1024L);
     diskStoreAttributes.queueSize = queueSize;
     diskStoreAttributes.timeInterval = timeInterval;
     diskStoreAttributes.writeBufferSize = writeBufferSize;
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShutdownCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShutdownCommand.java
index 75c4cbd..717d378 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShutdownCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShutdownCommand.java
@@ -67,7 +67,7 @@ public class ShutdownCommand extends InternalGfshCommand {
       }
 
       // convert to milliseconds
-      long timeout = userSpecifiedTimeout * 1000;
+      long timeout = userSpecifiedTimeout * 1000L;
       InternalCache cache = (InternalCache) getCache();
       int numDataNodes = getAllNormalMembers().size();
       Set<DistributedMember> locators = getAllMembers();
diff --git a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Numbers.java b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Numbers.java
index 39105e5..1d5b5d4 100755
--- a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Numbers.java
+++ b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Numbers.java
@@ -40,7 +40,7 @@ public class Numbers implements Serializable {
     avg1 = (id + id1 + id2) / 3;
     max1 = id;
     range = (id - id1);
-    l = id * 100000000;
+    l = id * 100000000L;
   }
 
 }
diff --git a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Portfolio.java b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Portfolio.java
index 6215d9b..2f5e71a 100644
--- a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Portfolio.java
+++ b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Portfolio.java
@@ -134,16 +134,16 @@ public class Portfolio implements Serializable, DataSerializable {
     pkid = "" + i;
     status = i % 2 == 0 ? "active" : "inactive";
     type = "type" + (i % 3);
-    position1 = new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000);
+    position1 = new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L);
     if (i % 2 != 0) {
-      position2 = new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000);
+      position2 = new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L);
     } else {
       position2 = null;
     }
     positions.put(secIds[Position.cnt % secIds.length],
-        new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000));
+        new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L));
     positions.put(secIds[Position.cnt % secIds.length],
-        new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000));
+        new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L));
     collectionHolderMap.put("0", new CollectionHolder());
     collectionHolderMap.put("1", new CollectionHolder());
     collectionHolderMap.put("2", new CollectionHolder());
@@ -158,7 +158,7 @@ public class Portfolio implements Serializable, DataSerializable {
     this.position1.portfolioId = j;
     this.position3 = new Position[3];
     for (int k = 0; k < position3.length; k++) {
-      Position p = new Position(secIds[k], (k + 1) * 1000);
+      Position p = new Position(secIds[k], (k + 1) * 1000L);
       p.portfolioId = (k + 1);
       this.position3[k] = p;
     }
diff --git a/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioNoDS.java
b/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioNoDS.java
index 9f4559a..3b92baf 100644
--- a/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioNoDS.java
+++ b/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioNoDS.java
@@ -125,17 +125,18 @@ public class PortfolioNoDS implements Serializable {
     pkid = "" + i;
     status = i % 2 == 0 ? "active" : "inactive";
     type = "type" + (i % 3);
-    position1 = new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt
* 1000);
+    position1 =
+        new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt * 1000L);
     if (i % 2 != 0) {
       position2 =
-          new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt * 1000);
+          new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt * 1000L);
     } else {
       position2 = null;
     }
     positions.put(secIds[PositionNoDS.cnt % secIds.length],
-        new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt * 1000));
+        new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt * 1000L));
     positions.put(secIds[PositionNoDS.cnt % secIds.length],
-        new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt * 1000));
+        new PositionNoDS(secIds[PositionNoDS.cnt % secIds.length], PositionNoDS.cnt * 1000L));
     collectionHolderMap.put("0", new CollectionHolder());
     collectionHolderMap.put("1", new CollectionHolder());
     collectionHolderMap.put("2", new CollectionHolder());
@@ -150,7 +151,7 @@ public class PortfolioNoDS implements Serializable {
     this.position1.portfolioId = j;
     this.position3 = new PositionNoDS[3];
     for (int k = 0; k < position3.length; k++) {
-      PositionNoDS p = new PositionNoDS(secIds[k], (k + 1) * 1000);
+      PositionNoDS p = new PositionNoDS(secIds[k], (k + 1) * 1000L);
       p.portfolioId = (k + 1);
       this.position3[k] = p;
     }
diff --git a/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioPdx.java
b/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioPdx.java
index 0a06ec0..fc7c19f 100644
--- a/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioPdx.java
+++ b/geode-junit/src/main/java/org/apache/geode/cache/query/data/PortfolioPdx.java
@@ -153,17 +153,17 @@ public class PortfolioPdx implements Serializable, PdxSerializable {
     pkid = "" + i;
     status = i % 2 == 0 ? "active" : "inactive";
     type = "type" + (i % 3);
-    position1 = new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt
* 1000);
+    position1 = new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt
* 1000L);
     if (i % 2 != 0) {
-      position2 = new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt
* 1000);
+      position2 = new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt
* 1000L);
     } else {
       position2 = null;
     }
 
     positions.put(secIds[PositionPdx.cnt % secIds.length],
-        new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000));
+        new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000L));
     positions.put(secIds[PositionPdx.cnt % secIds.length],
-        new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000));
+        new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000L));
 
     collectionHolderMap.put("0", new CollectionHolder());
     collectionHolderMap.put("1", new CollectionHolder());
@@ -180,7 +180,7 @@ public class PortfolioPdx implements Serializable, PdxSerializable {
     this.position1.portfolioId = j;
     this.position3 = new Object[3];
     for (int k = 0; k < position3.length; k++) {
-      PositionPdx p = new PositionPdx(secIds[k], (k + 1) * 1000);
+      PositionPdx p = new PositionPdx(secIds[k], (k + 1) * 1000L);
       p.portfolioId = (k + 1);
       this.position3[k] = p;
     }
diff --git a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Quote.java b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Quote.java
index 4fa4d95..adcfcb3 100644
--- a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Quote.java
+++ b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Quote.java
@@ -61,7 +61,7 @@ public class Quote implements Serializable {
     String[] arr4 = {"priceType1", "priceType2", "priceType3", "priceType4", "priceType5",
         "priceType6", "priceType7"};
     priceType = arr4[i % 7];
-    price = (i / 10) * 8;
+    price = (i / 10.0) * 8.0;
     lowerQty = i + 100;
     upperQty = i + 1000;
     if ((i % 12) == 0) {
diff --git a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Restricted.java b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Restricted.java
index ce44485..8e8b727 100644
--- a/geode-junit/src/main/java/org/apache/geode/cache/query/data/Restricted.java
+++ b/geode-junit/src/main/java/org/apache/geode/cache/query/data/Restricted.java
@@ -39,7 +39,7 @@ public class Restricted implements Serializable {
         "auto transport", "mortgage"};
     quoteType = arr1[i % 7];
     uniqueQuoteType = "quoteType" + Integer.toString(i);
-    price = (i / 10) * 8;
+    price = (i / 10.0) * 8.0;
     minQty = i + 100;
     maxQty = i + 1000;
     if ((i % 12) == 0) {
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
index c531b1d..26f9b88 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
@@ -789,12 +789,11 @@ public class Cluster extends Thread {
           existingClient.setUptime(updatedClient.getUptime());
 
           // set cpu usage
-          long lastCPUTime = 0;
-          lastCPUTime = existingClient.getProcessCpuTime();
-          long currCPUTime = 0;
-          currCPUTime = updatedClient.getProcessCpuTime();
+          long lastCPUTime = existingClient.getProcessCpuTime();
+          long currCPUTime = updatedClient.getProcessCpuTime();
 
-          double newCPUTime = (double) (currCPUTime - lastCPUTime) / (elapsedTime * 1000000000);
+          double newCPUTime =
+              (double) (((currCPUTime - lastCPUTime) / elapsedTime) / 1_000_000_000L);
 
           double newCPUUsage = 0;
           int availableCpus = updatedClient.getCpus();


Mime
View raw message