Skip to content

Commit 80d10f5

Browse files
author
Jaspreet Grewal
committed
Adressed pull request comments by komamitsu
1 parent b3bc73c commit 80d10f5

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/main/java/org/fluentd/logger/sender/RawSocketSender.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.io.IOException;
2727
import java.net.InetSocketAddress;
2828
import java.net.Socket;
29-
import java.net.SocketAddress;
3029
import java.nio.ByteBuffer;
3130
import java.util.Map;
3231

@@ -38,8 +37,6 @@ public class RawSocketSender implements Sender {
3837

3938
private MessagePack msgpack;
4039

41-
private SocketAddress server;
42-
4340
private Socket socket;
4441

4542
private int timeout;
@@ -52,9 +49,9 @@ public class RawSocketSender implements Sender {
5249

5350
private String name;
5451

55-
private String host;
52+
private final String host;
5653

57-
private int port;
54+
private final int port;
5855

5956
private ErrorHandler errorHandler = DEFAULT_ERROR_HANDLER;
6057

@@ -77,7 +74,6 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
7774
pendings = ByteBuffer.allocate(bufferCapacity);
7875
this.host = host;
7976
this.port = port;
80-
server = new InetSocketAddress(host, port);
8177
this.reconnector = reconnector;
8278
name = String.format("%s_%d_%d_%d", host, port, timeout, bufferCapacity);
8379
this.timeout = timeout;
@@ -86,8 +82,7 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
8682
private void connect() throws IOException {
8783
try {
8884
socket = new Socket();
89-
server = new InetSocketAddress(host, port);
90-
socket.connect(server, timeout);
85+
socket.connect(new InetSocketAddress(host, port), timeout);
9186
out = new BufferedOutputStream(socket.getOutputStream());
9287
} catch (IOException e) {
9388
throw e;
@@ -160,7 +155,7 @@ private boolean flushBuffer() {
160155
if (pendings.position() == 0) {
161156
return true;
162157
} else {
163-
LOG.error("Cannot send logs to " + server.toString());
158+
LOG.error("Cannot send logs to " + socket.getInetAddress().toString());
164159
}
165160
}
166161

0 commit comments

Comments
 (0)