db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r901167 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java
Date Wed, 20 Jan 2010 12:46:17 GMT
Author: kristwaa
Date: Wed Jan 20 12:46:17 2010
New Revision: 901167

URL: http://svn.apache.org/viewvc?rev=901167&view=rev
Log:
DERBY-4519: Infinite loop in StreamFileContainer.writeColumn.
Merged fix from trunk (r901165, derby-4519-2a-infinite_loop_fixes.diff).

Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 20 12:46:17 2010
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,882732,884163,887246,892912,897161
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,882732,884163,887246,892912,897161,901165

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java?rev=901167&r1=901166&r2=901167&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java
Wed Jan 20 12:46:17 2010
@@ -731,16 +731,24 @@
 		if (column instanceof InputStream) 
         {
 			InputStream inColumn = (InputStream) column;
-			int bufferLen = inColumn.available();
+            // Set a reasonable buffer size.
+            // To avoid extremely inefficient reads, and an infinite loop when
+            // InputStream.available() returns zero, a lower limit is set on
+            // the buffer size. To avoid using too much memory (especially in
+            // multi-user environments) an upper limit is set as well.
+            // The limits can be tuned, but note that using a too high default
+            // or lower limit can put unnecessary pressure on the memory sub-
+            // system and the GC process.
+            int bufferLen = Math.min(Math.max(inColumn.available(), 64), 8192);
 			byte[] bufData = new byte[bufferLen];
 
 			do 
             {
-				int lenRead = inColumn.read(bufData, bufferLen, 0);
+                int lenRead = inColumn.read(bufData);
 				if (lenRead != -1) 
                 {
 					fieldDataLength += lenRead;
-					out.write(bufData, lenRead, 0);
+                    out.write(bufData, 0, lenRead);
 				} 
                 else
                 {



Mime
View raw message