Prevent null pointer exception at integration start.

Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/e6c84480
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/e6c84480
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/e6c84480

Branch: refs/heads/MATH_3_X
Commit: e6c84480c11877073bb77a74e857fcf427409155
Parents: d724f4e
Author: Luc Maisonobe <l...@apache.org>
Authored: Sun Nov 29 20:20:18 2015 +0100
Committer: Luc Maisonobe <l...@apache.org>
Committed: Sun Nov 29 20:20:18 2015 +0100

----------------------------------------------------------------------
 .../math3/ode/sampling/AbstractFieldStepInterpolator.java        | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/e6c84480/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
 
b/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
index bb3d722..6692222 100644
--- 
a/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
+++ 
b/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
@@ -160,7 +160,9 @@ public abstract class AbstractFieldStepInterpolator<T 
extends RealFieldElement<T
 
         globalCurrentState = state;
         softCurrentState   = globalCurrentState;
-        h                  = 
globalCurrentState.getTime().subtract(globalPreviousState.getTime());
+        if (globalPreviousState != null) {
+            h = 
globalCurrentState.getTime().subtract(globalPreviousState.getTime());
+        }
 
         // the step is not finalized anymore
         finalized  = false;

Reply via email to