Baptiste Gaillard
Thu, 18 Mar 2010 07:07:38 -0700
Patch provided in JIRA: https://issues.apache.org/jira/browse/UIMA-1746
Baptiste Gaillard
> Date: Thu, 11 Mar 2010 10:26:36 +0100
> From: twgo...@gmx.de
> To: uima-dev@incubator.apache.org
> Subject: Re: Potential problems in the XmlInputSource class...
>
> Sure. Please open a JIRA issue and provide a patch. You can
> just paste your message into the issue.
>
> --Thilo
>
> On 3/10/2010 17:35, Baptiste Gaillard wrote:
> >
> > Hi,
> >
> > I've read multiple messages about UIMA and OSGI on this forum.
> >
> > On our project we have successfully integrated UIMA components inside OSGI
> > Bundle (our solution provides an automatic OSGI Bundle genration system
> > which take PEAR files so developpers do not have to worry about OSGI).
> >
> > We have encountered a JAR locking problem inside the XmlInputSource class,
> > the problem comes from this instruction (WmlInputSource line 90) :
> >
> > mInputStream = mURL.openStream()
> >
> > When we do that with a URL which refers to a file inside a JAR file a
> > JarURLConnection is used.
> >
> > JarURLConnection seems to have a bug because in the destroy method of
> > XmlInputSource those instruction do not close the ZipFile associated to the
> > JARUrlConnection.
> >
> > if (mInputStream != null)
> > {
> > mInputStream.close(); // DO NOT CLOSE THE ASSOCIATED ZipFile !!!
> > }
> >
> >
> > The bug has been reported in the SUN Bug Database: // see
> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4386865
> >
> > This is problematic with OSGI because we can unload our Bundles (UIMA
> > components in our case ;-) ) but never delete theme from the file system
> > after...
> >
> > The solution to close the ZipFiles in XmlInputSource is to add the
> > following instructions in the constructor and destroy method:
> >
> > private URLConnection urlConnection;
> >
> > public XMLInputSource(String aUrlOrFileName) throws IOException {
> > //try as URL first, then as file name
> > try {
> > mURL = new URL(aUrlOrFileName);
> > }
> > catch (MalformedURLException e) {
> > mURL = new File(aUrlOrFileName).toURL();
> > }
> >
> > this.urlConnection = mURL.openConnection();
> >
> > mInputStream = mURL.openStream();
> > }
> >
> >
> > public void close()
> > throws IOException
> > {
> > if (mInputStream != null)
> > {
> > mInputStream.close();
> > }
> >
> > if((this.urlConnection != null) && (this.urlConnection instanceof
> > JarURLConnection))
> > {
> > ((JarURLConnection)urlConnection).getJarFile().close();
> > }
> >
> > mURL = null;
> > }
> >
> > Is it possible to include those modifications in the next UIMA release ?
> >
> > Thanks,
> >
> > Baptiste Gaillard
> >
> >
> >
> >
> >
> > _________________________________________________________________
> > Hotmail arrive sur votre téléphone ! Compatible Iphone, Windows Phone,
> > Blackberry, …
> > http://www.messengersurvotremobile.com/?d=Hotmail
_________________________________________________________________
Découvrez comment SURFER DISCRETEMENT sur un site de rencontres !
http://clk.atdmt.com/FRM/go/206608211/direct/01/