Greetings, While working on enhancements for JavaHL I ran into a problem implementing svn_txdelta_apply call because txdelta_next_window would segfault while trying to calculate the streams checksum. I traced it down to code in the InputStream.cpp that returns -1 when end of stream is reached. -1 does not work with txdelta_next_window because it expects 0 to indicate end of stream. Spot checking other svn functions, that use streams, shows that they check for greater than 0 return value as indication that there is data to be process. Also as far as I can tell apr_size_t maps to size_t, which implies that it is a signed type making 0 more sensible than -1 as end of steam indicator.
[[[ JavaHL: Fix return value from the java svn_stream_t read function to be compatible with the txdelta_next_window function [ in subversion/bindings/javahl/native ] * InputStream.cpp (read): Return 0 instead of -1 as expected by the txdelta_next_window function ]]] Thank you, Vladimir
Index: subversion/bindings/javahl/native/InputStream.cpp =================================================================== --- subversion/bindings/javahl/native/InputStream.cpp (revision 1328758) +++ subversion/bindings/javahl/native/InputStream.cpp (working copy) @@ -99,6 +99,14 @@ svn_error_t *InputStream::read(void *baton, char * if (JNIUtil::isJavaExceptionThrown()) return SVN_NO_ERROR; + /* + * Convert -1 from InputStream.read that means EOF, 0 which is subversion equivalent + */ + if(jread == -1) + { + jread = 0; + } + // Put the Java byte array into a helper object to retrieve the // data bytes. JNIByteArray outdata(data, true); @@ -107,7 +115,7 @@ svn_error_t *InputStream::read(void *baton, char * // Catch when the Java method tells us it read too much data. if (jread > (jint) *len) - jread = -1; + jread = 0; // In the case of success copy the data back to the Subversion // buffer.