Skip to content

Commit 18702dc

Browse files
committed
fix(test): get cache field from N5KeyValueReader class
Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
1 parent 0b8d4c9 commit 18702dc

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/test/java/org/janelia/saalfeldlab/n5/http/HttpReaderFsWriter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
import org.janelia.saalfeldlab.n5.GsonKeyValueN5Writer;
4040
import org.janelia.saalfeldlab.n5.KeyValueAccess;
4141
import org.janelia.saalfeldlab.n5.N5Exception;
42-
import org.janelia.saalfeldlab.n5.codec.BlockCodecInfo;
43-
import org.janelia.saalfeldlab.n5.codec.DataCodecInfo;
42+
import org.janelia.saalfeldlab.n5.N5KeyValueReader;
4443

4544
import java.io.Serializable;
4645
import java.lang.reflect.Field;
@@ -70,8 +69,13 @@ public <W extends GsonKeyValueN5Writer, R extends GsonKeyValueN5Reader> HttpRead
7069
if (cachedReader.cacheMeta()) {
7170
/* Hack necessary to test HTTP reader caching without creating the data entirely first */
7271
try {
73-
// Access the private 'cache' field in the reader
74-
final Field cacheField = reader.getClass().getDeclaredField("cache");
72+
// Access the private 'cache' field in the reader (or the N5KeyValueReader as a fallback)
73+
Field cacheField;
74+
try {
75+
cacheField = reader.getClass().getDeclaredField("cache");
76+
} catch (NoSuchFieldException e) {
77+
cacheField = N5KeyValueReader.class.getDeclaredField("cache");
78+
}
7579
cacheField.setAccessible(true);
7680

7781
// Set the value of 'cache' to the one from writer.getCache()

0 commit comments

Comments
 (0)