| Priority |
Normal |
| Type | Bug |
| State | Fixed |
| Assignee | Bas Leijdekkers |
| Subsystem | Code Analysis. Inspection |
| Affected versions |
No affected versions
|
| Fixed in |
No fix versions
|
| Fixed in build |
Next build |
| Build |
7590
|
| Fixed in build |
8238
|
| Severity |
0
|
IDEA-42530 |
Faulty "'Connection' should be opened in a try block, and closed in a finally block" inspection in InspectionGadgets plugin |
|
|
javax.microedition.io.Connection connection = null;
try {
connection = (javax.microedition.io.file.FileConnection) Connector.open("");
} catch (IOException ioe) {
// ignore
} finally {
try {
if (null != connection) {
connection.close();
}
} catch (IOException ioe) {
// ignore
}
}
javax.microedition.io.file.FileConnection fileConnection = null;
try {
fileConnection = (javax.microedition.io.file.FileConnection) Connector.open("");
if (!fileConnection.exists()) {
fileConnection.mkdir();
}
} catch (IOException ioe) {
// ignore
} finally {
try {
if (null != fileConnection) {
fileConnection.close();
}
} catch (IOException ioe) {
// ignore
}
}
Connection connection = null; try { connection = Connector.open(""); final FileConnection fileConnection = (FileConnection) connection; if (!fileConnection.exists()) { fileConnection.mkdir(); } } catch (IOException ioe) { // ignore } finally { try { if (null != connection) { connection.close(); } } catch (IOException ioe) { // ignore } }