Kaydet (Commit) e61c4b5f authored tarafından Robert Antoni Buj i Gelonch's avatar Robert Antoni Buj i Gelonch Kaydeden (comit) Noel Grandin

java: prevent overflow by using 'long int' arithmetic in multiplication

Change-Id: I8dda8f4621f265208c713c9edcfe725f1c9c5998
Reviewed-on: https://gerrit.libreoffice.org/12001Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst f824b1b5
...@@ -318,7 +318,7 @@ public class LocalOfficeConnection ...@@ -318,7 +318,7 @@ public class LocalOfficeConnection
aSOffice.startupService(); aSOffice.startupService();
// wait until soffice is started // wait until soffice is started
long nMaxMillis = System.currentTimeMillis() + 1000*aSOffice.getStartupTime(); long nMaxMillis = System.currentTimeMillis() + 1000L*aSOffice.getStartupTime();
while ( aInitialObject == null ) while ( aInitialObject == null )
{ {
try try
......
...@@ -335,7 +335,7 @@ public class TestCacheSize { ...@@ -335,7 +335,7 @@ public class TestCacheSize {
System.out.println("Total insert: " + i); System.out.println("Total insert: " + i);
System.out.println("Insert time: " + sw.elapsedTime() + " rps: " System.out.println("Insert time: " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
} }
private void fillUpMultiTable(String filler, private void fillUpMultiTable(String filler,
...@@ -388,7 +388,7 @@ public class TestCacheSize { ...@@ -388,7 +388,7 @@ public class TestCacheSize {
System.out.println("Multi Key Total insert: " + i); System.out.println("Multi Key Total insert: " + i);
System.out.println("Insert time: " + sw.elapsedTime() + " rps: " System.out.println("Insert time: " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
} }
public void tearDown() {} public void tearDown() {}
...@@ -478,7 +478,7 @@ public class TestCacheSize { ...@@ -478,7 +478,7 @@ public class TestCacheSize {
|| (slow && (i + 1) % 100 == 0)) { || (slow && (i + 1) % 100 == 0)) {
System.out.println("Select " + (i + 1) + " : " System.out.println("Select " + (i + 1) + " : "
+ sw.elapsedTime() + " rps: " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -487,7 +487,7 @@ public class TestCacheSize { ...@@ -487,7 +487,7 @@ public class TestCacheSize {
System.out.println("Select random zip " + i + " rows : " System.out.println("Select random zip " + i + " rows : "
+ sw.elapsedTime() + " rps: " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
sw.zero(); sw.zero();
try { try {
...@@ -511,7 +511,7 @@ public class TestCacheSize { ...@@ -511,7 +511,7 @@ public class TestCacheSize {
System.out.println("Select random id " + i + " rows : " System.out.println("Select random id " + i + " rows : "
+ sw.elapsedTime() + " rps: " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
sw.zero(); sw.zero();
try { try {
...@@ -535,7 +535,7 @@ public class TestCacheSize { ...@@ -535,7 +535,7 @@ public class TestCacheSize {
System.out.println("Select random zip from zip table " + i System.out.println("Select random zip from zip table " + i
+ " rows : " + sw.elapsedTime() + " rps: " + " rows : " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
} }
private void checkUpdates() { private void checkUpdates() {
...@@ -570,7 +570,7 @@ public class TestCacheSize { ...@@ -570,7 +570,7 @@ public class TestCacheSize {
System.out.println("Update with random zip " + i System.out.println("Update with random zip " + i
+ " UPDATE commands, " + count + " rows : " + " UPDATE commands, " + count + " rows : "
+ sw.elapsedTime() + " rps: " + sw.elapsedTime() + " rps: "
+ (count * 1000 / (sw.elapsedTime() + 1))); + (1000L * count / (sw.elapsedTime() + 1)));
sw.zero(); sw.zero();
try { try {
...@@ -588,7 +588,7 @@ public class TestCacheSize { ...@@ -588,7 +588,7 @@ public class TestCacheSize {
|| (slow && (i + 1) % 100 == 0)) { || (slow && (i + 1) % 100 == 0)) {
System.out.println("Update " + (i + 1) + " : " System.out.println("Update " + (i + 1) + " : "
+ sw.elapsedTime() + " rps: " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -597,6 +597,6 @@ public class TestCacheSize { ...@@ -597,6 +597,6 @@ public class TestCacheSize {
System.out.println("Update with random id " + i + " rows : " System.out.println("Update with random id " + i + " rows : "
+ sw.elapsedTime() + " rps: " + sw.elapsedTime() + " rps: "
+ (i * 1000 / (sw.elapsedTime() + 1))); + (1000L * i / (sw.elapsedTime() + 1)));
} }
} }
...@@ -33,7 +33,7 @@ public class SimpleFileSemaphore /* extends *//* implements */ ...@@ -33,7 +33,7 @@ public class SimpleFileSemaphore /* extends *//* implements */
// wait a second here // wait a second here
try try
{ {
java.lang.Thread.sleep(_nSeconds * 1000); java.lang.Thread.sleep(1000L * _nSeconds);
} }
catch (InterruptedException e2) catch (InterruptedException e2)
{ {
......
...@@ -29,7 +29,7 @@ public class TimeHelper ...@@ -29,7 +29,7 @@ public class TimeHelper
{ {
GlobalLogWriter.get().println("Wait " + _nSeconds + " sec. Reason: " + _sReason); GlobalLogWriter.get().println("Wait " + _nSeconds + " sec. Reason: " + _sReason);
try { try {
java.lang.Thread.sleep(_nSeconds * 1000); java.lang.Thread.sleep(1000L * _nSeconds);
} catch (InterruptedException e2) {} } catch (InterruptedException e2) {}
} }
} }
...@@ -31,7 +31,7 @@ public class TimeHelper ...@@ -31,7 +31,7 @@ public class TimeHelper
{ {
GlobalLogWriter.println("Wait 0.25 * " + _nSeconds + " sec. Reason: " + _sReason); GlobalLogWriter.println("Wait 0.25 * " + _nSeconds + " sec. Reason: " + _sReason);
try { try {
java.lang.Thread.sleep(_nSeconds * 250); java.lang.Thread.sleep(250L * _nSeconds);
} catch (InterruptedException e2) {} } catch (InterruptedException e2) {}
} }
......
...@@ -264,7 +264,7 @@ public class OfficeProvider implements AppProvider ...@@ -264,7 +264,7 @@ public class OfficeProvider implements AppProvider
{ {
try try
{ {
Thread.sleep(k * 500); Thread.sleep(500L * k);
} }
catch (InterruptedException ex) catch (InterruptedException ex)
{ {
......
...@@ -446,7 +446,7 @@ public class ProcessHandler ...@@ -446,7 +446,7 @@ public class ProcessHandler
try try
{ {
Thread.sleep(1000 * counter); // 5000 Thread.sleep(1000L * counter); // 5000
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment