From 7d72ca0b20334aba077e3a01d7b12f6f34618076 Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Thu, 9 May 2013 14:25:28 -0700 Subject: Avoid JsonWriter multi-write error JsonWriter requires that its clients pass it only a single top-level object. The existing implementation tries to make code cleaner by having mJsonWriter never be null, and instead use a global static "NULL_JSON_WRITER" that just discards data. But because JsonWriter complains if more than one top-level object is passed, making this a global object does not work. This change instead copes with mJsonWriter being null. Change-Id: Ia37ccfc8646e91f11a64713dd92d2846eb86ac54 --- .../src/com/android/inputmethod/research/ResearchLogger.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'java/src/com/android/inputmethod/research/ResearchLogger.java') diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 4e839f972..b3c0faf29 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -422,11 +422,19 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang // Commit mCurrentLogUnit before closing. commitCurrentLogUnit(); - mMainLogBuffer.shiftAndPublishAll(); + try { + mMainLogBuffer.shiftAndPublishAll(); + } catch (final IOException e) { + Log.w(TAG, "IOException when publishing LogBuffer", e); + } logStatistics(); commitCurrentLogUnit(); mMainLogBuffer.setIsStopping(); - mMainLogBuffer.shiftAndPublishAll(); + try { + mMainLogBuffer.shiftAndPublishAll(); + } catch (final IOException e) { + Log.w(TAG, "IOException when publishing LogBuffer", e); + } mMainResearchLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS); mFeedbackLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS); -- cgit v1.2.3-83-g751a