java: Fix CID 1386112 (Resource leak)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-04-26 14:27:43 +02:00
parent 63d5709958
commit 62df5ae686

View File

@ -371,9 +371,8 @@ public class ScrollView {
intPattern = Pattern.compile("[0-9-][0-9]*");
floatPattern = Pattern.compile("[0-9-][0-9]*\\.[0-9]*");
try {
// Open a socket to listen on.
ServerSocket serverSocket = new ServerSocket(SERVER_PORT);
// Open a socket to listen on.
try (ServerSocket serverSocket = new ServerSocket(SERVER_PORT)) {
System.out.println("Socket started on port " + SERVER_PORT);
// Wait (blocking) for an incoming connection