From f084b1570836f43dcfe02fa7963183815cdc0569 Mon Sep 17 00:00:00 2001
From: Henry Pinkard <7969470+henrypinkard@users.noreply.github.com>
Date: Wed, 2 Aug 2023 10:28:17 -0400
Subject: [PATCH] improve shutdown behavior when writing exception happens
---
java/pom.xml | 2 +-
.../micromanager/ndtiffstorage/NDTiffAPI.java | 6 +++++
.../ndtiffstorage/NDTiffStorage.java | 24 +++++++++++--------
3 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/java/pom.xml b/java/pom.xml
index 204ced4..883f8f5 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.micro-manager.ndtiffstorage
NDTiffStorage
- 2.13.2
+ 2.14.0
jar
NDTiff Storage file format
Java-based writer and reader used for NDTiffStorage format
diff --git a/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffAPI.java b/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffAPI.java
index 7be19a0..75bc3fd 100644
--- a/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffAPI.java
+++ b/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffAPI.java
@@ -42,6 +42,12 @@ public Future putImage(Object pixels, JSONObject metadata, HashMap axessss,
boolean rgb, int bitDepth, int imageHeight, int imageWidth) {
- checkWritingException();
+ try {
+ checkForWritingException();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
TaggedImage ti = new TaggedImage(pixels, metadata);
// Make sure each axis takes all integer or all string values
@@ -904,7 +907,11 @@ static String getAxesString(HashMap axes) {
@Override
public Future putImageMultiRes( Object pixels, JSONObject metadata, final HashMap axes,
boolean rgb, int bitDepth, int imageHeight, int imageWidth) {
- checkWritingException();
+ try {
+ checkForWritingException();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
TaggedImage ti = new TaggedImage(pixels, metadata);
if (!firstImageAdded_) {
//technically this doesnt need to be parsed here, because it should be fixed for the whole
@@ -1049,10 +1056,9 @@ public void run() {
}
/**
- * Singal to finish writing and block until everything pending is done
+ * Signal to finish writing and block until everything pending is done
*/
public void finishedWriting() {
- checkWritingException();
if (loaded_) {
return;
}
@@ -1139,12 +1145,10 @@ public JSONObject getDisplaySettings() {
}
public void closeAndWait() throws InterruptedException {
- checkWritingException();
doClose();
}
public void close() {
- checkWritingException();
//run close on a new thread
new Thread(new Runnable() {
@Override