mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
assert isLocked in write
This commit is contained in:
@@ -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<IOException> ref = new Ref<IOException>();
|
||||
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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user