Beispiel
protected void finalize() throws Throwable {
try {
Socket socket = new Socket(HOST, 8080);
// ...
socket.close();
}
catch (IOException exc) {
LogUtility.log(exc);
}
finally {
super .finalize();
}
}

private static final String HOST = "host";
Lösung
Verwenden Sie statt der Methode finalize() eine Bereinigungsmethode, die explizit aufgerufen wird.
public void free() {
try {
Socket socket = new Socket(HOST, 8080);
// ...
socket.close();
}
catch (IOException exc) {
LogUtility.log(exc);
}
}

private static final String HOST = "host";