[FLINK-1173] Fix source codes to follow coding guidelines
[FLINK-1173] Check clientSocket is already closed before close clientSocket