Skip to content
Snippets Groups Projects
Commit cd831fa2 authored by Kurt Partridge's avatar Kurt Partridge
Browse files

Fix JsonWriter bug

JsonWriter requires that data be written to it, else close() will throw
an exception.

Change-Id: I596c5363e063cc75bcda55e0a506eefb3f17bd67
parent 3970352e
No related branches found
No related tags found
No related merge requests found
......@@ -108,10 +108,14 @@ public class ResearchLog {
@Override
public Object call() throws Exception {
try {
if (mHasWrittenData) {
mJsonWriter.endArray();
mHasWrittenData = false;
// TODO: This is necessary to avoid an exception. Better would be to not even
// open the JsonWriter if the file is not even opened unless there is valid data
// to write.
if (!mHasWrittenData) {
mJsonWriter.beginArray();
}
mJsonWriter.endArray();
mHasWrittenData = false;
mJsonWriter.flush();
mJsonWriter.close();
if (DEBUG) {
......@@ -159,6 +163,12 @@ public class ResearchLog {
public Object call() throws Exception {
try {
if (mHasWrittenData) {
// TODO: This is necessary to avoid an exception. Better would be to not
// even open the JsonWriter if the file is not even opened unless there is
// valid data to write.
if (!mHasWrittenData) {
mJsonWriter.beginArray();
}
mJsonWriter.endArray();
mJsonWriter.close();
mHasWrittenData = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment