[
https://issues.jboss.org/browse/JBRULES-2912?page=com.atlassian.jira.plug...
]
Geoffrey De Smet edited comment on JBRULES-2912 at 3/2/11 2:47 AM:
-------------------------------------------------------------------
A night sleep brings wisdom:
I fixed it like this now:
if (timeMillisSpend == 0L) {
// Avoid divide by zero exception on a fast CPU
timeMillisSpend = 1L;
}
long averageCalculateCountPerSecond = localSearchSolverScope.getCalculateCount() *
1000L / timeMillisSpend;
If it does a 77 calculations in 0 millisecond, we presume it took 1 millisecond, which
makes 77000 calculations per second on average.
Note: some OS's round their system.millis to 15 ms (most notably windows XP), so I
wouldn't thrust the average calculations per second on any program that run less then
2 minutes.
was (Author: ge0ffrey):
A night sleep brings wisdom:
I fixed it like this now:
if (timeMillisSpend == 0L) {
// Avoid divide by zero exception on a fast CPU
timeMillisSpend = 1L;
}
long averageCalculateCountPerSecond = localSearchSolverScope.getCalculateCount() *
1000L / timeMillisSpend;
If it does a 77 calculations in 0 millisecond, we presume it took 1 millisecond, which
makes 77000 calculations per second on average.
Note: some OS's round their system.millis to 15 ms (most notably winblows XP), so I
wouldn't thrust the average calculations per second on any program that run less then
2 minutes.
Planner: Divide by zero exception on timeMillisSpend on a fast
computer
-----------------------------------------------------------------------
Key: JBRULES-2912
URL:
https://issues.jboss.org/browse/JBRULES-2912
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-planner
Affects Versions: 5.1.1.FINAL
Environment: Windows, Intel desktop-class, Java6 (bug is not
environment-specific)
Reporter: David Faulkner
Assignee: Geoffrey De Smet
Labels: bug
Fix For: 5.2.0.M2
In org.drools.planner.core.localsearch.DefaultLocalSearchSolver::solvingEnded, there is
potentially a divide by zero that occurs on the line:
long averageCalculateCountPerSecond = localSearchSolverScope.getCalculateCount() * 1000L
/ timeMillisSpend;
if timeMillisSpend is zero. Although in theory the likelihood of this occurring in
practically nothing, we have actually seen it occur on a POC project with long running
Planner jobs. An appropriate guard should be added to this calculation to ensure that this
error cannot occur.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira