You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Manuel Freiholz <m....@cadenas.de> on 2006/02/07 10:07:16 UTC

svn-javahl: streamFileContent and large files

Hi,
i just subscribed to this mailing list and i hope i write to the correct 
adress.
I just started development with svn so be indulgent with me :P

I'm not sure, but i think i found a bug in the new method of the 
svn-javahl-1.3 -> "streamFileContent(..)". I looked in the native code 
and found this ( File: SVNClient.cpp, Line 2405, Method: 
streamFileContent ):

----
    while (contentSize > 0)
    {
        size_t readSize = bufSize > contentSize ? contentSize : bufSize;
        Err = svn_stream_read(read_stream, (char *)bufData, &readSize);
        if (Err != NULL)
        {
            env->ReleaseByteArrayElements(buffer, bufData, 0);
            svn_stream_close(read_stream);
            JNIUtil::handleSVNError(Err);
            return;
        }

        env->ReleaseByteArrayElements(buffer, bufData, JNI_COMMIT);
        env->CallVoidMethod(outputStream, writeMethod, buffer, 0, readSize);
        if (JNIUtil::isJavaExceptionThrown())
        {
            env->ReleaseByteArrayElements(buffer, bufData, 0);
            svn_stream_close(read_stream);
            return;
        }
        contentSize -= readSize;
    }
----

The code is reading from the "read_stream"  and fills the OutputStream 
completly. -> No Buffering possible in my java.

So i have the problem in my code that i can not download large files 
like 80 MB and bigger directly via "streamFileContent" from subversion.

Is there anybody with the same problem who knows a solutions?

Greetings,
 - Manuel

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn-javahl: streamFileContent and large files

Posted by Patrick Mayweg <ma...@qint.de>.
Hi Manuel,
for your use, you need a method which returns an InputStream with native 
methods. This InputStream could read the data as needed from the svn_stream.
But i am not sure if the container does not buffer the data anyway. If 
that is the case, you cannot send 80MB to a client without extending the 
heap size of the container.
Regards,
Patrick

P.S. This thread may move more to J2EE Servlet programming, then to svn. 
So I think its best to take it of this list.

Manuel Freiholz wrote:
> Hi Patrick,
> here a short description:
>
> I'm writting a svn-web-browser like ViewCVS.
> I can view files and download files. When the user clicks download he 
> should get the file
> directly. I don't want to save the file temporary on the server and 
> send it to the user.
>
> Im using the "streamFileContent" in a Servlet but i got the problem 
> that i can not buffer the
> way from the server to the user. Before i get the filled stream, i 
> already got a heap overflow.
>
> I tried to write the OutputStream to the ServletOutputStream but.. 
> same error. (with large files)
>
> Regards,
> Manuel.
>
>
> Patrick Mayweg wrote:
>
>> Hi Manuel,
>> I do not understand what kind of buffering you want to do. Could you 
>> explain that to me? If you do not want to use too much memory, a 
>> FileOutputStream would write the file content directly to the disk.
>> Regards,
>> Patrick
>>
>> Manuel Freiholz wrote:
>>
>>> Hi,
>>> i just subscribed to this mailing list and i hope i write to the 
>>> correct adress.
>>> I just started development with svn so be indulgent with me :P
>>>
>>> I'm not sure, but i think i found a bug in the new method of the 
>>> svn-javahl-1.3 -> "streamFileContent(..)". I looked in the native 
>>> code and found this ( File: SVNClient.cpp, Line 2405, Method: 
>>> streamFileContent ):
>>>
>>> ----
>>>    while (contentSize > 0)
>>>    {
>>>        size_t readSize = bufSize > contentSize ? contentSize : bufSize;
>>>        Err = svn_stream_read(read_stream, (char *)bufData, &readSize);
>>>        if (Err != NULL)
>>>        {
>>>            env->ReleaseByteArrayElements(buffer, bufData, 0);
>>>            svn_stream_close(read_stream);
>>>            JNIUtil::handleSVNError(Err);
>>>            return;
>>>        }
>>>
>>>        env->ReleaseByteArrayElements(buffer, bufData, JNI_COMMIT);
>>>        env->CallVoidMethod(outputStream, writeMethod, buffer, 0, 
>>> readSize);
>>>        if (JNIUtil::isJavaExceptionThrown())
>>>        {
>>>            env->ReleaseByteArrayElements(buffer, bufData, 0);
>>>            svn_stream_close(read_stream);
>>>            return;
>>>        }
>>>        contentSize -= readSize;
>>>    }
>>> ----
>>>
>>> The code is reading from the "read_stream"  and fills the 
>>> OutputStream completly. -> No Buffering possible in my java.
>>>
>>> So i have the problem in my code that i can not download large files 
>>> like 80 MB and bigger directly via "streamFileContent" from subversion.
>>>
>>> Is there anybody with the same problem who knows a solutions?
>>>
>>> Greetings,
>>> - Manuel
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
>>> For additional commands, e-mail: dev-help@subversion.tigris.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
>> For additional commands, e-mail: dev-help@subversion.tigris.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn-javahl: streamFileContent and large files

