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] [Updated] (ARIES-1254) ManifestHeaderProcessor.parseFilter throws IllegalArgumentException on legal filter containing '='
Date Fri, 03 Oct 2014 12:19:34 GMT

     [ https://issues.apache.org/jira/browse/ARIES-1254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Iain Lewis updated ARIES-1254:
------------------------------
    Description: 
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:
{noformat}
          else if (LESS_EQ_OP.equals(op))
            upperVersion = value;
          else
            throw new IllegalArgumentException();
        }
{noformat}

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

  was:
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:
<pre>
          else if (LESS_EQ_OP.equals(op))
            upperVersion = value;
          else
            throw new IllegalArgumentException();
        }
</pre>
          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


> 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:
> {noformat}
>           else if (LESS_EQ_OP.equals(op))
>             upperVersion = value;
>           else
>             throw new IllegalArgumentException();
>         }
> {noformat}
> 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