Open review DB in try-with-resource where appropriate
Try with resource can't be used for instances that are got through a provider. Suppress the warning in those cases. Change-Id: I7670151d8f179238bd3e887cc1597902b6f28a91
This commit is contained in:
@@ -116,14 +116,7 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
|
||||
private class Worker extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
final ReviewDb db;
|
||||
try {
|
||||
db = database.open();
|
||||
} catch (OrmException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
try (ReviewDb db = database.open()){
|
||||
for (;;) {
|
||||
final AccountExternalId extId = next();
|
||||
if (extId == null) {
|
||||
@@ -134,8 +127,8 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
|
||||
monitor.update(1);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
} catch (OrmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class CherryPick implements RestModifyView<RevisionResource, CherryPickIn
|
||||
throw new BadRequestException("destination must be non-empty");
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
ReviewDb db = dbProvider.get();
|
||||
if (!control.isVisible(db)) {
|
||||
throw new AuthException("Cherry pick not permitted");
|
||||
@@ -87,10 +88,8 @@ public class CherryPick implements RestModifyView<RevisionResource, CherryPickIn
|
||||
return json.create(ChangeJson.NO_OPTIONS).format(cherryPickedChangeId);
|
||||
} catch (InvalidChangeOperationException e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
} catch (MergeException e) {
|
||||
} catch (MergeException | NoSuchChangeException e) {
|
||||
throw new ResourceConflictException(e.getMessage());
|
||||
} catch (NoSuchChangeException e) {
|
||||
throw new ResourceNotFoundException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ public class Rebase implements RestModifyView<RevisionResource, RebaseInput>,
|
||||
return change.getDest().get();
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
ReviewDb db = dbProvider.get();
|
||||
PatchSet basePatchSet = parseBase(base);
|
||||
if (basePatchSet == null) {
|
||||
|
||||
@@ -217,6 +217,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
|
||||
private String problemsForSubmittingChangeset(
|
||||
ChangeSet cs, IdentifiedUser identifiedUser) {
|
||||
try {
|
||||
@SuppressWarnings("resource")
|
||||
ReviewDb db = dbProvider.get();
|
||||
for (PatchSet.Id psId : cs.patchIds()) {
|
||||
ChangeControl changeControl = changeControlFactory
|
||||
|
||||
@@ -37,6 +37,7 @@ public class RequestScopedReviewDbProvider implements Provider<ReviewDb> {
|
||||
this.cleanup = cleanup;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public ReviewDb get() {
|
||||
if (db == null) {
|
||||
|
||||
Submodule plugins/replication updated: 679301a1b4...264b7a0036
Submodule plugins/reviewnotes updated: d81e2d6d3e...b19086265e
Submodule plugins/singleusergroup updated: 082bf62238...6fb010107a
Reference in New Issue
Block a user