rethinkdb-java icon indicating copy to clipboard operation
rethinkdb-java copied to clipboard

improved code smell

Open EzxD opened this issue 3 years ago • 0 comments

Reason for the change Code smell is important for better readability

Description I replaced stuff which can be expressed with isEmpty(). And a try with resource for closing the socket if exception gets thrown

Code examples I replaced raw.size() == 0 with raw.isEmpty() more important is the try with resource of the socket. old code:

            SSLSocket sslSocket = (SSLSocket) sslContext.getSocketFactory().createSocket(
                        socket,
                        socket.getInetAddress().getHostAddress(),
                        socket.getPort(),
                        true);

                    // replace input/output streams
                    inputStream = new DataInputStream(sslSocket.getInputStream());
                    outputStream = sslSocket.getOutputStream();

                    // execute SSL handshake
                    sslSocket.startHandshake();

new code:

   try (
                      SSLSocket sslSocket = (SSLSocket) sslContext.getSocketFactory()
                        .createSocket(
                          socket,
                          socket.getInetAddress().getHostAddress(),
                          socket.getPort(),
                          true
                        )
                    ) {

                        // replace input/output streams
                        inputStream = new DataInputStream(sslSocket.getInputStream());
                        outputStream = sslSocket.getOutputStream();

                        // execute SSL handshake
                        sslSocket.startHandshake();
                    }

Checklist

References Anything else related to the change e.g. documentations, RFCs, etc.

EzxD avatar Nov 14 '21 22:11 EzxD