aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2011-01-31 23:55:06 +0100
committerRoel Spilker <r.spilker@gmail.com>2011-01-31 23:55:06 +0100
commit95f73048ceb8ecd5ca2ae59d152d8c9101fff596 (patch)
tree15513a98c378899cda3216d8b7ad52903c5b5e96
parentcfbfa178765b6eba85d4360943930e1e73c71cef (diff)
downloadlombok-95f73048ceb8ecd5ca2ae59d152d8c9101fff596.tar.gz
lombok-95f73048ceb8ecd5ca2ae59d152d8c9101fff596.tar.bz2
lombok-95f73048ceb8ecd5ca2ae59d152d8c9101fff596.zip
Issue 182: Cleanup documentation should include null-check
-rw-r--r--usage_examples/CleanupExample_post.jpage8
-rw-r--r--website/features/Cleanup.html6
2 files changed, 12 insertions, 2 deletions
diff --git a/usage_examples/CleanupExample_post.jpage b/usage_examples/CleanupExample_post.jpage
index 91458459..7e87c153 100644
--- a/usage_examples/CleanupExample_post.jpage
+++ b/usage_examples/CleanupExample_post.jpage
@@ -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();
+ }
}
}
}
diff --git a/website/features/Cleanup.html b/website/features/Cleanup.html
index 2efd6a3a..4ac4d75e 100644
--- a/website/features/Cleanup.html
+++ b/website/features/Cleanup.html
@@ -43,6 +43,12 @@
<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
code so that, if the main body has thrown an exception, any exception thrown by the close call is silently swallowed (but if the main body