reduce cyclomatic complexity

This commit is contained in:
mgabriel 2018-08-15 15:21:14 +02:00
parent 8c65ba088f
commit 4a047df314

View File

@ -139,16 +139,7 @@ public class ChronicleStore<T> implements FluxStore<T> {
if (wireStore != null) {
File file = wireStore.file();
if (file != null) {
try {
boolean deleted = file.delete();
if (deleted) {
LOGGER.trace("file {} deleted after read", file.getAbsolutePath());
} else {
LOGGER.error("Could not delete file {}", file.getAbsolutePath());
}
} catch (Exception e) {
LOGGER.error("Could not delete file {}", file.getAbsolutePath(), e);
}
deleteWireStore(file);
} else {
LOGGER.error("Could not find file for cycle {}", previousCycle);
}
@ -157,6 +148,23 @@ public class ChronicleStore<T> implements FluxStore<T> {
}
}
private void deleteWireStore(File file) {
try {
boolean deleted = file.delete();
logDeletionResult(file, deleted);
} catch (Exception e) {
LOGGER.error("Could not delete file {}", file.getAbsolutePath(), e);
}
}
private void logDeletionResult(File file, boolean deleted) {
if (deleted) {
LOGGER.trace("file {} deleted after read", file.getAbsolutePath());
} else {
LOGGER.error("Could not delete file {}", file.getAbsolutePath());
}
}
private void readAndSendValue(FluxSink<T> sink, BytesIn b) {
int size = b.readInt();
byte[] bytes = new byte[size];