You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2015/12/15 10:06:41 UTC

svn commit: r1720095 [1/2] - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/f...

Author: mduerig
Date: Tue Dec 15 09:06:41 2015
New Revision: 1720095

URL: http://svn.apache.org/viewvc?rev=1720095&view=rev
Log:
OAK-3703: Improve handling of IOException
Throw IOException from all write methods of the segment writer

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PersistedCompactionMap.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordWriters.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBufferWriter.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/migration/DepthFirstNodeIteratorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/InitializerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CheckpointTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MapRecordTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/PartialCompactionMapTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordIdMapTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordUsageAnalyserTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdFactoryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableBenchmark.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentParserTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/file/TarWriterTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RefreshOnGCTest.java
    jackrabbit/oak/trunk/oak-tarmk-standby/src/main/java/org/apache/jackrabbit/oak/plugins/segment/standby/store/StandbyStore.java
    jackrabbit/oak/trunk/oak-tarmk-standby/src/test/java/org/apache/jackrabbit/oak/plugins/segment/DebugSegmentStore.java
    jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/AbstractRepositoryUpgradeTest.java
    jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/nodestate/FilteringNodeStateTest.java
    jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/nodestate/NodeStateCopierTest.java
    jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/NodeStateTestUtils.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java Tue Dec 15 09:06:41 2015
