Issue #1998 fixed NPE in PointDataPluginDao

StorageStatus was not being checked after operation


Former-commit-id: 82736d581767831f426a17b0ee9d264fdda7dd64
This commit is contained in:
Brian Clements 2014-01-09 14:02:52 -06:00
parent c8cfc788f3
commit 1e6ae5a98e
2 changed files with 14 additions and 6 deletions

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.common.datastorage; package com.raytheon.uf.common.datastorage;
import com.raytheon.uf.common.datastorage.IDataStore.StoreOp; import com.raytheon.uf.common.datastorage.IDataStore.StoreOp;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@ -36,6 +35,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 30, 2008 chammack Initial creation * Dec 30, 2008 chammack Initial creation
* Jan 09, 2014 1998 bclement added hasExceptions method, removed ISerializableObject
* *
* </pre> * </pre>
* *
@ -43,7 +43,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* @version 1.0 * @version 1.0
*/ */
@DynamicSerialize @DynamicSerialize
public class StorageStatus implements ISerializableObject { public class StorageStatus {
private StorageException[] exceptions; private StorageException[] exceptions;
@ -104,4 +104,11 @@ public class StorageStatus implements ISerializableObject {
this.indexOfAppend = indexOfAppend; this.indexOfAppend = indexOfAppend;
} }
/**
* @return true if exceptions field is populated
*/
public boolean hasExceptions() {
return exceptions != null && exceptions.length > 0;
}
} }

View file

@ -75,6 +75,7 @@ import com.raytheon.uf.edex.database.plugin.PluginDao;
* Apr 29, 2013 1861 bkowal Refactor hdf5 filename generation during reads * Apr 29, 2013 1861 bkowal Refactor hdf5 filename generation during reads
* into its own method so modelsounding dao can * into its own method so modelsounding dao can
* override it. * override it.
* Jan 09, 2014 1998 bclement fixed NPE in persistToHDF5 when store failed
* *
* </pre> * </pre>
* *
@ -196,7 +197,8 @@ public abstract class PointDataPluginDao<T extends PluginDataObject> extends
try { try {
StorageStatus ss = ds.store(StoreOp.APPEND); StorageStatus ss = ds.store(StoreOp.APPEND);
if (ss.getOperationPerformed() == StoreOp.APPEND) { if (!ss.hasExceptions()
&& ss.getOperationPerformed() == StoreOp.APPEND) {
// increment the indices // increment the indices
List<PointDataView> views = containerMap.get(container); List<PointDataView> views = containerMap.get(container);
int idx = (int) ss.getIndexOfAppend()[0]; int idx = (int) ss.getIndexOfAppend()[0];
@ -211,9 +213,8 @@ public abstract class PointDataPluginDao<T extends PluginDataObject> extends
StorageStatus aggregatedStatus = new StorageStatus(); StorageStatus aggregatedStatus = new StorageStatus();
List<StorageException> se = new ArrayList<StorageException>(); List<StorageException> se = new ArrayList<StorageException>();
for (StorageStatus ss : ssList) { for (StorageStatus ss : ssList) {
StorageException[] seArr = ss.getExceptions(); if (ss.hasExceptions()) {
if (seArr != null) { se.addAll(Arrays.asList(ss.getExceptions()));
se.addAll(Arrays.asList(seArr));
} }
} }