Coverity suggested cleanup

This commit is contained in:
Jeremy Long
2017-07-23 06:27:14 -04:00
parent 176363492e
commit 12d74510cd
4 changed files with 6 additions and 26 deletions

View File

@@ -948,9 +948,7 @@ public class Check extends Update {
dealWithReferences();
validateConfiguration();
populateSettings();
Engine engine = null;
try {
engine = new Engine(Check.class.getClassLoader());
try (Engine engine = new Engine(Check.class.getClassLoader())) {
if (isUpdateOnly()) {
log("Deprecated 'UpdateOnly' property set; please use the UpdateTask instead", Project.MSG_WARN);
try {
@@ -1002,9 +1000,6 @@ public class Check extends Update {
log(msg, ex, Project.MSG_ERR);
} finally {
Settings.cleanup(true);
if (engine != null) {
engine.cleanup();
}
}
}

View File

@@ -385,9 +385,7 @@ public class Update extends Purge {
@Override
public void execute() throws BuildException {
populateSettings();
Engine engine = null;
try {
engine = new Engine(Update.class.getClassLoader());
try (Engine engine = new Engine(Update.class.getClassLoader())) {
try {
engine.doUpdates();
} catch (UpdateException ex) {
@@ -404,9 +402,6 @@ public class Update extends Purge {
log(msg, Project.MSG_ERR);
} finally {
Settings.cleanup(true);
if (engine != null) {
engine.cleanup();
}
}
}

View File

@@ -359,14 +359,8 @@ public class App {
* connection to the database could not be established
*/
private void runUpdateOnly() throws UpdateException, DatabaseException {
Engine engine = null;
try {
engine = new Engine();
try (Engine engine = new Engine()) {
engine.doUpdates();
} finally {
if (engine != null) {
engine.cleanup();
}
}
}

View File

@@ -65,9 +65,7 @@ public class UpdateMojo extends BaseDependencyCheckMojo {
*/
@Override
public void runCheck() throws MojoExecutionException, MojoFailureException {
Engine engine = null;
try {
engine = initializeEngine();
try (Engine engine = initializeEngine()) {
engine.doUpdates();
} catch (DatabaseException ex) {
if (getLog().isDebugEnabled()) {
@@ -84,11 +82,9 @@ public class UpdateMojo extends BaseDependencyCheckMojo {
throw new MojoExecutionException(msg, ex);
}
getLog().error(msg);
} finally {
Settings.cleanup();
}
if (engine != null) {
engine.cleanup();
}
Settings.cleanup();
}
/**