From 4e85d48409a904d370380cb48cafab258de83f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Gracia?= Date: Fri, 15 Jun 2018 10:51:58 +0200 Subject: [PATCH] Issue 85: Fixing the problem that caused NPE (wrong use of produceStats instead of consumeStats in reader and lack of null check parsing read events). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raúl Gracia --- .../pravega/turbineheatsensor/TurbineHeatSensor.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scenarios/turbine-heat-sensor/src/main/java/io/pravega/turbineheatsensor/TurbineHeatSensor.java b/scenarios/turbine-heat-sensor/src/main/java/io/pravega/turbineheatsensor/TurbineHeatSensor.java index 573811db..a7bbc20e 100644 --- a/scenarios/turbine-heat-sensor/src/main/java/io/pravega/turbineheatsensor/TurbineHeatSensor.java +++ b/scenarios/turbine-heat-sensor/src/main/java/io/pravega/turbineheatsensor/TurbineHeatSensor.java @@ -438,13 +438,16 @@ public void run() { do { try { final EventRead result = reader.readNextEvent(0); - produceStats.runAndRecordTime(() -> { - return CompletableFuture.completedFuture(null); - }, Long.parseLong(result.getEvent().split(",")[0]), 100); + if (result.getEvent() != null) { + consumeStats.runAndRecordTime(() -> { + return CompletableFuture.completedFuture(null); + }, Long.parseLong(result.getEvent().split(",")[0]), 100); + totalEvents--; + } } catch (ReinitializationRequiredException e) { e.printStackTrace(); } - } while ( totalEvents-- > 0 ); + } while (totalEvents > 0); } finally { reader.close();