Rename delegate to outputStream

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2022-11-23 19:53:12 -05:00
parent 86723cf85a
commit 96ea154176
No known key found for this signature in database
GPG key ID: 02AA2BAE387C8307

View file

@ -33,11 +33,11 @@ import javax.annotation.concurrent.NotThreadSafe;
class ProtoOutputStream { class ProtoOutputStream {
private static final Logger log = LoggerFactory.getLogger(ProtoOutputStream.class); private static final Logger log = LoggerFactory.getLogger(ProtoOutputStream.class);
private final OutputStream delegate; private final OutputStream outputStream;
private final Statistic statistic; private final Statistic statistic;
ProtoOutputStream(OutputStream delegate, Statistic statistic) { ProtoOutputStream(OutputStream outputStream, Statistic statistic) {
this.delegate = delegate; this.outputStream = outputStream;
this.statistic = statistic; this.statistic = statistic;
} }
@ -52,7 +52,7 @@ class ProtoOutputStream {
void onConnectionShutdown() { void onConnectionShutdown() {
try { try {
delegate.close(); outputStream.close();
} catch (Throwable t) { } catch (Throwable t) {
log.error("Failed to close connection", t); log.error("Failed to close connection", t);
} }
@ -61,8 +61,8 @@ class ProtoOutputStream {
private void writeEnvelopeOrThrow(NetworkEnvelope envelope) throws IOException { private void writeEnvelopeOrThrow(NetworkEnvelope envelope) throws IOException {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
protobuf.NetworkEnvelope proto = envelope.toProtoNetworkEnvelope(); protobuf.NetworkEnvelope proto = envelope.toProtoNetworkEnvelope();
proto.writeDelimitedTo(delegate); proto.writeDelimitedTo(outputStream);
delegate.flush(); outputStream.flush();
long duration = System.currentTimeMillis() - ts; long duration = System.currentTimeMillis() - ts;
if (duration > 10000) { if (duration > 10000) {
log.info("Sending {} to peer took {} sec.", envelope.getClass().getSimpleName(), duration / 1000d); log.info("Sending {} to peer took {} sec.", envelope.getClass().getSimpleName(), duration / 1000d);