Removed Writer.close().

This commit is contained in:
akwizgran
2011-07-22 18:08:05 +01:00
parent fe58fb4c30
commit 5d000b62f8
7 changed files with 3 additions and 17 deletions

View File

@@ -6,8 +6,8 @@ import java.util.Map;
public interface Writer {
// FIXME: Remove this method
long getBytesWritten();
void close() throws IOException;
void writeBoolean(boolean b) throws IOException;

View File

@@ -84,7 +84,8 @@ class BundleWriterImpl implements BundleWriter {
}
if(state != State.MORE_BATCHES) throw new IllegalStateException();
writer.writeListEnd();
writer.close();
out.flush();
out.close();
state = State.END;
}
}

View File

@@ -52,7 +52,6 @@ class MessageEncoderImpl implements MessageEncoder {
// Write the signature
w.writeRaw(sig);
byte[] raw = out.toByteArray();
w.close();
// The message ID is the hash of the entire message
messageDigest.reset();
messageDigest.update(raw);
@@ -62,7 +61,6 @@ class MessageEncoderImpl implements MessageEncoder {
w = writerFactory.createWriter(out);
w.writeString(nick);
w.writeRaw(keyPair.getPublic().getEncoded());
w.close();
messageDigest.reset();
messageDigest.update(out.toByteArray());
AuthorId authorId = new AuthorId(messageDigest.digest());

View File

@@ -25,11 +25,6 @@ class WriterImpl implements Writer {
return bytesWritten;
}
public void close() throws IOException {
out.flush();
out.close();
}
public void writeBoolean(boolean b) throws IOException {
if(b) out.write(Tag.TRUE);
else out.write(Tag.FALSE);

View File

@@ -152,7 +152,6 @@ public class BatchReaderTest extends TestCase {
w.writeUserDefinedTag(Tags.MESSAGE);
w.writeRaw(new byte[size - 10]);
w.writeListEnd();
w.close();
byte[] b = out.toByteArray();
assertEquals(size, b.length);
return b;
@@ -164,7 +163,6 @@ public class BatchReaderTest extends TestCase {
w.writeUserDefinedTag(Tags.BATCH);
w.writeListStart();
w.writeListEnd();
w.close();
return out.toByteArray();
}

View File

@@ -72,7 +72,6 @@ public class BundleReaderImplTest extends TestCase {
w.writeUserDefinedTag(Tags.BATCH);
w.writeList(Collections.emptyList());
w.writeListEnd();
w.close();
byte[] headless = out.toByteArray();
// Try to read a header from the headless bundle
ByteArrayInputStream in = new ByteArrayInputStream(headless);
@@ -96,7 +95,6 @@ public class BundleReaderImplTest extends TestCase {
w.writeList(Collections.emptyList()); // Subs
w.writeMap(Collections.emptyMap()); // Transports
w.writeInt64(System.currentTimeMillis()); // Timestamp
w.close();
byte[] headerOnly = out.toByteArray();
// Try to read a header from the header-only bundle
ByteArrayInputStream in = new ByteArrayInputStream(headerOnly);
@@ -122,7 +120,6 @@ public class BundleReaderImplTest extends TestCase {
w.writeInt64(System.currentTimeMillis()); // Timestamp
w.writeListStart();
w.writeListEnd();
w.close();
byte[] batchless = out.toByteArray();
// It should be possible to read the header and null
ByteArrayInputStream in = new ByteArrayInputStream(batchless);
@@ -210,7 +207,6 @@ public class BundleReaderImplTest extends TestCase {
w.writeUserDefinedTag(Tags.BATCH);
w.writeList(Collections.emptyList()); // Messages
w.writeListEnd();
w.close();
return out.toByteArray();
}

View File

@@ -133,7 +133,6 @@ public class HeaderReaderTest extends TestCase {
w.writeMapEnd();
// Timestamp
w.writeInt64(System.currentTimeMillis());
w.close();
assertEquals(size, out.size());
return out.toByteArray();
}
@@ -153,7 +152,6 @@ public class HeaderReaderTest extends TestCase {
w.writeMapEnd();
// Timestamp
w.writeInt64(System.currentTimeMillis());
w.close();
return out.toByteArray();
}
}