Skip to content

Commit

Permalink
Fix divide by null issue
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickfav committed Sep 28, 2017
1 parent b92c442 commit 31893df
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/at/favre/tools/dice/RndTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ static boolean execute(Arg arguments) {
return true;
}


private static void wrapInErrorHandling(Arg arguments, Callable r) {
try {
r.call();
} catch (Exception e) {

System.err.print("Could not create random bits.");

if (e.getMessage() != null) {
Expand All @@ -136,6 +136,7 @@ private static void wrapInErrorHandling(Arg arguments, Callable r) {
}
}


private static void fetch(final List<ServiceHandler<?>> handlers, final Arg arguments, final EntropyPool entropyPool,
final Encoder encoder, final long start) {
print("Fetch external seed: ", arguments);
Expand Down Expand Up @@ -222,13 +223,11 @@ private static void printRandoms(Arg arguments, Encoder encoder, DeterministicRa
printStream.close();
}
}


}

@NotNull
private static String getSummary(Arg arguments, long durationMs, long durationRndGen, long byteGen) {
double bandwidth = Math.round(byteGen / durationRndGen / 10.24) / 100.0;
double bandwidth = durationRndGen == 0 || byteGen == 0 ? 0 : Math.round(byteGen / durationRndGen / 10.24) / 100.0;
return System.lineSeparator() + System.lineSeparator() + "[" + getFriendlyFormattedDate() + "][" + MiscUtil.jarVersion() + "] " + byteGen + " bytes generated in " + durationMs + " ms." + (bandwidth > 0 ? " (" + bandwidth + " MB/s)" : "");
}

Expand All @@ -244,4 +243,4 @@ private static String getFriendlyFormattedDate() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
return sdf.format(new Date());
}
}
}

0 comments on commit 31893df

Please sign in to comment.