mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Removed Writer.close().
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user