You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2018/08/02 21:24:45 UTC
[geode] branch develop updated: GEODE-5517: Have StatArchiveReader
implement AutoCloseable (#2249)
This is an automated email from the ASF dual-hosted git repository.
jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new c5b923b GEODE-5517: Have StatArchiveReader implement AutoCloseable (#2249)
c5b923b is described below
commit c5b923b0d83d00d5fa2bbcd84d783d51600e899b
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Thu Aug 2 14:24:41 2018 -0700
GEODE-5517: Have StatArchiveReader implement AutoCloseable (#2249)
- This commit also fixes a resource leak in
StatTypesAreRolledOverRegressionTest which was causing the test to fail on
Windows.
---
.../StatTypesAreRolledOverRegressionTest.java | 31 +++++++++++-----------
.../internal/statistics/StatArchiveReader.java | 2 +-
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatTypesAreRolledOverRegressionTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatTypesAreRolledOverRegressionTest.java
index 520cdca..37e61ea 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatTypesAreRolledOverRegressionTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatTypesAreRolledOverRegressionTest.java
@@ -137,21 +137,22 @@ public class StatTypesAreRolledOverRegressionTest {
private void verifyStatisticsTypeIsInArchiveFile(final File archiveFile,
final int expectedResources) throws IOException {
- StatArchiveReader reader = new StatArchiveReader(new File[] {archiveFile}, null, false);
-
- // compare all resourceInst values against what was printed above
-
- List<ResourceInst> resources = reader.getResourceInstList();
- if (expectedResources > 0) {
- assertThat(resources).hasAtLeastOneElementOfType(ResourceInst.class);
- }
-
- for (ResourceInst resourceInstance : resources) {
- if (resourceInstance == null)
- continue;
- assertThat(resourceInstance.getName()).isNotNull();
- assertThat(resourceInstance.getType()).isNotNull();
- assertThat(resourceInstance.getType().getName()).isEqualTo(this.statisticsType.getName());
+ try (StatArchiveReader reader = new StatArchiveReader(new File[] {archiveFile}, null, false)) {
+
+ // compare all resourceInst values against what was printed above
+
+ List<ResourceInst> resources = reader.getResourceInstList();
+ if (expectedResources > 0) {
+ assertThat(resources).hasAtLeastOneElementOfType(ResourceInst.class);
+ }
+
+ for (ResourceInst resourceInstance : resources) {
+ if (resourceInstance == null)
+ continue;
+ assertThat(resourceInstance.getName()).isNotNull();
+ assertThat(resourceInstance.getType()).isNotNull();
+ assertThat(resourceInstance.getType().getName()).isEqualTo(this.statisticsType.getName());
+ }
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java
index 6cb3bc7..174a742 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java
@@ -50,7 +50,7 @@ import org.apache.geode.internal.logging.DateFormatter;
/**
* StatArchiveReader provides APIs to read statistic snapshots from an archive file.
*/
-public class StatArchiveReader implements StatArchiveFormat {
+public class StatArchiveReader implements StatArchiveFormat, AutoCloseable {
protected static final NumberFormat nf = NumberFormat.getNumberInstance();
static {