Repository: storm
Updated Branches:
  refs/heads/0.10.x-branch 53d04359f -> 4be3642eb


STORM-1108: Fix NPE in simulated time.


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

Branch: refs/heads/0.10.x-branch
Commit: a1649c5485f14fa94d1e80bd1f212a3e165afdc8
Parents: 53d0435
Author: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Authored: Wed Oct 14 13:33:27 2015 -0500
Committer: Jungtaek Lim <kabh...@gmail.com>
Committed: Fri Oct 16 08:59:06 2015 +0900

----------------------------------------------------------------------
 storm-core/src/jvm/backtype/storm/utils/Time.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/a1649c54/storm-core/src/jvm/backtype/storm/utils/Time.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/utils/Time.java 
b/storm-core/src/jvm/backtype/storm/utils/Time.java
index 50a79fd..6af7185 100644
--- a/storm-core/src/jvm/backtype/storm/utils/Time.java
+++ b/storm-core/src/jvm/backtype/storm/utils/Time.java
@@ -58,14 +58,24 @@ public class Time {
         if(simulating.get()) {
             try {
                 synchronized(sleepTimesLock) {
+                    if (threadSleepTimes == null) {
+                        LOG.debug("{} is still sleeping after simulated time 
disabled.", Thread.currentThread(), new RuntimeException("STACK TRACE"));
+                        throw new InterruptedException();
+                    }
                     threadSleepTimes.put(Thread.currentThread(), new 
AtomicLong(targetTimeMs));
                 }
                 while(simulatedCurrTimeMs.get() < targetTimeMs) {
+                    synchronized(sleepTimesLock) {
+                        if (threadSleepTimes == null) {
+                            LOG.debug("{} is still sleeping after simulated 
time disabled.", Thread.currentThread(), new RuntimeException("STACK TRACE"));
+                            throw new InterruptedException();
+                        }
+                    }
                     Thread.sleep(10);
                 }
             } finally {
                 synchronized(sleepTimesLock) {
-                    if (simulating.get()) {
+                    if (simulating.get() && threadSleepTimes != null) {
                         threadSleepTimes.remove(Thread.currentThread());
                     }
                 }

Reply via email to