Java
'throw' inside 'finally' block
Warning
Last modified: 03 December 2024 Reports throw
statements inside finally
blocks. While occasionally intended, such throw
statements can hide exceptions thrown from the try
and catch
blocks, thereby complicating the debugging process.
Example:
class Fascinating {
void doTask(Task t) {
try {
t.activity();
} finally {
if (!t.finish()) {
throw new IllegalStateException();
}
}
}
}
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
ThrowFromFinallyBlock
Use the Warn everywhere declared exceptions may be thrown option to warn on method calls to methods that declare exceptions as well.
Here you can find the description of settings available for the 'throw' inside 'finally' block inspection, and the reference of their default values.
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 243.23126 |
Thanks for your feedback!
Was this page helpful?