Pass SQL connection into nested method to prevent deadlock.

Discussed with Sam on Slack 11 Dec #general.
This commit is contained in:
md_5 2016-12-11 18:19:25 +11:00 committed by cnr
parent 337f9e4fd9
commit e107c0a64a
2 changed files with 3 additions and 3 deletions

View File

@ -163,11 +163,11 @@ public class SnapshotRepository
} }
} }
public CompletableFuture<SnapshotMetadata> getSnapshotMetadata(int snapshotId) public CompletableFuture<SnapshotMetadata> getSnapshotMetadata(Connection connection, int snapshotId)
{ {
CompletableFuture<SnapshotMetadata> future = CompletableFuture.supplyAsync(() -> CompletableFuture<SnapshotMetadata> future = CompletableFuture.supplyAsync(() ->
{ {
try (Connection connection = DBPool.getAccount().getConnection()) try
{ {
try (PreparedStatement statement = connection.prepareStatement(GET_METADATA)) try (PreparedStatement statement = connection.prepareStatement(GET_METADATA))
{ {

View File

@ -372,7 +372,7 @@ public class ReportRepository
if (!resultSet.wasNull()) if (!resultSet.wasNull())
{ {
SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getRepository() SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getRepository()
.getSnapshotMetadata(snapshotId).join(); .getSnapshotMetadata(connection, snapshotId).join();
report.setSnapshotMetadata(snapshotMetadata); report.setSnapshotMetadata(snapshotMetadata);
} }