diff --git a/pom.xml b/pom.xml index 7e90388..6df21f0 100644 --- a/pom.xml +++ b/pom.xml @@ -138,7 +138,7 @@ 1.1.1 - 3.1.1 + 3.1.3 1.0.2 diff --git a/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueReader.java b/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueReader.java index a18d542..3a1dfde 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueReader.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueReader.java @@ -505,7 +505,7 @@ protected JsonElement zarrToN5DatasetAttributes(final JsonElement elem ) { attrs.add(DatasetAttributes.BLOCK_SIZE_KEY, attrs.get(ZArrayAttributes.chunksKey)); attrs.addProperty(DatasetAttributes.DATA_TYPE_KEY, zattrs.getDType().getDataType().toString()); - JsonElement e = attrs.get(ZArrayAttributes.compressorKey); + final JsonElement e = attrs.get(ZArrayAttributes.compressorKey); if (e == JsonNull.INSTANCE) { attrs.add(DatasetAttributes.COMPRESSION_KEY, gson.toJsonTree(new RawCompression())); } else { @@ -636,7 +636,7 @@ public DataBlock readBlock( try (final LockedChannel lockedChannel = keyValueAccess.lockForReading(absolutePath)) { return readBlock(lockedChannel.newInputStream(), zarrDatasetAttributes, gridPosition); - } catch (final IOException | UncheckedIOException e) { + } catch (final Throwable e) { throw new N5IOException( "Failed to read block " + Arrays.toString(gridPosition) + " from dataset " + pathName, e); @@ -685,9 +685,9 @@ protected static DataBlock readBlock( return dataBlock; } - private static ZarrStringDataBlock readVLenStringBlock(InputStream in, BlockReader reader, ByteArrayDataBlock byteBlock) throws IOException { + private static ZarrStringDataBlock readVLenStringBlock(final InputStream in, final BlockReader reader, final ByteArrayDataBlock byteBlock) throws IOException { // read whole chunk and deserialize; this should be improved - ZarrStringDataBlock dataBlock = new ZarrStringDataBlock(byteBlock.getSize(), byteBlock.getGridPosition(), new String[0]); + final ZarrStringDataBlock dataBlock = new ZarrStringDataBlock(byteBlock.getSize(), byteBlock.getGridPosition(), new String[0]); if (reader instanceof BloscCompression) { // Blosc reader reads actual data and doesn't care about buffer size (but needs special treatment in data block) reader.read(dataBlock, in); diff --git a/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueWriter.java b/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueWriter.java index b922879..e681210 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueWriter.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/zarr/ZarrKeyValueWriter.java @@ -27,7 +27,6 @@ import java.io.IOException; import java.io.OutputStream; -import java.io.UncheckedIOException; import java.util.Arrays; import java.util.Map; import java.util.function.Supplier; @@ -45,9 +44,9 @@ import org.janelia.saalfeldlab.n5.LockedChannel; import org.janelia.saalfeldlab.n5.N5Exception; import org.janelia.saalfeldlab.n5.N5Exception.N5IOException; -import org.janelia.saalfeldlab.n5.cache.N5JsonCache; import org.janelia.saalfeldlab.n5.N5URI; import org.janelia.saalfeldlab.n5.RawCompression; +import org.janelia.saalfeldlab.n5.cache.N5JsonCache; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -137,6 +136,7 @@ public ZarrKeyValueWriter( } } + @Override public void setVersion(final String path) throws N5Exception { setVersion(path, false); @@ -192,7 +192,7 @@ else if ( getCache().isDataset(normalPath, ZARRAY_FILE)){ // since the contents is null try { keyValueAccess.createDirectories(absoluteGroupPath(normalPath)); - } catch (final IOException | UncheckedIOException e) { + } catch (final Throwable e) { throw new N5Exception.N5IOException("Failed to create group " + path, e); } @@ -245,7 +245,7 @@ else if (getCache().isGroup(normalPath, ZGROUP_FILE)) { final String absPath = absoluteGroupPath(normalPath); try { keyValueAccess.createDirectories(absPath); - } catch (final IOException | UncheckedIOException e) { + } catch (final Throwable e) { throw new N5IOException("Failed to create directories " + absPath, e); } @@ -386,8 +386,8 @@ protected ZArrayAttributes createZArrayAttributes(final DatasetAttributes datase /** * Write the contents of the attributes argument to the .zarray file at - * the given pathName. Overwrites and existing .zarray. - * + * the given pathName. Overwrites and existing .zarray. + * * @param pathName the group / dataset path * @param attributes ZArray attributes * @throws N5Exception the exception @@ -407,7 +407,7 @@ protected void deleteJsonResource(final String normalPath, final String jsonName final String absolutePath = keyValueAccess.compose(uri, normalPath, jsonName); try { keyValueAccess.delete(absolutePath); - } catch (IOException | UncheckedIOException e1) { + } catch (final Throwable e1) { throw new N5IOException("Failed to delete " + absolutePath, e1); } } @@ -423,7 +423,7 @@ protected void writeJsonResource( final String absolutePath = keyValueAccess.compose(uri, normalPath, jsonName); try (final LockedChannel lock = keyValueAccess.lockForWriting(absolutePath)) { GsonUtils.writeAttributes(lock.newWriter(), attributes, gson); - } catch (final IOException | UncheckedIOException e) { + } catch (final Throwable e) { throw new N5IOException("Failed to write " + absolutePath, e); } } @@ -540,7 +540,7 @@ public void writeBlock( zarrDatasetAttributes, dataBlock); } - } catch (final IOException | UncheckedIOException e) { + } catch (final Throwable e) { throw new N5IOException( "Failed to write block " + Arrays.toString(dataBlock.getGridPosition()) + " into dataset " + path, e); @@ -567,7 +567,7 @@ public boolean deleteBlock( try { if (keyValueAccess.exists(absolutePath)) keyValueAccess.delete(absolutePath); - } catch (final IOException | UncheckedIOException e) { + } catch (final Throwable e) { throw new N5IOException( "Failed to delete block " + Arrays.toString(gridPosition) + " from dataset " + path, e); @@ -730,7 +730,7 @@ protected static ZarrJsonElements build(final JsonObject obj, final Gson gson ) *

* Used when re-directing attributes to the appropriate zarr metadata files according to * attribute keys. - * + * * @param obj the json attributes object * @param gson the json * @param mapN5Attributes if true, map n5 attribute keys to corresponding zarr attribute keys @@ -856,5 +856,4 @@ static void reorder(final JsonArray array) { array.set(j, a); } } - }