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