サンプル
protected void finalize() throws Throwable {
try {
getAny().write_value(getOutputStream());
getOutputStream().flush();
getOutputStream().close();
}
catch (IOException exc) {
LogUtility.log(exc);
}
finally {
super .finalize();
}
}

private OutputStream getOutputStream() {
return _outputStream;
}

private Any getAny() {
return _any;
}

private Any _any;
private transient OutputStream _outputStream;
ソリューション
finalize() メソッドの代わりに、クリーンアップ・メソッドを明示的に呼び出して使用します。
public void free() {
try {
getAny().write_value(getOutputStream());
getOutputStream().flush();
getOutputStream().close();
}
catch (IOException exc) {
LogUtility.log(exc);
}
}

private OutputStream getOutputStream() {
return _outputStream;
}

private Any getAny() {
return _any;
}

private Any _any;
private transient OutputStream _outputStream;