Skip to content

Commit f5cdd1e

Browse files
committed
#5130 Fix raw size meta bug
1 parent de4bfe4 commit f5cdd1e

File tree

2 files changed

+97
-32
lines changed

2 files changed

+97
-32
lines changed

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

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

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-
}
180-
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;
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+
} finally {
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;
194+
}
195+
}
194196
}
195197
}
198+
} finally {
199+
outputStream = null;
200+
closed = true;
196201
}
197-
198-
closed = true;
199202
}
200203

201204
private void unlock(final Meta meta, final AttributeMap attributeMap) {
@@ -225,16 +228,20 @@ public void delete() {
225228
// Close the stream target.
226229
closeStreams();
227230
} 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);
231+
try {
232+
// Only delete the root target.
233+
if (parent == null) {
234+
// Mark the target meta as deleted.
235+
this.meta = metaService.updateStatus(meta, Status.LOCKED, Status.DELETED);
236+
}
237+
} finally {
238+
outputStream = null;
239+
deleted = true;
232240
}
233-
deleted = true;
234241
}
235242
}
236243

237-
private synchronized void closeStreams() {
244+
private void closeStreams() {
238245
RuntimeException exception = null;
239246

240247
// Close the stream target.
@@ -244,8 +251,6 @@ private synchronized void closeStreams() {
244251
} catch (final IOException e) {
245252
LOGGER.error(() -> "closeStreams() - Error on closing stream " + this, e);
246253
exception = new UncheckedIOException(e);
247-
} finally {
248-
outputStream = null;
249254
}
250255
}
251256

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
* Issue **#5130** : Fix raw size meta bug.
2+
3+
4+
```sh
5+
# ********************************************************************************
6+
# Issue title: Raw size is set to `0.0B`
7+
# Issue link: https://github.com/gchq/stroom/issues/5130
8+
# ********************************************************************************
9+
10+
# ONLY the top line will be included as a change entry in the CHANGELOG.
11+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
12+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
13+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
14+
# 'Fixed nasty bug'.
15+
#
16+
# Examples of acceptable entries are:
17+
#
18+
#
19+
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
20+
#
21+
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
22+
#
23+
# * Fix bug with no associated GitHub issue.
24+
25+
26+
# --------------------------------------------------------------------------------
27+
# The following is random text to make this file unique for git's change detection
28+
# h2vcQ03HLlVScRnKfkAZsVWHjA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Nii5rhiOqGT2BHTpo2
54+
# Ee3EYTsFTcoIyw20nZKGnaSu06LwMf28KVxSxja51yRPHMPSa335jFgQWRbGG1SK3Nn1HU4bEYwS4dK4
55+
# g5BwwTTgoqXan7OolydUbKFIFLiv4cbpt4hGqni3BEvGNDglZGB8vexAQibfb5lPPmPtVQJhwygWjdTn
56+
# SM4fTL2ax6AtKGjsgcWimg2xhv5rP1QkTDMQ5JIsG1bqXrs7s2ZqZpxbziYbTh2U2z5L3hNKhTWQ39rD
57+
# G3K1YH0hcmL4nGkBUTkr1S7AJMKRuhuZaMGqD07pWe4nFvq0GptMgEbomv5ig05FkTerxOsZYY0lfVqH
58+
# --------------------------------------------------------------------------------
59+
60+
```

0 commit comments

Comments
 (0)