uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Baptiste Gaillard <b_gaill...@hotmail.com>
Subject Potential problems in the XmlInputSource class...
Date Wed, 10 Mar 2010 16:35:31 GMT


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

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)
      if((this.urlConnection != null) && (this.urlConnection instanceof JarURLConnection))

      mURL = null;

Is it possible to include those modifications in the next UIMA release ? 


Baptiste Gaillard

Hotmail arrive sur votre téléphone ! Compatible Iphone, Windows Phone, Blackberry, …
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message