Skip to content

Commit 3a96c7d

Browse files
committed
#5086 Improve stream error handling
1 parent 18df3df commit 3a96c7d

File tree

1 file changed

+30
-37
lines changed
  • stroom-data/stroom-data-store-impl-fs/src/main/java/stroom/data/store/impl/fs

1 file changed

+30
-37
lines changed

stroom-data/stroom-data-store-impl-fs/src/main/java/stroom/data/store/impl/fs/FsTarget.java

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -169,35 +169,33 @@ public void close() {
169169
throw new DataException("Target already closed");
170170
}
171171

172-
try {
173-
if (!deleted) {
174-
// If we get error on closing the stream we must return it to the caller
175-
RuntimeException streamCloseException = null;
176-
try {
177-
closeStreams();
178-
} catch (final RuntimeException e) {
179-
streamCloseException = e;
180-
}
172+
if (!deleted) {
173+
// If we get error on closing the stream we must return it to the caller
174+
RuntimeException streamCloseException = null;
175+
try {
176+
closeStreams();
177+
} catch (final RuntimeException e) {
178+
streamCloseException = e;
179+
}
181180

182-
// Only write meta for the root target.
183-
if (parent == null) {
184-
// Update attributes and write the manifest.
185-
updateAttribute(this, MetaFields.RAW_SIZE, String.valueOf(getStreamSize()));
186-
updateAttribute(this, MetaFields.FILE_SIZE, String.valueOf(getTotalFileSize()));
187-
writeManifest();
188-
189-
if (streamCloseException == null) {
190-
// Unlock will update the meta data so set it back on the stream
191-
// target so the client has the up to date copy
192-
unlock(getMeta(), getAttributes());
193-
} else {
194-
throw streamCloseException;
195-
}
181+
// Only write meta for the root target.
182+
if (parent == null) {
183+
// Update attributes and write the manifest.
184+
updateAttribute(this, MetaFields.RAW_SIZE, String.valueOf(getStreamSize()));
185+
updateAttribute(this, MetaFields.FILE_SIZE, String.valueOf(getTotalFileSize()));
186+
writeManifest();
187+
188+
if (streamCloseException == null) {
189+
// Unlock will update the meta data so set it back on the stream
190+
// target so the client has the up to date copy
191+
unlock(getMeta(), getAttributes());
192+
} else {
193+
throw streamCloseException;
196194
}
197195
}
198-
} finally {
199-
closed = true;
200196
}
197+
198+
closed = true;
201199
}
202200

203201
private void unlock(final Meta meta, final AttributeMap attributeMap) {
@@ -224,19 +222,14 @@ public void delete() {
224222
}
225223

226224
try {
227-
try {
228-
// Close the stream target.
229-
closeStreams();
230-
} finally {
231-
closed = true;
232-
233-
// Only delete the root target.
234-
if (parent == null) {
235-
// Mark the target meta as deleted.
236-
this.meta = metaService.updateStatus(meta, Status.LOCKED, Status.DELETED);
237-
}
238-
}
225+
// Close the stream target.
226+
closeStreams();
239227
} finally {
228+
// Only delete the root target.
229+
if (parent == null) {
230+
// Mark the target meta as deleted.
231+
this.meta = metaService.updateStatus(meta, Status.LOCKED, Status.DELETED);
232+
}
240233
deleted = true;
241234
}
242235
}

0 commit comments

Comments
 (0)