RFR: 8336240: Test com/sun/crypto/provider/Cipher/DES/PerformanceTest.java fails with java.lang.ArithmeticException
Fernando Guallini
fguallini at openjdk.org
Thu Jul 11 15:46:05 UTC 2024
The manual test Cipher/DES/PerformanceTest.java fails with ArithmeticException due to potential division by zero. The issue arises when calculating the elapsed time using end - start, which could result in zero milliseconds if start and end are identical due to the high speed of execution. This leads to a division error in the following code snippet:
start = System.currentTimeMillis();
end = System.currentTimeMillis();
int speed = (int)((data.length * count)/(end - start));
The fix is to provide a default value in case _end_ is not higher than _start_.
-------------
Commit messages:
- remove unused imports
- tiny refactor
- avoid dividing by zero
Changes: https://git.openjdk.org/jdk/pull/20135/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20135&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8336240
Stats: 7 lines in 2 files changed: 2 ins; 3 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/20135.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20135/head:pull/20135
PR: https://git.openjdk.org/jdk/pull/20135
More information about the security-dev
mailing list