Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5B887116E9 for ; Thu, 18 Sep 2014 12:46:09 +0000 (UTC) Received: (qmail 85248 invoked by uid 500); 18 Sep 2014 12:46:09 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 85180 invoked by uid 500); 18 Sep 2014 12:46:09 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 85168 invoked by uid 99); 18 Sep 2014 12:46:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Sep 2014 12:46:08 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of 10527@liferay.com designates 209.85.216.174 as permitted sender) Received: from [209.85.216.174] (HELO mail-qc0-f174.google.com) (209.85.216.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Sep 2014 12:46:04 +0000 Received: by mail-qc0-f174.google.com with SMTP id m20so1115577qcx.19 for ; Thu, 18 Sep 2014 05:45:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=je+0H08k3uN89gPTQrLll1TlViUUW0it5KxdPmCQL4A=; b=NzXX5Kma/Cf3VN+k3Dzf3lVVAZvHBSxDtIBoZmS9VKpCL4faoLxIxuXfWYnOs1TmAV p3UDVUYkKovKYNc9+Ry1G46T2NI2n+r05p4pH1H8Nw/KZzEY1nvm9PUEJ5ugYqbZtaeJ vad4ydPEPvcX8dHRZMqYMMQPjIhGZBQk5Awl2PAkUP3twrjded3lfjMP+irfvW0M0/nj ji/OCSeUNpvfLX8eWtCarxe9E3zdP6D2PxiSyBEsJ1l53aZbenMICkosw1JmtQp9+e9I TGcDLLhrWbtmoL3vI5JpEscUh67EBYnDRpstr3P92JoYRCbKHhEeVLN6iUDlFRzw5IBb hx/w== X-Gm-Message-State: ALoCoQl6qMBuwfjOC84ZNCyPoayrLWtQEsL0VDuMzbK9Y1ms4YxrlURNE8wPVNV/b/+gPmz0Pk8N MIME-Version: 1.0 X-Received: by 10.224.165.1 with SMTP id g1mr4606206qay.97.1411044343339; Thu, 18 Sep 2014 05:45:43 -0700 (PDT) Received: by 10.96.85.9 with HTTP; Thu, 18 Sep 2014 05:45:43 -0700 (PDT) In-Reply-To: <541AD180.6020302@ungoverned.org> References: <541A8D08.4080707@ascert.com> <541AD180.6020302@ungoverned.org> Date: Thu, 18 Sep 2014 08:45:43 -0400 Message-ID: Subject: Re: Stream Closed issue loading bundles over HTTP From: Raymond Auge To: Apache Felix Developers Content-Type: multipart/alternative; boundary=089e0153819ad8f9150503565ca4 X-Virus-Checked: Checked by ClamAV on apache.org --089e0153819ad8f9150503565ca4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable May I ask to see the stacktrace of the original error? I want to correlate a strange jetty error from non-felix code against this one because they seem eerily similar. (long shot) - Ray On Thu, Sep 18, 2014 at 8:35 AM, Richard S. Hall wrote: > I guess the question to ask is what behavior is the correct behavior if > there really is an exception on close? This patch will ignore every > exception, not just ones that occurs because of a double close (although = it > seems to me a double close should be a no-op, not sure why it throws, but > that is another issue). > > Does it make sense that every close exception is ignored and the user is > never alerted? Granted, there isn't much we can do, but often such errors > are better breaking things than just being ignored. > > -> richard > > > On 9/18/14 03:43 , Rob Walker wrote: > >> Just wanted to check this one before I raise a JIRA, in case it's known >> and/or already been fixed or being worked on. >> >> In one of our models we provision our application over WebStart, which >> causes bundles to be loaded over HTTP. Occasionally we get a Stream Clos= ed >> exception being thrown from the Jetty HTTP server (the server serving up >> the code is also running under Felix). >> >> What seems to happen is a double close of the input stream - which throw= s >> an error. I've include the notes below from our developer who found this= . >> >> It's a pretty simple mod to ignore the exception on second close >> (highlighted red below) - assuming everyone is happy this is an ok appro= ach. >> >> -- Rob >> >> =3D=3D=3D >> >> /It turns out the problem was arising when caching the VersaTest jar >> files. Whilst they are coming across via WebStart ok, an error was being >> thrown because the stream used to read them was being closed multiple ti= mes >> and at some point the close operation causes an exception that isn't cau= ght >> so stops the load. This error occurs in Felix in the JarRevision class,= in >> the initialize() method. I put a simple fix in that ignored the error on >> close. So in the code below, a close on the input stream was being calle= d >> in the //BundleCache.copyStreamToFile(is, m_bundleFile) and in the >> bottom finally block (you can see below where I put in that disregarding >> catch. (Note, I suspect that also the input stream could be closed in t= he >> //((HttpURLConnection) conn).disconnect() //as well. But it is explicitl= y >> closed in the copyStreamToFile.)//// >> /// >> >> if (!byReference) >> { >> URLConnection conn =3D null; >> try >> { >> if (is =3D=3D null) >> { >> // Do it the manual way to have a chance to >> // set request properties such as proxy auth= . >> URL url =3D BundleCache.getSecureAction(). >> createURL( >> null, getLocation(), null); >> conn =3D url.openConnection(); >> >> // Support for http proxy authentication. >> String auth =3D BundleCache.getSecureAction(= ) >> .getSystemProperty("http.proxyAuth", null); >> if ((auth !=3D null) && (auth.length() > 0)) >> { >> if ("http".equals(url.getProtocol()) || >> "https".equals(url.getProtocol())) >> { >> String base64 =3D >> Util.base64Encode(auth); >> conn.setRequestProperty( >> "Proxy-Authorization", "Basic " + base64); >> } >> } >> is =3D BundleCache.getSecureAction() >> .getURLConnectionInputStream(conn); >> } >> >> // Save the bundle jar file. >> BundleCache.copyStreamToFile(is, m_bundleFile); >> } >> finally >> { >> // This is a hack to fix an issue on Android, >> where >> // HttpURLConnections are not properly closed. >> (FELIX-2728) >> if ((conn !=3D null) && (conn instanceof >> HttpURLConnection)) >> { >> ((HttpURLConnection) conn).disconnect(); >> } >> } >> } >> } >> } >> finally >> { >> if (is !=3D null) >> { >> try >> { >> is.close(); >> } catch (IOException ioe) >> { >> /* Catch and disregard exception on close as could >> already have been closed, >> either in the disconnect or in the >> copyStreamToProfile >> */ >> >> } >> >> } >> } >> >> >> >> >> >> >> >> >> >> >> >> > --=20 *Raymond Aug=C3=A9* (@rotty3000) Senior Software Architect *Liferay, Inc.* (@Liferay) --089e0153819ad8f9150503565ca4--