From e7d5dae5af7214f7f8dac39e8d081ad6c4533d20 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 23 Aug 2018 10:10:44 +0500 Subject: Make accumulators nullable --- src/org/traccar/database/DeviceManager.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/database') diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index c32aca6f9..bc8894743 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -354,8 +354,12 @@ public class DeviceManager extends BaseObjectManager implements Identity public void resetDeviceAccumulators(DeviceAccumulators deviceAccumulators) throws SQLException { Position last = positions.get(deviceAccumulators.getDeviceId()); if (last != null) { - last.getAttributes().put(Position.KEY_TOTAL_DISTANCE, deviceAccumulators.getTotalDistance()); - last.getAttributes().put(Position.KEY_HOURS, deviceAccumulators.getHours()); + if (deviceAccumulators.getTotalDistance() != null) { + last.getAttributes().put(Position.KEY_TOTAL_DISTANCE, deviceAccumulators.getTotalDistance()); + } + if (deviceAccumulators.getHours() != null) { + last.getAttributes().put(Position.KEY_HOURS, deviceAccumulators.getHours()); + } getDataManager().addObject(last); updateLatestPosition(last); } else { -- cgit v1.2.3