Beispiel
protected void finalize() throws Throwable {
try {
getContext().close();
}
catch (NamingException exc) {
LogUtility.log(exc);
}
finally {
super .finalize();
}
}

private Context getContext() {
return _context;
}

private transient Context _context;
Lösung
Verwenden Sie statt der Methode finalize() eine Bereinigungsmethode, die explizit aufgerufen wird.
public void free() {
try {
getContext().close();
}
catch (NamingException exc) {
LogUtility.log(exc);
}
}

private Context getContext() {
return _context;
}

private transient Context _context;