git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Commented] (ARIES-1254) ManifestHeaderProcessor.parseFilter throws IllegalArgumentException on legal filter containing '='


    [ https://issues.apache.org/jira/browse/ARIES-1254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16678216#comment-16678216 ] 

Grzegorz Grzybek commented on ARIES-1254:
-----------------------------------------

I wasn't able to track it - the parser never supported {{version=xxx}}.

> 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
>            Priority: Major
>
> 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.
> {noformat}
>                     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
>                                 }
>                             }
>                         }
>                     }
> {noformat}
> 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:
> {noformat}
>           else if (LESS_EQ_OP.equals(op))
>             upperVersion = value;
>           else
>             throw new IllegalArgumentException();
>         }
> {noformat}
> Should become this:
> {noformat}
>                     } else if (LESS_EQ_OP.equals(op)) {
>                         upperVersion = value;
>                     } else if (EQ_OP.equals(op)) {
>                            lowerVersion = value;
>                            upperVersion = value;
>                     } else {
>                         throw new IllegalArgumentException();
>                     }
> {noformat}
> And a new constant of EQ_OP needs to be added



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)