mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 14:16:11 +00:00
Issue 182: Cleanup documentation should include null-check
This commit is contained in:
1 parent
cfbfa17876
commit
95f73048ce
2 files changed
+12
-2
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user