Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 34940 invoked from network); 10 Apr 2009 00:48:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Apr 2009 00:48:20 -0000 Received: (qmail 33360 invoked by uid 500); 10 Apr 2009 00:48:19 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 33289 invoked by uid 500); 10 Apr 2009 00:48:19 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 33279 invoked by uid 99); 10 Apr 2009 00:48:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Apr 2009 00:48:19 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [98.136.44.63] (HELO smtp108.prem.mail.sp1.yahoo.com) (98.136.44.63) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 10 Apr 2009 00:48:09 +0000 Received: (qmail 25760 invoked from network); 10 Apr 2009 00:47:47 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Message-Id:From:To:In-Reply-To:Content-Type:Content-Transfer-Encoding:Mime-Version:Subject:Date:References:X-Mailer; b=44ykxS1XobKE7SlUh0xkfmPP+EQPI1fBuSvGJk1RoLa9NXZQeSdvWWVXUEt4DjcgrZuQH1ZCcxeUPVZCKV7OcqqN5OX9uM6mZ4SbCNhC9TqyNV5huyxiAH7lE5JhPWCaWW18a8VQHDnTCNkY04J3S2ClkD64p84wDdIFAqzL//Y= ; Received: from unknown (HELO ?10.11.55.39?) (david_jencks@76.76.148.215 with plain) by smtp108.prem.mail.sp1.yahoo.com with SMTP; 10 Apr 2009 00:47:47 -0000 X-YMail-OSG: 9TQ8NFwVM1mSuKzCB2bN9_DJ95f3yJCHseqAb7PfGy6DVWYkAjapcifY9KSnAXtElqc.yGtZBFlEPc1huLUQWF.6BGir2U.crYsTLIfoiCR4nIK9NkSjY01d0TRjxBTnhIi_ACOYa2qNoIMjlEyYUv4K.PV2Wfti2w3EfWzpLg_Job5J1G6lU7X4j0p6p7t1Cq.1C5Gof8lAIQxY0NXRdpAIti8B7YwYKXTTHuVSRfOBgyc.fZ94JODB8xQ7sghCPgedqbGiqienCEf.kmkTMnia5FqNxk5b_n6llAOqJNpmqwkiEv3acaoVNIrq0KVo5OcNgPqbGSPF0xD.mq8SUTa9GnldLY6RpbWbFXmyBoQ- X-Yahoo-Newman-Property: ymail-3 Message-Id: <1569129E-1B96-43DF-A4B5-FE9185D4ACE3@yahoo.com> From: David Jencks To: dev@openjpa.apache.org In-Reply-To: <49DE2DE8.9040409@apache.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: Streaming BLOB/LOB : who closes the stream? Date: Thu, 9 Apr 2009 17:47:46 -0700 References: <49DE2DE8.9040409@apache.org> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org On Apr 9, 2009, at 10:18 AM, Simone Gianni wrote: > Hi all, > I noticed that when using streaming BLOB, after consuming the > stream, OpenJPA does not close it. This is causing lots of problems > to us, cause we're working on a system that needs to populate lots > of blobs from incoming files, submit them to a number of > "processors" and then save them back to file system storage. Since > the FileInputStream we are passing to OpenJPA during the "fetch" > phase never gets closed, after a few seconds the system runs out of > resources. > > Ignacio, can you confirm this is the case? > > Since once the stream is used it is (99% of the times) unusable > again, OpenJPA should close it in the DBDictionary class, eventually > in the method that consumes it (it should be > copy(InputStream,OutputStream) IIRC). > > Documentation says nothing about the need to hold a reference to the > stream passed to a bean to close it after OpenJPA finished using it, > and I think it would be quite a pain to close the streams from the > application layer, cause that would mean keeping a reference to > them. In plain english, the contract should be something like "If > you call the getter and obtain an input stream, it's your job to > close it, if you call a setter passing an input stream, it's OpenJPA > job to close it". > > I'm testing right now a patch (3 lines) to close it after OpenJPA > used it. If I'm not missing something and you agree this is a bug, > I'll open an issue and attach the patch to it to keep track of the > problem. I tend to disagree with you about the design and think whoever opens the stream should be responsible for closing it. I've repeatedly had to work around the behavior you are advocating as implemented in IIRC xerces. IIRC the situation I keep running into is an input stream from a jar entry where closing the input stream closes the entire jar file. In order to use xerces we had to wrap the input stream from the jar entry in something that ignores the close method. This experience has convinced me that something that reads from a supplied input stream has no business deciding whether to close it. thanks david jencks > > > Simone > > -- > Simone Gianni CEO Semeru s.r.l. Apache Committer > http://www.simonegianni.it/ >