From 277cd99f9c172c4d70ed3c1f38dfcba0b7df1af7 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 7 Nov 2014 15:40:38 +0100 Subject: [PATCH] assert isLocked in write --- .../history/core/changes/ChangeSet.java | 26 +++++-------------- .../history/core/storage/StreamTest.java | 4 +-- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/platform/lvcs-impl/src/com/intellij/history/core/changes/ChangeSet.java b/platform/lvcs-impl/src/com/intellij/history/core/changes/ChangeSet.java index c9a75530871b..44f32d8d136c 100644 --- a/platform/lvcs-impl/src/com/intellij/history/core/changes/ChangeSet.java +++ b/platform/lvcs-impl/src/com/intellij/history/core/changes/ChangeSet.java @@ -19,7 +19,6 @@ package com.intellij.history.core.changes; import com.intellij.history.core.Content; import com.intellij.history.core.StreamUtil; import com.intellij.history.utils.LocalHistoryLog; -import com.intellij.openapi.util.Ref; import com.intellij.util.Producer; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; @@ -61,27 +60,16 @@ public class ChangeSet { isLocked = true; } - public void write(final DataOutput out) throws IOException { + public void write(DataOutput out) throws IOException { + LocalHistoryLog.LOG.assertTrue(isLocked, "Changeset should be locked"); out.writeLong(myId); StreamUtil.writeStringOrNull(out, myName); out.writeLong(myTimestamp); - final Ref ref = new Ref(); - accessChanges(new Runnable() { - @Override - public void run() { - try { - out.writeInt(myChanges.size()); - for (Change c : myChanges) { - StreamUtil.writeChange(out, c); - } - } - catch (IOException e) { - ref.set(e); - } - } - }); - if (ref.get() != null) throw ref.get(); + out.writeInt(myChanges.size()); + for (Change c : myChanges) { + StreamUtil.writeChange(out, c); + } } public void setName(@Nullable String name) { @@ -131,7 +119,7 @@ public class ChangeSet { } public void addChange(final Change c) { - LocalHistoryLog.LOG.assertTrue(!isLocked, "Changset is already locked"); + LocalHistoryLog.LOG.assertTrue(!isLocked, "Changeset is already locked"); accessChanges(new Runnable() { @Override public void run() { diff --git a/platform/platform-tests/testSrc/com/intellij/history/core/storage/StreamTest.java b/platform/platform-tests/testSrc/com/intellij/history/core/storage/StreamTest.java index fa8a9e3a6e0a..ff5e98a0a3b2 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/core/storage/StreamTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/core/storage/StreamTest.java @@ -260,7 +260,7 @@ public class StreamTest extends LocalHistoryTestCase { @Test public void testChangeSet() throws IOException { ChangeSet cs = cs(123, "name", new CreateFileChange(nextId(), "file")); - + cs.lock(); cs.write(os); ChangeSet read = new ChangeSet(is); @@ -275,7 +275,7 @@ public class StreamTest extends LocalHistoryTestCase { @Test public void testChangeSetWithoutName() throws IOException { ChangeSet cs = cs((String)null); - + cs.lock(); cs.write(os); ChangeSet read = new ChangeSet(is);