MessageFactory never throws IOException.

This commit is contained in:
akwizgran
2016-01-29 16:03:16 +00:00
parent fd99dd7573
commit 54272c8836
3 changed files with 3 additions and 11 deletions

View File

@@ -1,9 +1,6 @@
package org.briarproject.api.sync; package org.briarproject.api.sync;
import java.io.IOException;
public interface MessageFactory { public interface MessageFactory {
Message createMessage(GroupId groupId, long timestamp, byte[] body) Message createMessage(GroupId groupId, long timestamp, byte[] body);
throws IOException;
} }

View File

@@ -110,8 +110,6 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch (FormatException e) { } catch (FormatException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (IOException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} finally { } finally {
lock.writeLock().unlock(); lock.writeLock().unlock();
} }
@@ -123,7 +121,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
private void storeMessage(GroupId g, DeviceId dev, TransportId t, private void storeMessage(GroupId g, DeviceId dev, TransportId t,
TransportProperties p, long version, boolean local, boolean shared) TransportProperties p, long version, boolean local, boolean shared)
throws DbException, IOException { throws DbException, FormatException {
byte[] body = encodeProperties(dev, t, p, version); byte[] body = encodeProperties(dev, t, p, version);
long now = clock.currentTimeMillis(); long now = clock.currentTimeMillis();
Message m = messageFactory.createMessage(g, now, body); Message m = messageFactory.createMessage(g, now, body);

View File

@@ -10,8 +10,6 @@ import org.briarproject.api.sync.MessageFactory;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import org.briarproject.util.ByteUtils; import org.briarproject.util.ByteUtils;
import java.io.IOException;
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH; import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH; import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
@@ -25,8 +23,7 @@ class MessageFactoryImpl implements MessageFactory {
} }
@Override @Override
public Message createMessage(GroupId groupId, long timestamp, byte[] body) public Message createMessage(GroupId groupId, long timestamp, byte[] body) {
throws IOException {
if (body.length > MAX_MESSAGE_BODY_LENGTH) if (body.length > MAX_MESSAGE_BODY_LENGTH)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
byte[] raw = new byte[MESSAGE_HEADER_LENGTH + body.length]; byte[] raw = new byte[MESSAGE_HEADER_LENGTH + body.length];