aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iain Lewis (JIRA)" <j...@apache.org>
Subject [jira] [Created] (ARIES-1254) ManifestHeaderProcessor.parseFilter throws IllegalArgumentException on legal filter containing '='
Date Fri, 03 Oct 2014 12:16:33 GMT
Iain Lewis created ARIES-1254:
---------------------------------

             Summary: ManifestHeaderProcessor.parseFilter throws IllegalArgumentException
on legal filter containing '='
                 Key: ARIES-1254
                 URL: https://issues.apache.org/jira/browse/ARIES-1254
             Project: Aries
          Issue Type: Bug
          Components: Util
         Environment: All envs
            Reporter: Iain Lewis


I have an OSGI bundle where the manifest contains a capability requirement of:

Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.6))"

Trying to parse this with the parseFilter() method throws an IlegalArgumentException. The
code snippet below is sufficient to reproduce the problem.

                    String attribute = "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=1.6))\"";
                    List<GenericMetadata> requirementMetadata = ManifestHeaderProcessor.parseRequirementString(attribute);
                    for (GenericMetadata metaData : requirementMetadata) {
                        if (metaData.getNamespace().equals("osgi.ee")) {
                            Map<String, String> dirs = metaData.getDirectives();
                            for (String key : dirs.keySet()) {
                                if (key.equals("filter")) {
                                    Map<String, String> filter = ManifestHeaderProcessor.parseFilter(dirs.get(key));
// Throws IllegalArgumentException
                                }
                            }
                        }
                    }


There is a fairly trivial fix for this. Looking at the version of the source from here:

https://svn.apache.org/repos/asf/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/manifest/ManifestHeaderProcessor.java

On line 713:
          else if (LESS_EQ_OP.equals(op))
            upperVersion = value;
          else
            throw new IllegalArgumentException();
        }


Should become this:

                    } else if (LESS_EQ_OP.equals(op)) {
                        upperVersion = value;
                    } else if (EQ_OP.equals(op)) {
                           lowerVersion = value;
                           upperVersion = value;
                    } else {
                        throw new IllegalArgumentException();
                    }

And a new constant of EQ_OP needs to be added



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message