Repository: cassandra Updated Branches: refs/heads/trunk 644676b08 -> 7082b64fc
ninja: fix resource leak warning Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7082b64f Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7082b64f Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7082b64f Branch: refs/heads/trunk Commit: 7082b64fc9a9a14c9f9cb9a492c0b25d109f4edc Parents: 644676b Author: Blake Eggleston <[email protected]> Authored: Wed Aug 22 08:15:55 2018 -0700 Committer: Blake Eggleston <[email protected]> Committed: Wed Aug 22 08:15:55 2018 -0700 ---------------------------------------------------------------------- .../apache/cassandra/service/StorageProxy.java | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/7082b64f/src/java/org/apache/cassandra/service/StorageProxy.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java index 7fdf591..58f08d4 100644 --- a/src/java/org/apache/cassandra/service/StorageProxy.java +++ b/src/java/org/apache/cassandra/service/StorageProxy.java @@ -2243,12 +2243,23 @@ public class StorageProxy implements StorageProxyMBean { List<PartitionIterator> concurrentQueries = new ArrayList<>(concurrencyFactor); List<ReadRepair> readRepairs = new ArrayList<>(concurrencyFactor); - for (int i = 0; i < concurrencyFactor && ranges.hasNext(); i++) + + try + { + for (int i = 0; i < concurrencyFactor && ranges.hasNext(); i++) + { + @SuppressWarnings("resource") // response will be closed by concatAndBlockOnRepair, or in the catch block below + SingleRangeResponse response = query(ranges.next(), i == 0); + concurrentQueries.add(response); + readRepairs.add(response.readRepair); + ++rangesQueried; + } + } + catch (Throwable t) { - SingleRangeResponse response = query(ranges.next(), i == 0); - concurrentQueries.add(response); - readRepairs.add(response.readRepair); - ++rangesQueried; + for (PartitionIterator response: concurrentQueries) + response.close(); + throw t; } Tracing.trace("Submitted {} concurrent range requests", concurrentQueries.size()); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
