Author: michiel
Date: 2009-06-03 15:36:17 +0200 (Wed, 03 Jun 2009)
New Revision: 35617
Modified:
mmbase/trunk/src/org/mmbase/util/SerializableInputStream.java
Log:
several fixes related to MMB-1810. Avoid storing blobs in memory.
Modified: mmbase/trunk/src/org/mmbase/util/SerializableInputStream.java
===================================================================
--- mmbase/trunk/src/org/mmbase/util/SerializableInputStream.java
2009-06-03 13:21:47 UTC (rev 35616)
+++ mmbase/trunk/src/org/mmbase/util/SerializableInputStream.java
2009-06-03 13:36:17 UTC (rev 35617)
@@ -282,7 +282,25 @@
")";
}
+ protected static boolean inputStreamEquals(SerializableInputStream in1,
SerializableInputStream in2) throws IOException {
+ in1.mark(Integer.MAX_VALUE);
+ in2.mark(Integer.MAX_VALUE);
+ final byte[] buffer1 = new byte[1024];
+ final byte[] buffer2 = new byte[1024];
+ while (true) {
+ int n1 = in1.read(buffer1);
+ int n2 = in2.read(buffer2);
+ if (n1 != n2) return false;
+ if (n1 == -1) break;
+ if ( ! java.util.Arrays.equals(buffer1, buffer2)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
@Override
public boolean equals(Object o) {
if (o instanceof SerializableInputStream) {
@@ -292,7 +310,8 @@
(getSize() == s.getSize()) &&
(getName() == null ? s.getName() == null :
getName().equals(s.getName())) &&
(getContentType() == null ? s.getContentType() == null :
getContentType().equals(s.getContentType())) &&
- java.util.Arrays.equals(get(), s.get());
+ (fileMark == s.fileMark) &&
+ ((file != null && file.equals(s.file)) ||
inputStreamEquals(this, s));
} catch (IOException ioe) {
log.error(ioe);
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs