Skip to content

Commit 4d30c51

Browse files
committed
Fix resource leaks failing tests
1 parent a6d03e0 commit 4d30c51

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/java/org/apache/cassandra/index/sai/SSTableContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ private SSTableContext(SSTableContext copy)
6565
this.primaryKeyMapFactory = copy.primaryKeyMapFactory;
6666
}
6767

68-
@SuppressWarnings("resource")
6968
public static SSTableContext create(SSTableReader sstable, IndexComponents.ForRead perSSTableComponents)
7069
{
7170
var onDiskFormat = perSSTableComponents.onDiskFormat();

src/java/org/apache/cassandra/index/sai/disk/v1/PartitionAwarePrimaryKeyMap.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ public class PartitionAwarePrimaryKeyMap implements PrimaryKeyMap
5959
@ThreadSafe
6060
public static class PartitionAwarePrimaryKeyMapFactory implements Factory
6161
{
62+
private final IndexComponents.ForRead perSSTableComponents;
6263
private final LongArray.Factory tokenReaderFactory;
6364
private final LongArray.Factory offsetReaderFactory;
65+
private final MetadataSource metadata;
6466
private final KeyFetcher keyFetcher;
6567
private final IPartitioner partitioner;
6668
private final PrimaryKey.Factory primaryKeyFactory;
@@ -74,13 +76,15 @@ public PartitionAwarePrimaryKeyMapFactory(IndexComponents.ForRead perSSTableComp
7476
{
7577
try
7678
{
77-
MetadataSource metadata = MetadataSource.loadMetadata(perSSTableComponents);
79+
this.perSSTableComponents = perSSTableComponents;
80+
this.metadata = MetadataSource.loadMetadata(perSSTableComponents);
81+
MetadataSource metadata = MetadataSource.loadMetadata(this.perSSTableComponents);
7882

7983
IndexComponent.ForRead offsetsComponent = perSSTableComponents.get(IndexComponentType.OFFSETS_VALUES);
8084
IndexComponent.ForRead tokensComponent = perSSTableComponents.get(IndexComponentType.TOKEN_VALUES);
8185

82-
NumericValuesMeta offsetsMeta = new NumericValuesMeta(metadata.get(offsetsComponent));
83-
NumericValuesMeta tokensMeta = new NumericValuesMeta(metadata.get(tokensComponent));
86+
NumericValuesMeta offsetsMeta = new NumericValuesMeta(this.metadata.get(offsetsComponent));
87+
NumericValuesMeta tokensMeta = new NumericValuesMeta(this.metadata.get(tokensComponent));
8488

8589
count = tokensMeta.valueCount;
8690
token = tokensComponent.createFileHandle();

src/java/org/apache/cassandra/index/sai/disk/v2/RowAwarePrimaryKeyMap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class RowAwarePrimaryKeyMap implements PrimaryKeyMap
7171
@ThreadSafe
7272
public static class RowAwarePrimaryKeyMapFactory implements Factory
7373
{
74+
private final IndexComponents.ForRead perSSTableComponents;
7475
private final LongArray.Factory tokenReaderFactory;
7576
private final SortedTermsReader sortedTermsReader;
7677
private final long count;
@@ -88,6 +89,7 @@ public RowAwarePrimaryKeyMapFactory(IndexComponents.ForRead perSSTableComponents
8889
{
8990
try
9091
{
92+
this.perSSTableComponents = perSSTableComponents;
9193
MetadataSource metadataSource = MetadataSource.loadMetadata(perSSTableComponents);
9294
NumericValuesMeta tokensMeta = new NumericValuesMeta(metadataSource.get(perSSTableComponents.get(IndexComponentType.TOKEN_VALUES)));
9395
count = tokensMeta.valueCount;

0 commit comments

Comments
 (0)