geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Oberg (JIRA)" <j...@apache.org>
Subject [jira] Commented: (GERONIMO-5172) ImageDownload.java bug in writing to buffer in 'Accessing JDBC in Web applications' tutorial page
Date Mon, 08 Mar 2010 15:55:28 GMT

    [ https://issues.apache.org/jira/browse/GERONIMO-5172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12842705#action_12842705
] 

Scott Oberg commented on GERONIMO-5172:
---------------------------------------

Yes, the typical result is that you'll end up with downloaded data files
that are multiples of the buffer size. 

e.g.
n * 4096 in this example. 


i.e. You'll get the downloaded data, plus garbage data at the end of the
buffer since the read size from the input stream is never used to
validate the amount of data to write to the output stream.

Scott



Scott Oberg
Senior Software Engineer
Engineering & Systems Div.
--
SRI International
4119 Broad Street, Suite 210
San Luis Obispo, CA 93401
(805) 542-9330 ext. 104
-- 
 O       __O 
'Z.    _-\<,_   ~~>-^O~~ 
/>    (_)/ (_)      7 



> ImageDownload.java bug in writing to buffer in 'Accessing JDBC in Web applications' tutorial
page
> -------------------------------------------------------------------------------------------------
>
>                 Key: GERONIMO-5172
>                 URL: https://issues.apache.org/jira/browse/GERONIMO-5172
>             Project: Geronimo
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: documentation
>    Affects Versions: 2.2
>         Environment: N/A
>            Reporter: Scott Oberg
>            Priority: Trivial
>
> The 'Accessing JDBC in Web applications' page in the tutorial contains a bug in the ImageDownload.java
sample code.
> http://cwiki.apache.org/GMOxDOC22/accessing-jdbc-in-web-applications.html
> The line 'out.write(b);' should be replaced with 'out.write(b, 0, c);' and a check to
make sure there is data to read.
> {noformat} 
> original code:
> while (c != -1) {
>   c = ip.read(b);
>   out.write(b);
>   out.flush();
> }
> fix:
> while (c != -1) {
>   c = ip.read(b);
>   if (c > 0) {
>     out.write(b, 0, c);
>     out.flush();
>   }
> }
> {noformat} 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message