Příklad
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;
Řešení
Použijte metody vyčištění, která se vyvolá explicitně místo metody finalize().
public void free() {
try {
getContext().close();
}
catch (NamingException exc) {
LogUtility.log(exc);
}
}

private Context getContext() {
return _context;
}

private transient Context _context;