The problem is that in the while loop (line 549), if only part of the byte array is written to the buffer, the position is updated but the length is not. I'm attaching a patch.
Here is some code that fails in r13087, and works with the patch. I ran into this while serializing mixed lisp/java objects, which is pretty well reflected in this snippet.
Cheers,
-david k.
(let* ((len 5000) (big-object (jnew-array "double" len))) (dotimes (i len) (setf (jarray-ref big-object i) (+ i 0.1)))
(with-open-file (stream "foo.dat" :direction :output :element-type 'unsigned-byte) (let ((p (jnew (jconstructor "java.io.ObjectOutputStream" "java.io.OutputStream") (jcall (jmethod "org.armedbear.lisp.Stream" "getWrappedOutputStream") stream))))
(jcall (jmethod "java.io.ObjectOutputStream" "writeObject" "java.lang.Object") p big-object)
(jcall (jmethod "java.io.ObjectOutputStream" "flush") p)))
(let ((big-object2 (with-open-file (stream "foo.dat" :direction :input :element-type 'unsigned-byte) (let ((p (jnew (jconstructor "java.io.ObjectInputStream" "java.io.InputStream") (jcall (jmethod "org.armedbear.lisp.Stream" "getWrappedInputStream") stream)))) (jcall (jmethod "java.io.ObjectInputStream" "readObject") p)))))
(dotimes (i len) (format t "~A ~A~%" (jarray-ref big-object i) (jarray-ref big-object2 i)))))
On 12/5/10 6:25 AM, David Kirkman wrote:
The problem is that in the while loop (line 549), if only part of the byte array is written to the buffer, the position is updated but the length is not. I'm attaching a patch.
Applied in [svn r13088][1]. Thanks for the patch!
[1]: http://trac.common-lisp.net/armedbear/changeset/13088
armedbear-devel@common-lisp.net