felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Gruber <ogru...@us.ibm.com>
Subject Small bug...
Date Tue, 19 Sep 2006 15:56:15 GMT
Just stumbled on a small bug

    public FindEntriesEnumeration(Felix felix,
        BundleImpl bundle, String path, String filePattern, boolean 
recurse)
    {
        m_felix = felix;
        m_bundle = bundle;
        m_path = path;
        m_enumeration = m_bundle.getInfo().getCurrentModule()
            .getContentLoader().getContent().getEntries();
        m_recurse = recurse;

        // Sanity check the parameters.
        if (m_path == null)
        {
            throw new IllegalArgumentException("The path for findEntries() 
cannot be null.");
        }
        // Strip leading '/' if present.
        if ((m_path.length() > 0) && (m_path.charAt(0) == '/'))
        {
            m_path = m_path.substring(1);
        }
        // Add a '/' to the end if not present.
==>     if ((m_path.length() > 0) && (m_path.charAt(path.length() - 1) != 
'/'))
        {                                           ****
            m_path = m_path + "/";
        }

        // File pattern defaults to "*" if not specified.
        filePattern = (filePattern == null) ? "*" : filePattern;

        m_filePattern = parseSubstring(filePattern);

        m_next = findNext();
    }

It should not mix path and m_path... on a path like /META-INF/Foo/ 
it fails raising a StringIndexOutOfBoundsException
Here is the fix:

==>     if ((m_path.length() > 0) && (m_path.charAt(m_path.length() - 1) 
!= '/'))
 _______

Cheers, 

Olivier Gruber, Ph.D.
Persistent & Distributed Object Platforms and Frameworks
IBM TJ Watson Research Center


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message