Posted by Manuel Freiholz <m....@cadenas.de>.
Hi Patrick,
here a short description:

I'm writting a svn-web-browser like ViewCVS.
I can view files and download files. When the user clicks download he 
should get the file
directly. I don't want to save the file temporary on the server and send 
it to the user.

Im using the "streamFileContent" in a Servlet but i got the problem that 
i can not buffer the
way from the server to the user. Before i get the filled stream, i 
already got a heap overflow.

I tried to write the OutputStream to the ServletOutputStream but.. same 
error. (with large files)

Regards,
Manuel.


Patrick Mayweg wrote:

> Hi Manuel,
> I do not understand what kind of buffering you want to do. Could you 
> explain that to me? If you do not want to use too much memory, a 
> FileOutputStream would write the file content directly to the disk.
> Regards,
> Patrick
>
> Manuel Freiholz wrote:
>
>> Hi,
>> i just subscribed to this mailing list and i hope i write to the 
>> correct adress.
>> I just started development with svn so be indulgent with me :P
>>
>> I'm not sure, but i think i found a bug in the new method of the 
>> svn-javahl-1.3 -> "streamFileContent(..)". I looked in the native 
>> code and found this ( File: SVNClient.cpp, Line 2405, Method: 
>> streamFileContent ):
>>
>> ----
>>    while (contentSize > 0)
>>    {
>>        size_t readSize = bufSize > contentSize ? contentSize : bufSize;
>>        Err = svn_stream_read(read_stream, (char *)bufData, &readSize);
>>        if (Err != NULL)
>>        {
>>            env->ReleaseByteArrayElements(buffer, bufData, 0);
>>            svn_stream_close(read_stream);
>>            JNIUtil::handleSVNError(Err);
>>            return;
>>        }
>>
>>        env->ReleaseByteArrayElements(buffer, bufData, JNI_COMMIT);
>>        env->CallVoidMethod(outputStream, writeMethod, buffer, 0, 
>> readSize);
>>        if (JNIUtil::isJavaExceptionThrown())
>>        {
>>            env->ReleaseByteArrayElements(buffer, bufData, 0);
>>            svn_stream_close(read_stream);
>>            return;
>>        }
>>        contentSize -= readSize;
>>    }
>> ----
>>
>> The code is reading from the "read_stream"  and fills the 
>> OutputStream completly. -> No Buffering possible in my java.
>>
>> So i have the problem in my code that i can not download large files 
>> like 80 MB and bigger directly via "streamFileContent" from subversion.
>>
>> Is there anybody with the same problem who knows a solutions?
>>
>> Greetings,
>> - Manuel
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
>> For additional commands, e-mail: dev-help@subversion.tigris.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn-javahl: streamFileContent and large files

Posted by Patrick Mayweg <ma...@qint.de>.
Hi Manuel,
I do not understand what kind of buffering you want to do. Could you 
explain that to me? If you do not want to use too much memory, a 
FileOutputStream would write the file content directly to the disk.
Regards,
Patrick

Manuel Freiholz wrote:
> Hi,
> i just subscribed to this mailing list and i hope i write to the 
> correct adress.
> I just started development with svn so be indulgent with me :P
>
> I'm not sure, but i think i found a bug in the new method of the 
> svn-javahl-1.3 -> "streamFileContent(..)". I looked in the native code 
> and found this ( File: SVNClient.cpp, Line 2405, Method: 
> streamFileContent ):
>
> ----
>    while (contentSize > 0)
>    {
>        size_t readSize = bufSize > contentSize ? contentSize : bufSize;
>        Err = svn_stream_read(read_stream, (char *)bufData, &readSize);
>        if (Err != NULL)
>        {
>            env->ReleaseByteArrayElements(buffer, bufData, 0);
>            svn_stream_close(read_stream);
>            JNIUtil::handleSVNError(Err);
>            return;
>        }
>
>        env->ReleaseByteArrayElements(buffer, bufData, JNI_COMMIT);
>        env->CallVoidMethod(outputStream, writeMethod, buffer, 0, 
> readSize);
>        if (JNIUtil::isJavaExceptionThrown())
>        {
>            env->ReleaseByteArrayElements(buffer, bufData, 0);
>            svn_stream_close(read_stream);
>            return;
>        }
>        contentSize -= readSize;
>    }
> ----
>
> The code is reading from the "read_stream"  and fills the OutputStream 
> completly. -> No Buffering possible in my java.
>
> So i have the problem in my code that i can not download large files 
> like 80 MB and bigger directly via "streamFileContent" from subversion.
>
> Is there anybody with the same problem who knows a solutions?
>
> Greetings,
> - Manuel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org