From e107c0a64a2efa25fe6784a662a7068b5b5a45a4 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 11 Dec 2016 18:19:25 +1100 Subject: [PATCH] Pass SQL connection into nested method to prevent deadlock. Discussed with Sam on Slack 11 Dec #general. --- .../src/mineplex/core/chatsnap/SnapshotRepository.java | 4 ++-- .../src/mineplex/core/report/data/ReportRepository.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java index 261f081f8..2b638186e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java @@ -163,11 +163,11 @@ public class SnapshotRepository } } - public CompletableFuture getSnapshotMetadata(int snapshotId) + public CompletableFuture getSnapshotMetadata(Connection connection, int snapshotId) { CompletableFuture future = CompletableFuture.supplyAsync(() -> { - try (Connection connection = DBPool.getAccount().getConnection()) + try { try (PreparedStatement statement = connection.prepareStatement(GET_METADATA)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index fb1e6ffb6..8a491b798 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -372,7 +372,7 @@ public class ReportRepository if (!resultSet.wasNull()) { SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getRepository() - .getSnapshotMetadata(snapshotId).join(); + .getSnapshotMetadata(connection, snapshotId).join(); report.setSnapshotMetadata(snapshotMetadata); }