tmf: Bug 495219: Fix NPE in checkpoint indexer seeking on disposed trace
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 2 Jun 2016 21:10:00 +0000 (17:10 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 7 Jun 2016 18:46:19 +0000 (14:46 -0400)
In BTree, if it is disposed (file is null), return -1 (insertion point
0) in the binary search. This will correspond to checkpoint 0 in the
flat array.

In FlatArray, if it is disposed (file is null) return null as checkpoint
in get(long).

In TmfCheckpointIndexer, if the returned checkpoint is null in
restoreCheckpoint(long), return the context given by the trace
implementation of seekEvent((ITmfLocation) null). It should properly
handle a disposed trace.

Change-Id: I3148d2e10118628e387d206054de55d5238a9807
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/74474
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/BTree.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/FlatArray.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/indexer/checkpoint/TmfCheckpointIndexer.java

index 32ae555876955af9c290330f747f258d866f5b6e..e3a1ad1abcb77cb0400ffb5a3388ed654310dd29 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -290,7 +290,7 @@ public class BTree extends AbstractFileCheckpointCollection {
 
     private void accept(long nodeOffset, IBTreeVisitor visitor) {
 
-        if (nodeOffset == BTreeNode.NULL_CHILD) {
+        if (nodeOffset == BTreeNode.NULL_CHILD || getRandomAccessFile() == null) {
             return;
         }
 
index a404a2c9ab0fbe49b0c55ac3c9f333e2fcc00fce..4df395d7dbf4efbdae37eb6790400201964222cf 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -90,6 +90,9 @@ public class FlatArray extends AbstractFileCheckpointCollection {
         ITmfCheckpoint checkpoint = null;
         try {
             long pos = getHeader().getSize() + fCheckpointSize * rank;
+            if (getRandomAccessFile() == null) {
+                return null;
+            }
             getRandomAccessFile().seek(pos);
             fByteBuffer.clear();
             getRandomAccessFile().read(fByteBuffer.array());
index 8e806307f16a6f4a2e8efe968972259ad5f5d03a..355f67e04125323f5b4f9be867174b42dcaba7ce 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -323,6 +323,9 @@ public class TmfCheckpointIndexer implements ITmfTraceIndexer {
                 }
                 ITmfCheckpoint checkpoint = fTraceIndex.get(index);
                 TmfCoreTracer.traceIndexer("Restored checkpoint: " + checkpoint); //$NON-NLS-1$
+                if (checkpoint == null) {
+                    return fTrace.seekEvent((ITmfLocation) null);
+                }
                 location = checkpoint.getLocation();
             }
         }
This page took 0.026332 seconds and 5 git commands to generate.