@@ -62,7 +62,7 @@ public class FileStoreRestore {
     }
 
     private static void restore(NodeState source, NodeStore store,
-            SegmentStore restore) throws CommitFailedException {
+            SegmentStore restore) throws CommitFailedException, IOException {
         long s = System.currentTimeMillis();
         NodeState current = store.getRoot();
         RestoreCompactor compactor = new RestoreCompactor(restore);
@@ -78,7 +78,7 @@ public class FileStoreRestore {
         }
 
         @Override
-        protected SegmentNodeBuilder process(NodeState before, NodeState after, NodeState onto) {
+        protected SegmentNodeBuilder process(NodeState before, NodeState after, NodeState onto) throws IOException {
             return super.process(before, after, onto);
         }
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java Tue Dec 15 09:06:41 2015
@@ -21,6 +21,7 @@ import static com.google.common.collect.
 import static org.apache.jackrabbit.oak.api.Type.BINARIES;
 import static org.apache.jackrabbit.oak.api.Type.BINARY;
 import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -38,7 +39,6 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.IOUtils;
 import org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState;
-import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
 import org.apache.jackrabbit.oak.plugins.memory.MultiBinaryPropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.segment.compaction.CompactionStrategy;
@@ -46,7 +46,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.state.ApplyDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -129,9 +128,9 @@ public class Compactor {
         this.cancel = cancel;
     }
 
-    protected SegmentNodeBuilder process(NodeState before, NodeState after, NodeState onto) {
+    protected SegmentNodeBuilder process(NodeState before, NodeState after, NodeState onto) throws IOException {
         SegmentNodeBuilder builder = new SegmentNodeBuilder(writer.writeNode(onto), writer);
-        after.compareAgainstBaseState(before, newCompactionDiff(builder));
+        new CompactDiff(builder).diff(before, after);
         return builder;
     }
 
@@ -145,7 +144,7 @@ public class Compactor {
      * @param after   the after state
      * @return  the compacted state
      */
-    public SegmentNodeState compact(NodeState before, NodeState after) {
+    public SegmentNodeState compact(NodeState before, NodeState after) throws IOException {
         progress.start();
         SegmentNodeState compacted = process(before, after, before).getNodeState();
         writer.flush();
@@ -161,7 +160,7 @@ public class Compactor {
      * @param onto    the onto state
      * @return  the compacted state
      */
-    public SegmentNodeState compact(NodeState before, NodeState after, NodeState onto) {
+    public SegmentNodeState compact(NodeState before, NodeState after, NodeState onto) throws IOException {
         progress.start();
         SegmentNodeState compacted = process(before, after, onto).getNodeState();
         writer.flush();
@@ -175,6 +174,7 @@ public class Compactor {
     }
 
     private class CompactDiff extends ApplyDiff {
+        private IOException exception;
 
         /**
          * Current processed path, or null if the trace log is not enabled at
@@ -201,6 +201,14 @@ public class Compactor {
             }
         }
 
+        boolean diff(NodeState before, NodeState after) throws IOException {
+            boolean success = after.compareAgainstBaseState(before, new CancelableDiff(this, cancel));
+            if (exception != null) {
+                throw new IOException(exception);
+            }
+            return success;
+        }
+
         @Override
         public boolean propertyAdded(PropertyState after) {
             if (path != null) {
@@ -236,19 +244,21 @@ public class Compactor {
             }
 
             progress.onNode();
-            NodeBuilder child = EmptyNodeState.EMPTY_NODE.builder();
-            boolean success = EmptyNodeState.compareAgainstEmptyState(after,
-                    newCompactionDiff(child, path, name));
-
-            if (success) {
-                SegmentNodeState state = writer.writeNode(child.getNodeState());
-                builder.setChildNode(name, state);
-                if (id != null && includeInMap.apply(state)) {
-                    map.put(id, state.getRecordId());
+            try {
+                NodeBuilder child = EMPTY_NODE.builder();
+                boolean success =  new CompactDiff(child, path, name).diff(EMPTY_NODE, after);
+                if (success) {
+                    SegmentNodeState state = writer.writeNode(child.getNodeState());
+                    builder.setChildNode(name, state);
+                    if (id != null && includeInMap.apply(state)) {
+                        map.put(id, state.getRecordId());
+                    }
                 }
+                return success;
+            } catch (IOException e) {
+                exception = e;
+                return false;
             }
-
-            return success;
         }
 
         @Override
@@ -269,29 +279,21 @@ public class Compactor {
             }
 
             progress.onNode();
-            NodeBuilder child = builder.getChildNode(name);
-            boolean success = after.compareAgainstBaseState(before,
-                    newCompactionDiff(child, path, name));
-
-            if (success) {
-                RecordId compactedId = writer.writeNode(child.getNodeState())
-                        .getRecordId();
-                if (id != null) {
-                    map.put(id, compactedId);
+            try {
+                NodeBuilder child = builder.getChildNode(name);
+                boolean success = new CompactDiff(child, path, name).diff(before, after);
+                if (success) {
+                    RecordId compactedId = writer.writeNode(child.getNodeState()).getRecordId();
+                    if (id != null) {
+                        map.put(id, compactedId);
+                    }
                 }
+                return success;
+            } catch (IOException e) {
+                exception = e;
+                return false;
             }
-
-            return success;
         }
-
-    }
-
-    private NodeStateDiff newCompactionDiff(NodeBuilder builder) {
-        return new CancelableDiff(new CompactDiff(builder), cancel);
-    }
-
-    private NodeStateDiff newCompactionDiff(NodeBuilder child, String path, String name) {
-        return new CancelableDiff(new CompactDiff(child, path, name), cancel);
     }
 
     private PropertyState compact(PropertyState property) {
@@ -381,8 +383,7 @@ public class Compactor {
         }
     }
 
-    private class ProgressTracker {
-
+    private static class ProgressTracker {
         private final long logAt = Long.getLong("compaction-progress-log",
                 150000);
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PersistedCompactionMap.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PersistedCompactionMap.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PersistedCompactionMap.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PersistedCompactionMap.java Tue Dec 15 09:06:41 2015
@@ -23,6 +23,7 @@ import static com.google.common.collect.
 import static java.lang.Integer.getInteger;
 import static org.apache.jackrabbit.oak.plugins.segment.Segment.encode;
 
+import java.io.IOException;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -35,6 +36,8 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A {@code PartialCompactionMap} implementation persisting its entries
@@ -43,6 +46,7 @@ import org.apache.jackrabbit.oak.plugins
  * TODO In theory we could also compact the compaction map. Is there any need to do so?
  */
 public class PersistedCompactionMap implements PartialCompactionMap {
+    private static final Logger LOG = LoggerFactory.getLogger(PersistedCompactionMap.class);
 
     /**
      * Rough estimate of the number of bytes of disk space of a map entry.
@@ -174,66 +178,71 @@ public class PersistedCompactionMap impl
     }
 
     private void compress(@Nonnull Set<UUID> removed) {
-        if (recent.isEmpty() && removed.isEmpty()) {
-            return;
-        }
+        try {
+            if (recent.isEmpty() && removed.isEmpty()) {
+                return;
+            }
 
-        SegmentWriter writer = null;
-        Map<String, RecordId> segmentIdMap = newHashMap();
-        for (Entry<UUID, RecordIdMap> recentEntry : recent.entrySet()) {
-            UUID uuid = recentEntry.getKey();
-            RecordIdMap newSegment = recentEntry.getValue();
+            SegmentWriter writer = null;
+            Map<String, RecordId> segmentIdMap = newHashMap();
+            for (Entry<UUID, RecordIdMap> recentEntry : recent.entrySet()) {
+                UUID uuid = recentEntry.getKey();
+                RecordIdMap newSegment = recentEntry.getValue();
 
-            if (removed.contains(uuid)) {
-                continue;
-            }
+                if (removed.contains(uuid)) {
+                    continue;
+                }
 
-            MapRecord base;
-            MapEntry baseEntry = entries == null ? null : entries.getEntry(uuid.toString());
-            base = baseEntry == null ? null : new MapRecord(baseEntry.getValue());
+                MapRecord base;
+                MapEntry baseEntry = entries == null ? null : entries.getEntry(uuid.toString());
+                base = baseEntry == null ? null : new MapRecord(baseEntry.getValue());
 
-            if (writer == null) {
-                writer = store.createSegmentWriter(createWid());
-            }
+                if (writer == null) {
+                    writer = store.createSegmentWriter(createWid());
+                }
 
-            Map<String, RecordId> offsetMap = newHashMap();
-            for (int k = 0; k < newSegment.size(); k++) {
-                offsetMap.put(String.valueOf(newSegment.getKey(k)),
+                Map<String, RecordId> offsetMap = newHashMap();
+                for (int k = 0; k < newSegment.size(); k++) {
+                    offsetMap.put(String.valueOf(newSegment.getKey(k)),
                         writer.writeString(newSegment.getRecordId(k).toString10()));
+                }
+                RecordId newEntryId = writer.writeMap(base, offsetMap).getRecordId();
+                segmentIdMap.put(uuid.toString(), newEntryId);
+                recordCount += offsetMap.size();
             }
-            RecordId newEntryId = writer.writeMap(base, offsetMap).getRecordId();
-            segmentIdMap.put(uuid.toString(), newEntryId);
-            recordCount += offsetMap.size();
-        }
 
-        if (entries != null) {
-            for (UUID uuid : removed) {
-                MapEntry toRemove = entries.getEntry(uuid.toString());
-                if (toRemove != null) {
-                    segmentIdMap.put(uuid.toString(), null);
-                    recordCount -= new MapRecord(toRemove.getValue()).size();
+            if (entries != null) {
+                for (UUID uuid : removed) {
+                    MapEntry toRemove = entries.getEntry(uuid.toString());
+                    if (toRemove != null) {
+                        segmentIdMap.put(uuid.toString(), null);
+                        recordCount -= new MapRecord(toRemove.getValue()).size();
+                    }
                 }
             }
-        }
 
-        if (!segmentIdMap.isEmpty()) {
-            if (writer == null) {
-                writer = store.createSegmentWriter(createWid());
-            }
+            if (!segmentIdMap.isEmpty()) {
+                if (writer == null) {
+                    writer = store.createSegmentWriter(createWid());
+                }
 
-            RecordId previousBaseId = entries == null ? null : entries.getRecordId();
-            entries = writer.writeMap(entries, segmentIdMap);
-            entries.getSegment().getSegmentId().pin();
-            String mapInfo = PERSISTED_COMPACTION_MAP + '{' +
+                RecordId previousBaseId = entries == null ? null : entries.getRecordId();
+                entries = writer.writeMap(entries, segmentIdMap);
+                entries.getSegment().getSegmentId().pin();
+                String mapInfo = PERSISTED_COMPACTION_MAP + '{' +
                     "id=" + entries.getRecordId() +
                     ", baseId=" + previousBaseId + '}';
-            writer.writeString(mapInfo);
-            writer.flush();
-        }
+                writer.writeString(mapInfo);
+                writer.flush();
+            }
 
-        recent.clear();
-        if (recordCount == 0) {
-            entries = null;
+            recent.clear();
+            if (recordCount == 0) {
+                entries = null;
+            }
+        } catch (IOException e) {
+            LOG.error("Error compression compaction map", e);
+            throw new IllegalStateException("Unexpected IOException", e);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordWriters.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordWriters.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordWriters.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordWriters.java Tue Dec 15 09:06:41 2015
@@ -32,6 +32,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.segment.Segment.SMALL_LIMIT;
 import static org.apache.jackrabbit.oak.plugins.segment.SegmentVersion.V_11;
 
+import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -62,7 +63,7 @@ final class RecordWriters {
             this(type, size, Collections.<RecordId> emptyList());
         }
 
-        public final T write(SegmentBufferWriter writer) {
+        public final T write(SegmentBufferWriter writer) throws IOException {
             RecordId id = writer.prepare(type, size, ids);
             return writeRecordContent(id, writer);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBufferWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBufferWriter.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBufferWriter.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBufferWriter.java Tue Dec 15 09:06:41 2015
@@ -35,6 +35,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.segment.Segment.SEGMENT_REFERENCE_LIMIT;
 import static org.apache.jackrabbit.oak.plugins.segment.Segment.align;
 
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.HashSet;
@@ -108,7 +109,7 @@ class SegmentBufferWriter {
      */
     private int position;
 
-    public SegmentBufferWriter(SegmentStore store, SegmentVersion version, String wid) {
+    public SegmentBufferWriter(SegmentStore store, SegmentVersion version, String wid) throws IOException {
         this.store = store;
         this.version = version;
         this.wid = (wid == null
@@ -135,7 +136,7 @@ class SegmentBufferWriter {
      * The segment meta data is guaranteed to be the first string record in a segment.
      * @param wid  the writer id
      */
-    private void newSegment(String wid) {
+    private void newSegment(String wid) throws IOException {
         this.segment = new Segment(tracker, buffer);
         String metaInfo = "{\"wid\":\"" + wid + '"' +
                 ",\"sno\":" + tracker.getNextSegmentNo() +
@@ -230,7 +231,7 @@ class SegmentBufferWriter {
      * store. This is done automatically (called from prepare) when there is not
      * enough space for a record. It can also be called explicitly.
      */
-    public void flush() {
+    public void flush() throws IOException {
         if (length > 0) {
             int refcount = segment.getRefCount();
 
@@ -324,7 +325,7 @@ class SegmentBufferWriter {
      * @param ids the record ids
      * @return a new record id
      */
-    public RecordId prepare(RecordType type, int size, Collection<RecordId> ids) {
+    public RecordId prepare(RecordType type, int size, Collection<RecordId> ids) throws IOException {
         checkArgument(size >= 0);
         checkNotNull(ids);
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java Tue Dec 15 09:06:41 2015
@@ -24,6 +24,8 @@ import javax.annotation.Nonnull;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A node builder that keeps track of the number of updates
@@ -32,6 +34,7 @@ import org.apache.jackrabbit.oak.spi.sta
  * and that might persist the changes (if the segment is flushed).
  */
 public class SegmentNodeBuilder extends MemoryNodeBuilder {
+    private static final Logger LOG = LoggerFactory.getLogger(SegmentNodeBuilder.class);
 
     /**
      * Number of content updates that need to happen before the updates
@@ -103,13 +106,18 @@ public class SegmentNodeBuilder extends
     @Nonnull
     @Override
     public SegmentNodeState getNodeState() {
-        NodeState state = super.getNodeState();
-        SegmentNodeState sstate = writer.writeNode(state);
-        if (state != sstate) {
-            set(sstate);
-            updateCount = 0;
+        try {
+            NodeState state = super.getNodeState();
+            SegmentNodeState sstate = writer.writeNode(state);
+            if (state != sstate) {
+                set(sstate);
+                updateCount = 0;
+            }
+            return sstate;
+        } catch (IOException e) {
+            LOG.error("Error flushing changes", e);
+            throw new IllegalStateException("Unexpected IOException", e);
         }
-        return sstate;
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java Tue Dec 15 09:06:41 2015
@@ -104,7 +104,7 @@ public class SegmentNodeStore implements
     /**
      * Flag controlling the commit lock fairness
      */
-    private boolean commitFairLock = Boolean
+    private final boolean commitFairLock = Boolean
             .getBoolean("oak.segmentNodeStore.commitFairLock");
 
     @Nonnull
@@ -132,7 +132,7 @@ public class SegmentNodeStore implements
         this.changeDispatcher = new ChangeDispatcher(getRoot());
     }
 
-    public SegmentNodeStore() {
+    public SegmentNodeStore() throws IOException {
         this(new MemoryStore());
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java Tue Dec 15 09:06:41 2015
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import java.io.IOException;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
@@ -64,7 +66,7 @@ public interface SegmentStore {
      * @param offset start offset within the byte buffer
      * @param length length of the segment
      */
-    void writeSegment(SegmentId id, byte[] bytes, int offset, int length);
+    void writeSegment(SegmentId id, byte[] bytes, int offset, int length) throws IOException;
 
     void close();
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java Tue Dec 15 09:06:41 2015
@@ -20,6 +20,7 @@ import static com.google.common.collect.
 import static com.google.common.collect.Sets.newHashSet;
 import static java.lang.Boolean.getBoolean;
 
+import java.io.IOException;
 import java.security.SecureRandom;
 import java.util.Queue;
 import java.util.Set;
@@ -271,22 +272,27 @@ public class SegmentTracker {
      * running.
      */
     public void collectBlobReferences(ReferenceCollector collector) {
-        Set<SegmentId> processed = newHashSet();
-        Queue<SegmentId> queue = newArrayDeque(getReferencedSegmentIds());
-        writer.flush(); // force the current segment to have root record info
-        while (!queue.isEmpty()) {
-            SegmentId id = queue.remove();
-            if (id.isDataSegmentId() && processed.add(id)) {
-                Segment segment = id.getSegment();
-
-                segment.collectBlobReferences(collector);
-
-                for (SegmentId refid : segment.getReferencedIds()) {
-                    if (refid.isDataSegmentId() && !processed.contains(refid)) {
-                        queue.add(refid);
+        try {
+            Set<SegmentId> processed = newHashSet();
+            Queue<SegmentId> queue = newArrayDeque(getReferencedSegmentIds());
+            writer.flush(); // force the current segment to have root record info
+            while (!queue.isEmpty()) {
+                SegmentId id = queue.remove();
+                if (id.isDataSegmentId() && processed.add(id)) {
+                    Segment segment = id.getSegment();
+
+                    segment.collectBlobReferences(collector);
+
+                    for (SegmentId refid : segment.getReferencedIds()) {
+                        if (refid.isDataSegmentId() && !processed.contains(refid)) {
+                            queue.add(refid);
+                        }
                     }
                 }
             }
+        } catch (IOException e) {
+            log.error("Error while flushing pending segments", e);
+            throw new IllegalStateException("Unexpected IOException", e);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java Tue Dec 15 09:06:41 2015
@@ -140,7 +140,7 @@ public class SegmentWriter {
         this.wid = wid;
     }
 
-    public void flush() {
+    public void flush() throws IOException {
         segmentBufferWriterPool.flush();
     }
 
@@ -148,7 +148,7 @@ public class SegmentWriter {
         records.clear();
     }
 
-    MapRecord writeMap(MapRecord base, Map<String, RecordId> changes) {
+    MapRecord writeMap(MapRecord base, Map<String, RecordId> changes) throws IOException {
         if (base != null && base.isDiff()) {
             Segment segment = base.getSegment();
             RecordId key = segment.readRecordId(base.getOffset(8));
@@ -198,7 +198,7 @@ public class SegmentWriter {
         return writeMapBucket(base, entries, 0);
     }
 
-    private MapRecord writeMapLeaf(int level, Collection<MapEntry> entries) {
+    private MapRecord writeMapLeaf(int level, Collection<MapEntry> entries) throws IOException {
         checkNotNull(entries);
         int size = entries.size();
         checkElementIndex(size, MapRecord.MAX_SIZE);
@@ -207,7 +207,7 @@ public class SegmentWriter {
         return writeRecord(newMapLeafWriter(level, entries));
     }
 
-    private MapRecord writeMapBranch(int level, int size, MapRecord[] buckets) {
+    private MapRecord writeMapBranch(int level, int size, MapRecord[] buckets) throws IOException {
         int bitmap = 0;
         List<RecordId> bucketIds = newArrayListWithCapacity(buckets.length);
         for (int i = 0; i < buckets.length; i++) {
@@ -219,7 +219,7 @@ public class SegmentWriter {
         return writeRecord(newMapBranchWriter(level, size, bitmap, bucketIds));
     }
 
-    private MapRecord writeMapBucket(MapRecord base, Collection<MapEntry> entries, int level) {
+    private MapRecord writeMapBucket(MapRecord base, Collection<MapEntry> entries, int level) throws IOException {
         // when no changed entries, return the base map (if any) as-is
         if (entries == null || entries.isEmpty()) {
             if (base != null) {
@@ -309,7 +309,7 @@ public class SegmentWriter {
      * @param list list of record identifiers
      * @return list record identifier
      */
-    public RecordId writeList(List<RecordId> list) {
+    public RecordId writeList(List<RecordId> list) throws IOException {
         checkNotNull(list);
         checkArgument(!list.isEmpty());
         List<RecordId> thisLevel = list;
@@ -328,7 +328,7 @@ public class SegmentWriter {
         return thisLevel.iterator().next();
     }
 
-    private RecordId writeListBucket(List<RecordId> bucket) {
+    private RecordId writeListBucket(List<RecordId> bucket) throws IOException {
         checkArgument(bucket.size() > 1);
         return writeRecord(newListBucketWriter(bucket));
     }
@@ -352,12 +352,12 @@ public class SegmentWriter {
         return buckets;
     }
 
-    private RecordId writeValueRecord(long length, RecordId blocks) {
+    private RecordId writeValueRecord(long length, RecordId blocks) throws IOException {
         long len = (length - Segment.MEDIUM_LIMIT) | (0x3L << 62);
         return writeRecord(newValueWriter(blocks, len));
     }
 
-    private RecordId writeValueRecord(int length, byte[] data) {
+    private RecordId writeValueRecord(int length, byte[] data) throws IOException {
         checkArgument(length < Segment.MEDIUM_LIMIT);
         return writeRecord(newValueWriter(length, data));
     }
@@ -368,7 +368,7 @@ public class SegmentWriter {
      * @param string string to be written
      * @return value record identifier
      */
-    public RecordId writeString(String string) {
+    public RecordId writeString(String string) throws IOException {
         RecordId id = records.get(string);
         if (id != null) {
             return id; // shortcut if the same string was recently stored
@@ -435,7 +435,7 @@ public class SegmentWriter {
      * @return Record ID pointing to the written blob ID.
      * @see Segment#BLOB_ID_SMALL_LIMIT
      */
-    private RecordId writeBlobId(String blobId) {
+    private RecordId writeBlobId(String blobId) throws IOException {
         byte[] data = blobId.getBytes(UTF_8);
         if (data.length < Segment.BLOB_ID_SMALL_LIMIT) {
             return writeRecord(newBlobIdWriter(data));
@@ -452,18 +452,18 @@ public class SegmentWriter {
      * @param length number of bytes to write
      * @return block record identifier
      */
-    RecordId writeBlock(byte[] bytes, int offset, int length) {
+    RecordId writeBlock(byte[] bytes, int offset, int length) throws IOException {
         checkNotNull(bytes);
         checkPositionIndexes(offset, offset + length, bytes.length);
         return writeRecord(newBlockWriter(bytes, offset, length));
     }
 
-    SegmentBlob writeExternalBlob(String blobId) {
+    SegmentBlob writeExternalBlob(String blobId) throws IOException {
         RecordId id = writeBlobId(blobId);
         return new SegmentBlob(id);
     }
 
-    SegmentBlob writeLargeBlob(long length, List<RecordId> list) {
+    SegmentBlob writeLargeBlob(long length, List<RecordId> list) throws IOException {
         RecordId id = writeValueRecord(length, writeList(list));
         return new SegmentBlob(id);
     }
@@ -530,12 +530,12 @@ public class SegmentWriter {
         return writeValueRecord(length, writeList(blockIds));
     }
 
-    public RecordId writeProperty(PropertyState state) {
+    public RecordId writeProperty(PropertyState state) throws IOException {
         Map<String, RecordId> previousValues = emptyMap();
         return writeProperty(state, previousValues);
     }
 
-    private RecordId writeProperty(PropertyState state, Map<String, RecordId> previousValues) {
+    private RecordId writeProperty(PropertyState state, Map<String, RecordId> previousValues) throws IOException {
         Type<?> type = state.getType();
         int count = state.count();
 
@@ -568,7 +568,7 @@ public class SegmentWriter {
         }
     }
 
-    public RecordId writeTemplate(Template template) {
+    public RecordId writeTemplate(Template template) throws IOException {
         checkNotNull(template);
 
         RecordId id = records.get(template);
@@ -646,7 +646,7 @@ public class SegmentWriter {
         return tid;
     }
 
-    public SegmentNodeState writeNode(NodeState state) {
+    public SegmentNodeState writeNode(NodeState state) throws IOException {
         if (state instanceof SegmentNodeState) {
             SegmentNodeState sns = uncompact((SegmentNodeState) state);
             if (sns != state || store.containsSegment(
@@ -685,31 +685,15 @@ public class SegmentWriter {
         String childName = template.getChildName();
         if (childName == Template.MANY_CHILD_NODES) {
             MapRecord base;
-            final Map<String, RecordId> childNodes = newHashMap();
+            Map<String, RecordId> childNodes;
             if (before != null
                 && before.getChildNodeCount(2) > 1
                 && after.getChildNodeCount(2) > 1) {
                 base = before.getChildNodeMap();
-                after.compareAgainstBaseState(before, new DefaultNodeStateDiff() {
-                    @Override
-                    public boolean childNodeAdded(String name, NodeState after) {
-                        childNodes.put(name, writeNode(after).getRecordId());
-                        return true;
-                    }
-                    @Override
-                    public boolean childNodeChanged(
-                        String name, NodeState before, NodeState after) {
-                        childNodes.put(name, writeNode(after).getRecordId());
-                        return true;
-                    }
-                    @Override
-                    public boolean childNodeDeleted(String name, NodeState before) {
-                        childNodes.put(name, null);
-                        return true;
-                    }
-                });
+                childNodes = new ChildNodeCollectorDiff().diff(before, after);
             } else {
                 base = null;
+                childNodes = newHashMap();
                 for (ChildNodeEntry entry : state.getChildNodeEntries()) {
                     childNodes.put(
                         entry.getName(),
@@ -779,7 +763,7 @@ public class SegmentWriter {
         }
     }
 
-    private <T> T writeRecord(RecordWriter<T> recordWriter) {
+    private <T> T writeRecord(RecordWriter<T> recordWriter) throws IOException {
         SegmentBufferWriter writer = segmentBufferWriterPool.borrowWriter(currentThread());
         try {
             return recordWriter.write(writer);
@@ -794,7 +778,7 @@ public class SegmentWriter {
 
         private short writerId = -1;
 
-        public void flush() {
+        public void flush() throws IOException {
             List<SegmentBufferWriter> toFlush = newArrayList();
             synchronized (this) {
                 toFlush.addAll(writers.values());
@@ -808,7 +792,7 @@ public class SegmentWriter {
             }
         }
 
-        public synchronized SegmentBufferWriter borrowWriter(Object key) {
+        public synchronized SegmentBufferWriter borrowWriter(Object key) throws IOException {
             SegmentBufferWriter writer = writers.remove(key);
             if (writer == null) {
                 writer = new SegmentBufferWriter(store, version, wid + "." + getWriterId());
@@ -817,7 +801,7 @@ public class SegmentWriter {
             return writer;
         }
 
-        public void returnWriter(Object key, SegmentBufferWriter writer) {
+        public void returnWriter(Object key, SegmentBufferWriter writer) throws IOException {
             if (!tryReturn(key, writer)) {
                 // Delayed flush this writer as it was borrowed while flush() was called.
                 writer.flush();
@@ -850,4 +834,46 @@ public class SegmentWriter {
         }
     }
 
+    private class ChildNodeCollectorDiff extends DefaultNodeStateDiff {
+        private final Map<String, RecordId> childNodes = newHashMap();
+        private IOException exception;
+
+        @Override
+        public boolean childNodeAdded(String name, NodeState after) {
+            try {
+                childNodes.put(name, writeNode(after).getRecordId());
+            } catch (IOException e) {
+                exception = e;
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public boolean childNodeChanged(
+            String name, NodeState before, NodeState after) {
+            try {
+                childNodes.put(name, writeNode(after).getRecordId());
+            } catch (IOException e) {
+                exception = e;
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public boolean childNodeDeleted(String name, NodeState before) {
+            childNodes.put(name, null);
+            return true;
+        }
+
+        public Map<String, RecordId> diff(SegmentNodeState before, ModifiedNodeState after) throws IOException {
+            after.compareAgainstBaseState(before, this);
+            if (exception != null) {
+                throw new IOException(exception);
+            } else {
+                return childNodes;
+            }
+        }
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java Tue Dec 15 09:06:41 2015
@@ -496,7 +496,11 @@ public class FileStore implements Segmen
                     new Runnable() {
                         @Override
                         public void run() {
-                            maybeCompact(true);
+                            try {
+                                maybeCompact(true);
+                            } catch (IOException e) {
+                                log.error("Error running compaction", e);
+                            }
                         }
                     });
 
@@ -528,7 +532,7 @@ public class FileStore implements Segmen
         }
     }
 
-    public boolean maybeCompact(boolean cleanup) {
+    public boolean maybeCompact(boolean cleanup) throws IOException {
         gcMonitor.info("TarMK GC #{}: started", gcCount.incrementAndGet());
 
         Runtime runtime = Runtime.getRuntime();
@@ -960,7 +964,7 @@ public class FileStore implements Segmen
      * are fully kept (they are only removed in cleanup, if there is no
      * reference to them).
      */
-    public void compact() {
+    public void compact() throws IOException {
         checkArgument(!compactionStrategy.equals(NO_COMPACTION),
                 "You must set a compactionStrategy before calling compact");
         gcMonitor.info("TarMK GC #{}: compaction started, strategy={}", gcCount, compactionStrategy);
@@ -1222,7 +1226,7 @@ public class FileStore implements Segmen
     }
 
     @Override
-    public void writeSegment(SegmentId id, byte[] data, int offset, int length) {
+    public void writeSegment(SegmentId id, byte[] data, int offset, int length) throws IOException {
         fileStoreLock.writeLock().lock();
         try {
             long size = writer.writeEntry(
@@ -1233,8 +1237,6 @@ public class FileStore implements Segmen
                 newWriter();
             }
             approximateSize.addAndGet(TarWriter.BLOCK_SIZE + length + TarWriter.getPaddingSize(length));
-        } catch (IOException e) {
-            throw new RuntimeException(e);
         } finally {
             fileStoreLock.writeLock().unlock();
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java Tue Dec 15 09:06:41 2015
@@ -126,13 +126,13 @@ public class HttpStore implements Segmen
         } catch (MalformedURLException e) {
             throw new SegmentNotFoundException(id, e);
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new SegmentNotFoundException(id, e);
         }
     }
 
     @Override
     public void writeSegment(
-            SegmentId id, byte[] bytes, int offset, int length) {
+            SegmentId id, byte[] bytes, int offset, int length) throws IOException {
         try {
             URLConnection connection = get(id.toString());
             connection.setDoInput(false);
@@ -144,9 +144,7 @@ public class HttpStore implements Segmen
                 stream.close();
             }
         } catch (MalformedURLException e) {
-            throw new IllegalStateException(e);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new IOException(e);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java Tue Dec 15 09:06:41 2015
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.ConcurrentMap;
 
@@ -50,7 +51,7 @@ public class MemoryStore implements Segm
     private final ConcurrentMap<SegmentId, Segment> segments =
             Maps.newConcurrentMap();
 
-    public MemoryStore(NodeState root) {
+    public MemoryStore(NodeState root) throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("root", root);
 
@@ -59,7 +60,7 @@ public class MemoryStore implements Segm
         writer.flush();
     }
 
-    public MemoryStore() {
+    public MemoryStore() throws IOException {
         this(EMPTY_NODE);
     }
 
@@ -99,13 +100,13 @@ public class MemoryStore implements Segm
 
     @Override
     public void writeSegment(
-            SegmentId id, byte[] data, int offset, int length) {
+            SegmentId id, byte[] data, int offset, int length) throws IOException {
         ByteBuffer buffer = ByteBuffer.allocate(length);
         buffer.put(data, offset, length);
         buffer.rewind();
         Segment segment = new Segment(tracker, id, buffer);
         if (segments.putIfAbsent(id, segment) != null) {
-            throw new IllegalStateException("Segment override: " + id);
+            throw new IOException("Segment override: " + id);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java Tue Dec 15 09:06:41 2015
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak;
 
+import java.io.IOException;
+
 import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
 import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
@@ -38,7 +40,11 @@ public abstract class NodeStoreFixture {
 
         @Override
         public NodeStore createNodeStore() {
-            return new SegmentNodeStore(new MemoryStore());
+            try {
+                return new SegmentNodeStore(new MemoryStore());
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
         }
 
         @Override

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/migration/DepthFirstNodeIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/migration/DepthFirstNodeIteratorTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/migration/DepthFirstNodeIteratorTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/migration/DepthFirstNodeIteratorTest.java Tue Dec 15 09:06:41 2015
@@ -19,6 +19,14 @@
 
 package org.apache.jackrabbit.oak.plugins.blob.migration;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore;
@@ -29,19 +37,12 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.junit.Before;
 import org.junit.Test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-
-import java.util.HashMap;
-import java.util.Map;
-
 public class DepthFirstNodeIteratorTest {
 
     private NodeStore store;
 
     @Before
-    public void setup() throws CommitFailedException {
+    public void setup() throws CommitFailedException, IOException {
         store = SegmentNodeStore.newSegmentNodeStore(new MemoryStore()).create();
         NodeBuilder rootBuilder = store.getRoot().builder();
         NodeBuilder countries = rootBuilder.child("countries");

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/InitializerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/InitializerTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/InitializerTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/InitializerTest.java Tue Dec 15 09:06:41 2015
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.document;
 
+import java.io.IOException;
+
 import com.google.common.collect.ImmutableMap;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -51,7 +53,7 @@ public class InitializerTest extends Abs
     }
 
     @Test
-    public void testInitializerSegment() throws CommitFailedException {
+    public void testInitializerSegment() throws CommitFailedException, IOException {
         NodeStore store = new SegmentNodeStore(new MemoryStore());
 
         NodeBuilder builder = store.getRoot().builder();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CheckpointTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CheckpointTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CheckpointTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CheckpointTest.java Tue Dec 15 09:06:41 2015
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
@@ -38,7 +39,7 @@ import org.junit.Test;
 public class CheckpointTest {
 
     @Test
-    public void testCheckpoint() throws CommitFailedException {
+    public void testCheckpoint() throws CommitFailedException, IOException {
         SegmentNodeStore store = new SegmentNodeStore(new MemoryStore());
         addTestNode(store, "test-checkpoint");
         verifyNS(store, true);
@@ -50,7 +51,7 @@ public class CheckpointTest {
     }
 
     @Test
-    public void testRelease() throws CommitFailedException {
+    public void testRelease() throws CommitFailedException, IOException {
         SegmentNodeStore store = new SegmentNodeStore(new MemoryStore());
         addTestNode(store, "test-checkpoint");
         String cp = verifyNS(store, true);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactorTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactorTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactorTest.java Tue Dec 15 09:06:41 2015
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.junit.Assert.assertFalse;
 
+import java.io.IOException;
+
 import com.google.common.base.Suppliers;
 import junit.framework.Assert;
 import org.apache.jackrabbit.oak.Oak;
@@ -38,7 +40,7 @@ public class CompactorTest {
     private SegmentStore segmentStore;
 
     @Before
-    public void openSegmentStore() {
+    public void openSegmentStore() throws IOException {
         segmentStore = new MemoryStore();
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java Tue Dec 15 09:06:41 2015
@@ -22,6 +22,8 @@ import static org.easymock.EasyMock.expe
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
+import java.io.IOException;
+
 import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -37,8 +39,11 @@ public class CompareAgainstBaseStateTest
     private final NodeStateDiff diff =
             createControl().createMock("diff", NodeStateDiff.class);
 
-    private NodeBuilder builder =
-            new MemoryStore().getTracker().getWriter().writeNode(EMPTY_NODE).builder();
+    private NodeBuilder builder;
+
+    public CompareAgainstBaseStateTest() throws IOException {
+        builder = new MemoryStore().getTracker().getWriter().writeNode(EMPTY_NODE).builder();
+    }
 
     @Before
     public void setUp() {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MapRecordTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MapRecordTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MapRecordTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MapRecordTest.java Tue Dec 15 09:06:41 2015
@@ -23,6 +23,7 @@ import static org.easymock.EasyMock.expe
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
+import java.io.IOException;
 import java.util.Set;
 import java.util.regex.Pattern;
 
@@ -42,8 +43,11 @@ public class MapRecordTest {
     private final NodeStateDiff diff =
             createControl().createMock("diff", NodeStateDiff.class);
 
-    private NodeBuilder builder =
-            new MemoryStore().getTracker().getWriter().writeNode(EMPTY_NODE).builder();
+    private NodeBuilder builder;
+
+    public MapRecordTest() throws IOException {
+        builder = new MemoryStore().getTracker().getWriter().writeNode(EMPTY_NODE).builder();
+    }
 
     @Test
     public void testOak1104() {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java Tue Dec 15 09:06:41 2015
@@ -20,6 +20,7 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertTrue;
 import static junit.framework.Assert.fail;
 
+import java.io.IOException;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -38,7 +39,7 @@ import org.junit.Test;
 public class MergeTest {
 
     @Test
-    public void testSequentialMerge() throws CommitFailedException {
+    public void testSequentialMerge() throws CommitFailedException, IOException {
         NodeStore store = new SegmentNodeStore(new MemoryStore());
 
         assertFalse(store.getRoot().hasProperty("foo"));
@@ -60,7 +61,7 @@ public class MergeTest {
     }
 
     @Test
-    public void testOptimisticMerge() throws CommitFailedException {
+    public void testOptimisticMerge() throws CommitFailedException, IOException {
         NodeStore store = new SegmentNodeStore(new MemoryStore());
 
         NodeBuilder a = store.getRoot().builder();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/PartialCompactionMapTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/PartialCompactionMapTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/PartialCompactionMapTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/PartialCompactionMapTest.java Tue Dec 15 09:06:41 2015
@@ -299,7 +299,7 @@ public class PartialCompactionMapTest {
         run(new GetBenchmark(1000000, 100));
     }
 
-    private static abstract class LoggingBenchmark extends Benchmark {
+    private abstract static class LoggingBenchmark extends Benchmark {
 
         @Override
         public void result(DescriptiveStatistics statistics) {
@@ -349,7 +349,7 @@ public class PartialCompactionMapTest {
         }
 
         @Override
-        public void run() {
+        public void run() throws IOException {
             for (Entry<RecordId, RecordId> tuple : putIds.entrySet()) {
                 map.put(tuple.getKey(), tuple.getValue());
             }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordIdMapTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordIdMapTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordIdMapTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordIdMapTest.java Tue Dec 15 09:06:41 2015
@@ -30,6 +30,7 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Random;
@@ -56,7 +57,7 @@ public class RecordIdMapTest {
     }
 
     @Test
-    public void testRecordIdMap() {
+    public void testRecordIdMap() throws IOException {
         int maxSegments = 1000;
         int maxEntriesPerSegment = 10;
         int seed = new Random().nextInt();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java Tue Dec 15 09:06:41 2015
@@ -26,6 +26,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 import static org.apache.jackrabbit.oak.plugins.segment.ListRecord.LEVEL_SIZE;
+import static org.apache.jackrabbit.oak.plugins.segment.Segment.readString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -51,18 +52,23 @@ import org.junit.Test;
 
 public class RecordTest {
 
-    private String hello = "Hello, World!";
+    private final String hello = "Hello, World!";
 
-    private byte[] bytes = hello.getBytes(Charsets.UTF_8);
+    private final byte[] bytes = hello.getBytes(Charsets.UTF_8);
 
-    private SegmentStore store = new MemoryStore();
+    private final SegmentStore store;
 
-    private SegmentWriter writer = store.getTracker().getWriter();
+    private final SegmentWriter writer;
 
     private final Random random = new Random(0xcafefaceL);
 
+    public RecordTest() throws IOException {
+        store = new MemoryStore();
+        writer = store.getTracker().getWriter();
+    }
+
     @Test
-    public void testBlockRecord() {
+    public void testBlockRecord() throws IOException {
         RecordId blockId = writer.writeBlock(bytes, 0, bytes.length);
         BlockRecord block = new BlockRecord(blockId, bytes.length);
 
@@ -82,7 +88,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testListRecord() {
+    public void testListRecord() throws IOException {
         RecordId blockId = writer.writeBlock(bytes, 0, bytes.length);
 
         ListRecord one = writeList(1, blockId);
@@ -115,13 +121,13 @@ public class RecordTest {
         assertEquals(LEVEL_SIZE * LEVEL_SIZE + 1, count);
     }
 
-    private ListRecord writeList(int size, RecordId id) {
+    private ListRecord writeList(int size, RecordId id) throws IOException {
         List<RecordId> list = Collections.nCopies(size, id);
         return new ListRecord(writer.writeList(list), size);
     }
 
     @Test
-    public void testListWithLotsOfReferences() { // OAK-1184
+    public void testListWithLotsOfReferences() throws IOException { // OAK-1184
         SegmentTracker factory = store.getTracker();
         List<RecordId> list = newArrayList();
         for (int i = 0; i < 1000; i++) {
@@ -169,7 +175,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testStringRecord() {
+    public void testStringRecord() throws IOException {
         RecordId empty = writer.writeString("");
         RecordId space = writer.writeString(" ");
         RecordId hello = writer.writeString("Hello, World!");
@@ -182,14 +188,14 @@ public class RecordTest {
 
         Segment segment = large.getSegmentId().getSegment();
 
-        assertEquals("", segment.readString(empty));
-        assertEquals(" ", segment.readString(space));
-        assertEquals("Hello, World!", segment.readString(hello));
-        assertEquals(builder.toString(), segment.readString(large));
+        assertEquals("", readString(empty));
+        assertEquals(" ", readString(space));
+        assertEquals("Hello, World!", readString(hello));
+        assertEquals(builder.toString(), readString(large));
     }
 
     @Test
-    public void testMapRecord() {
+    public void testMapRecord() throws IOException {
         RecordId blockId = writer.writeBlock(bytes, 0, bytes.length);
 
         MapRecord zero = writer.writeMap(
@@ -256,7 +262,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testMapRemoveNonExisting() {
+    public void testMapRemoveNonExisting() throws IOException {
         RecordId blockId = writer.writeBlock(bytes, 0, bytes.length);
 
         Map<String, RecordId> changes = newHashMap();
@@ -266,7 +272,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testWorstCaseMap() {
+    public void testWorstCaseMap() throws IOException {
         RecordId blockId = writer.writeBlock(bytes, 0, bytes.length);
         Map<String, RecordId> map = newHashMap();
         char[] key = new char[2];
@@ -288,14 +294,14 @@ public class RecordTest {
     }
 
     @Test
-    public void testEmptyNode() {
+    public void testEmptyNode() throws IOException {
         NodeState before = EMPTY_NODE;
         NodeState after = writer.writeNode(before);
         assertEquals(before, after);
     }
 
     @Test
-    public void testSimpleNode() {
+    public void testSimpleNode() throws IOException {
         NodeState before = EMPTY_NODE.builder()
                 .setProperty("foo", "abc")
                 .setProperty("bar", 123)
@@ -306,7 +312,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testDeepNode() {
+    public void testDeepNode() throws IOException {
         NodeBuilder root = EMPTY_NODE.builder();
         NodeBuilder builder = root;
         for (int i = 0; i < 1000; i++) {
@@ -318,7 +324,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testManyMapDeletes() {
+    public void testManyMapDeletes() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         for (int i = 0; i < 1000; i++) {
             builder.child("test" + i);
@@ -364,7 +370,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testStringPrimaryType() {
+    public void testStringPrimaryType() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("jcr:primaryType", "foo", STRING);
         NodeState state = writer.writeNode(builder.getNodeState());
@@ -372,7 +378,7 @@ public class RecordTest {
     }
 
     @Test
-    public void testStringMixinTypes() {
+    public void testStringMixinTypes() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("jcr:mixinTypes", singletonList("foo"), STRINGS);
         NodeState state = writer.writeNode(builder.getNodeState());

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordUsageAnalyserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordUsageAnalyserTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordUsageAnalyserTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordUsageAnalyserTest.java Tue Dec 15 09:06:41 2015
@@ -35,6 +35,7 @@ import static org.junit.Assert.assertEqu
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.io.IOException;
 import java.util.List;
 import java.util.Random;
 
@@ -74,14 +75,14 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void emptyNode() {
+    public void emptyNode() throws IOException {
         SegmentNodeState node = writer.writeNode(EMPTY_NODE);
         analyser.analyseNode(node.getRecordId());
         assertSizes(analyser, 0, 0, 0, 4, 3);
     }
 
     @Test
-    public void nodeWithInt() {
+    public void nodeWithInt() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("one", 1);
 
@@ -91,7 +92,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithString() {
+    public void nodeWithString() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("two", "222");
 
@@ -101,7 +102,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithMultipleProperties() {
+    public void nodeWithMultipleProperties() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("one", "11");
         builder.setProperty("two", "22");
@@ -117,7 +118,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithMediumString() {
+    public void nodeWithMediumString() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("medium", repeat("a", SMALL_LIMIT + 1));
 
@@ -127,7 +128,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithLargeString() {
+    public void nodeWithLargeString() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("large", repeat("b", MEDIUM_LIMIT + 1));
 
@@ -137,7 +138,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithSameString() {
+    public void nodeWithSameString() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("two", "two");
 
@@ -147,7 +148,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithInts() {
+    public void nodeWithInts() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("multi", ImmutableList.of(1L, 2L, 3L, 4L), LONGS);
 
@@ -157,7 +158,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithManyInts() {
+    public void nodeWithManyInts() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("multi", nCopies(LEVEL_SIZE + 1, 1L), LONGS);
 
@@ -167,7 +168,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithManyIntsAndOne() {
+    public void nodeWithManyIntsAndOne() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("multi", nCopies(LEVEL_SIZE + 2, 1L), LONGS);
 
@@ -177,7 +178,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithStrings() {
+    public void nodeWithStrings() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("multi", ImmutableList.of("one", "one", "two", "two", "three"), STRINGS);
 
@@ -187,7 +188,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithBlob() {
+    public void nodeWithBlob() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("blob", createRandomBlob(4));
 
@@ -197,7 +198,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithMediumBlob() {
+    public void nodeWithMediumBlob() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("mediumBlob", createRandomBlob(SMALL_LIMIT + 1));
 
@@ -207,7 +208,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithLargeBlob() {
+    public void nodeWithLargeBlob() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("largeBlob", createRandomBlob(MEDIUM_LIMIT + 1));
 
@@ -217,7 +218,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithPrimaryType() {
+    public void nodeWithPrimaryType() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("jcr:primaryType", "type", NAME);
 
@@ -227,7 +228,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void nodeWithMixinTypes() {
+    public void nodeWithMixinTypes() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("jcr:mixinTypes", ImmutableList.of("type1", "type2"), NAMES);
 
@@ -237,7 +238,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void singleChild() {
+    public void singleChild() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("child");
 
@@ -247,7 +248,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void multiChild() {
+    public void multiChild() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("child1");
         builder.setChildNode("child2");
@@ -258,7 +259,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void manyChild() {
+    public void manyChild() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         for (int k = 0; k < MapRecord.BUCKETS_PER_LEVEL + 1; k++) {
             builder.setChildNode("child" + k);
@@ -270,7 +271,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void changedChild() {
+    public void changedChild() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("child1");
         builder.setChildNode("child2");
@@ -290,7 +291,7 @@ public class RecordUsageAnalyserTest {
     }
 
     @Test
-    public void counts() {
+    public void counts() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("child1");
         builder.setChildNode("child2");

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdFactoryTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdFactoryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdFactoryTest.java Tue Dec 15 09:06:41 2015
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
 
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Set;
 
@@ -27,7 +28,11 @@ import org.junit.Test;
 
 public class SegmentIdFactoryTest {
 
-    private final SegmentTracker factory = new MemoryStore().getTracker();
+    private final SegmentTracker factory;
+
+    public SegmentIdFactoryTest() throws IOException {
+        factory = new MemoryStore().getTracker();
+    }
 
     @Test
     public void segmentIdType() {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableBenchmark.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableBenchmark.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableBenchmark.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableBenchmark.java Tue Dec 15 09:06:41 2015
@@ -16,13 +16,14 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.util.Random;
 
 import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore;
 
 public class SegmentIdTableBenchmark {
-    public static void main(String... args) {
+    public static void main(String... args) throws IOException {
         test();
         test();
         test();
@@ -31,7 +32,7 @@ public class SegmentIdTableBenchmark {
         test();
     }
 
-    private static void test() {
+    private static void test() throws IOException {
         long time;
         int repeat = 10000;
         int count = 10000;

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentIdTableTest.java Tue Dec 15 09:06:41 2015
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -43,7 +44,7 @@ public class SegmentIdTableTest {
      * OAK-2752
      */
     @Test
-    public void endlessSearchLoop() {
+    public void endlessSearchLoop() throws IOException {
         SegmentTracker tracker = new MemoryStore().getTracker();
         final SegmentIdTable tbl = new SegmentIdTable(tracker);
 
@@ -73,7 +74,7 @@ public class SegmentIdTableTest {
     }
     
     @Test
-    public void randomized() {
+    public void randomized() throws IOException {
         SegmentTracker tracker = new MemoryStore().getTracker();
         final SegmentIdTable tbl = new SegmentIdTable(tracker);
 
@@ -96,7 +97,7 @@ public class SegmentIdTableTest {
     }
     
     @Test
-    public void clearTable() {
+    public void clearTable() throws IOException {
         SegmentTracker tracker = new MemoryStore().getTracker();
         final SegmentIdTable tbl = new SegmentIdTable(tracker);
 
@@ -142,7 +143,7 @@ public class SegmentIdTableTest {
     }
     
     @Test
-    public void justHashCollisions() {
+    public void justHashCollisions() throws IOException {
         SegmentTracker tracker = new MemoryStore().getTracker();
         final SegmentIdTable tbl = new SegmentIdTable(tracker);
 
@@ -166,7 +167,7 @@ public class SegmentIdTableTest {
     }
     
     @Test
-    public void gc() {
+    public void gc() throws IOException {
         SegmentTracker tracker = new MemoryStore().getTracker();
         final SegmentIdTable tbl = new SegmentIdTable(tracker);
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentParserTest.java?rev=1720095&r1=1720094&r2=1720095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentParserTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentParserTest.java Tue Dec 15 09:06:41 2015
@@ -160,7 +160,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void emptyNode() {
+    public void emptyNode() throws IOException {
         SegmentNodeState node = writer.writeNode(EMPTY_NODE);
         NodeInfo info = new TestParser("emptyNode") {
             @Override protected void onTemplate(RecordId parentId, RecordId templateId) { }
@@ -172,7 +172,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void singleChildNode() {
+    public void singleChildNode() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("child");
         SegmentNodeState node = writer.writeNode(builder.getNodeState());
@@ -187,7 +187,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void node() {
+    public void node() throws IOException {
         final NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("one");
         builder.setChildNode("two");
@@ -212,7 +212,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void template() {
+    public void template() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("n");
         builder.setProperty("p", 1);
@@ -245,7 +245,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void emptyMap() {
+    public void emptyMap() throws IOException {
         Map<String, RecordId> empty = newHashMap();
         MapRecord map = writer.writeMap(null, empty);
         MapInfo mapInfo = new TestParser("emptyMap") {
@@ -256,7 +256,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void nonEmptyMap() {
+    public void nonEmptyMap() throws IOException {
         Random rnd = new Random();
         MapRecord base = writer.writeMap(null, createMap(33, rnd));
         MapRecord map = writer.writeMap(base, createMap(1, rnd));
@@ -302,7 +302,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void singleValueProperty() {
+    public void singleValueProperty() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("p", 1);
         SegmentNodeState node = writer.writeNode(builder.getNodeState());
@@ -326,7 +326,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void multiValueProperty() {
+    public void multiValueProperty() throws IOException {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty("p", ImmutableList.of(1L, 2L, 3L, 4L), LONGS);
         SegmentNodeState node = writer.writeNode(builder.getNodeState());
@@ -400,7 +400,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void shortString() {
+    public void shortString() throws IOException {
         RecordId stringId = writer.writeString("short");
         BlobInfo blobInfo = new TestParser("shortString").parseString(stringId);
         assertEquals(stringId, blobInfo.blobId);
@@ -409,7 +409,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void mediumString() {
+    public void mediumString() throws IOException {
         RecordId stringId = writer.writeString(repeat("s", SMALL_LIMIT));
         BlobInfo blobInfo = new TestParser("mediumString").parseString(stringId);
         assertEquals(stringId, blobInfo.blobId);
@@ -418,7 +418,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void longString() {
+    public void longString() throws IOException {
         RecordId stringId = writer.writeString(repeat("s", MEDIUM_LIMIT));
         BlobInfo blobInfo = new TestParser("longString"){
             @Override protected void onList(RecordId parentId, RecordId listId, int count) { }
@@ -438,7 +438,7 @@ public class SegmentParserTest {
     }
 
     @Test
-    public void nonEmptyList() {
+    public void nonEmptyList() throws IOException {
         int count = 100000;
         Random rnd = new Random();
         List<RecordId> list = newArrayListWithCapacity(count);