Skip to content

Commit 46a43cd

Browse files
authored
Clarify error message in BackwardsCompatibilityTestBase and fix resource leak in existence check (#15248)
1 parent b39cf5e commit 46a43cd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lucene/backward-codecs/src/test/org/apache/lucene/backward_index/BackwardsCompatibilityTestBase.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ protected BackwardsCompatibilityTestBase(
126126
public void setUp() throws Exception {
127127
super.setUp();
128128
assertNull(
129-
"Index name " + version + " should not exist found",
130-
TestAncientIndicesCompatibility.class.getResourceAsStream(
131-
indexName(LATEST_PREVIOUS_MAJOR)));
129+
"Index name "
130+
+ LATEST_PREVIOUS_MAJOR
131+
+ " for latest previous major (not yet released, so may need to be added to Version.java) should not exist, but found",
132+
BackwardsCompatibilityTestBase.class.getResource(indexName(LATEST_PREVIOUS_MAJOR)));
132133
if (supportsVersion(version) == false) {
133134
assertNull(
134-
"Index name " + version + " should not exist found",
135-
TestAncientIndicesCompatibility.class.getResourceAsStream(indexName(version)));
135+
"Index name " + version + " should not exist as it is not supported, but found",
136+
BackwardsCompatibilityTestBase.class.getResource(indexName(version)));
136137
}
137138
assumeTrue("This test doesn't support version: " + version, supportsVersion(version));
138139
if (version.equals(Version.LATEST)) {
@@ -141,7 +142,7 @@ public void setUp() throws Exception {
141142
} else {
142143
Path dir = createTempDir();
143144
InputStream resource =
144-
TestAncientIndicesCompatibility.class.getResourceAsStream(indexName(version));
145+
BackwardsCompatibilityTestBase.class.getResourceAsStream(indexName(version));
145146
assertNotNull("Index name " + version + " not found: " + indexName(version), resource);
146147
TestUtil.unzip(resource, dir);
147148
directory = newFSDirectory(dir);
@@ -215,7 +216,7 @@ private static List<Version> getAllCurrentReleasedVersions() {
215216
for (Iterator<Version> it = currentReleasedVersions.iterator(); it.hasNext(); ) {
216217
Version version = it.next();
217218
String indexName = String.format(Locale.ROOT, "index.%s-cfs.zip", version);
218-
if (TestAncientIndicesCompatibility.class.getResource(indexName) == null) {
219+
if (BackwardsCompatibilityTestBase.class.getResource(indexName) == null) {
219220
missingVersions.add(version);
220221
it.remove();
221222
}

0 commit comments

Comments
 (0)