예제
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;
솔루션
finalize() 메소드 대신 명시적으로 호출된 정리 메소드를 사용하십시오.
public
void
free() {
try
{
getContext().close();
}
catch
(
NamingException
exc) {
LogUtility.log(exc);
}
}
private
Context
getContext() {
return
_context;
}
private
transient
Context
_context;