Issue 182: Cleanup documentation should include null-check

This commit is contained in:
Roel Spilker committed 2011-01-31 23:55:06 +01:00
1 parent cfbfa17876
commit 95f73048ce
2 files changed
+12 -2

No files matched your search

+6 -2
View File
@@ -13,10 +13,14 @@ public class CleanupExample {
out.write(b, 0, r);
}
} finally {
out.close();
if (out != null) {
out.close();
}
}
} finally {
in.close();
if (in != null) {
in.close();
}
}
}
}
+6
View File
@@ -42,6 +42,12 @@
<div style="clear: left;"></div>
<div class="overview">
<h3>Small print</h3><div class="smallprint">
<p>
In the finally block, the cleanup method is only called if the given resource is not <code>null</code>. However, if you use <code>delombok</code>
on the code, a call to <code>lombok.Lombok.preventNullAnalysis(Object o)</code> is inserted to prevent warnings if static code analysis could
determine that a null-check would not be needed. Compilation with <code>lombok.jar</code> on the classpath removes that method call,
so there is no runtime dependency.
</p>
<p>
If your code throws an exception, and the cleanup method call that is then triggered also throws an exception, then the original exception
is hidden by the exception thrown by the cleanup call. You should <em>not</em> rely on this 'feature'. Preferably, lombok would like to generate