am b20c7ee7: am 1f99e04b: Merge "Fix JsonWriter bug"

* commit 'b20c7ee75093ae9c111daf64d9e4f8509d692824':
  Fix JsonWriter bug
main
Kurt Partridge 2013-05-15 10:36:24 -07:00 committed by Android Git Automerger
commit 4a885f254d
1 changed files with 13 additions and 3 deletions

View File

@ -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;