Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1F6D49950 for ; Wed, 4 Apr 2012 19:52:40 +0000 (UTC) Received: (qmail 98010 invoked by uid 500); 4 Apr 2012 19:52:40 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 97956 invoked by uid 500); 4 Apr 2012 19:52:40 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 97911 invoked by uid 99); 4 Apr 2012 19:52:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 19:52:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 19:52:38 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id E5CF1358640 for ; Wed, 4 Apr 2012 19:52:18 +0000 (UTC) Date: Wed, 4 Apr 2012 19:52:18 +0000 (UTC) From: =?utf-8?Q?Andreas_Kr=C3=BCger_=28Updated=29_=28JIRA=29?= To: issues@cxf.apache.org Message-ID: <975048100.13687.1333569138942.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <459098391.13669.1333568898705.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (CXF-4227) AttachmentDeserializerTest contains buggy code for reading an InputStream. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CXF-4227?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:all-tabpanel ] Andreas Kr=C3=BCger updated CXF-4227: -------------------------------- Attachment: AttachmentDeserializerTest.patch The patch I promised. =20 > AttachmentDeserializerTest contains buggy code for reading an InputStream= . > -------------------------------------------------------------------------= - > > Key: CXF-4227 > URL: https://issues.apache.org/jira/browse/CXF-4227 > Project: CXF > Issue Type: Bug > Components: WS-* Components > Reporter: Andreas Kr=C3=BCger > Priority: Minor > Labels: patch > Attachments: AttachmentDeserializerTest.patch > > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > Browsing through the CXF code, I stumbled over the following in Attachmen= tDeserializerTest, method testCXF3383(): > {code} > for (int x =3D 1; x < 50; x++) { > String cid =3D "1882f79d-e20a-4b36-a222-7a75518cf395-" + x + "@cxf.ap= ache.org"; > DataSource ds =3D AttachmentUtil.getAttachmentDataSource(cid, message= .getAttachments()); > byte bts[] =3D new byte[1024]; > =20 > InputStream ins =3D ds.getInputStream(); > int count =3D ins.read(bts, 0, bts.length); > int sz =3D ins.read(bts, count, bts.length - count); > while (sz !=3D -1) { > sz =3D ins.read(bts, count, bts.length - count); > } > assertEquals(x + 1, count); > } > {code} > I think some "count +=3D sz" has been forgotten. Details: > * The while-loop does nothing to change the test result. > * Endless loop, should "ins" ever deliver 1025 bytes or more. > * The fix is obvious, I'll attach a patch. > The problem does not show as long as "ins" contains less than 1024 bytes = and all its content is delivered with the first read operation. So no funct= ional impairment, just code hygiene. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira