OpenRocket Version: 1.1.9
I used a program called findBugs to look for potential bugs in the openRocket program. FindBugs looks for bugs in Java programs. It is based on the concept of bug patterns. A bug pattern is a code idiom that is often an error. Bug patterns arise for a variety of reasons:
Difficult language features
Misunderstood API methods
Misunderstood invariants when code is modified during maintenance
Garden variety mistakes: typos, use of the wrong boolean operator
Bug: Random object created and used only once in new net.sf.openrocket.simulation.SimulationOptions(Rocket)
private int randomSeed = new Random().nextInt();
and
public void randomizeSeed() {
this.randomSeed = new Random().nextInt();
//fireChangeEvent();
}
This code creates a java.util.Random object, uses it to generate one random number, and then discards the Random object. This produces mediocre quality random numbers and is inefficient. If possible, rewrite the code so that the Random objects is created once and saved, and each time a new random number is required.
Corrected by placing a Random object named randomObject at the top of the file and changed the randomizeSeed() method to use the object instead like so:
public void randomizeSeed() {
this.randomSeed = randomObject.nextInt();
// fireChangeEvent();
}