wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1025633 - /incubator/wink/trunk/wink-json4j/src/main/java/org/apache/wink/json4j/JSONArray.java
Date Wed, 20 Oct 2010 16:36:40 GMT
Author: bluk
Date: Wed Oct 20 16:36:40 2010
New Revision: 1025633

URL: http://svn.apache.org/viewvc?rev=1025633&view=rev
Log:
Fix for JSONArray's write method

It wasn't flushing the buffered writer if used.
JSONObject currently does it correctly so copied it over.

Modified:
    incubator/wink/trunk/wink-json4j/src/main/java/org/apache/wink/json4j/JSONArray.java

Modified: incubator/wink/trunk/wink-json4j/src/main/java/org/apache/wink/json4j/JSONArray.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-json4j/src/main/java/org/apache/wink/json4j/JSONArray.java?rev=1025633&r1=1025632&r2=1025633&view=diff
==============================================================================
--- incubator/wink/trunk/wink-json4j/src/main/java/org/apache/wink/json4j/JSONArray.java (original)
+++ incubator/wink/trunk/wink-json4j/src/main/java/org/apache/wink/json4j/JSONArray.java Wed
Oct 20 16:36:40 2010
@@ -967,10 +967,12 @@ public class JSONArray extends ArrayList
         //Try to avoid double-buffering or buffering in-memory
         //writers.
         Class writerClass = writer.getClass();
+        boolean flushIt = false;
         if (!StringWriter.class.isAssignableFrom(writerClass) &&
             !CharArrayWriter.class.isAssignableFrom(writerClass) &&
             !BufferedWriter.class.isAssignableFrom(writerClass)) {
             writer = new BufferedWriter(writer);
+            flushIt = true;
         }
 
         if (verbose) {
@@ -986,6 +988,15 @@ public class JSONArray extends ArrayList
             jex.initCause(iox);
             throw jex;
         }
+        if (flushIt) {
+            try {
+                writer.flush();
+            } catch (Exception ex) { 
+                JSONException jex = new JSONException("Error during buffer flush");
+                jex.initCause(ex);
+                throw jex;
+            }
+        }
         return writer;
     }
 



Mime
View raw message