aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Ross (JIRA)" <>
Subject [jira] [Resolved] (ARIES-1387) Make equals and hashCode comparisons within the header, clause, and parameter hierarchies based on equivalency rather than string equals.
Date Thu, 17 Sep 2015 14:15:04 GMT


John Ross resolved ARIES-1387.
    Resolution: Fixed

I committed the pull request with the following modifications.

Reinforce the immutablity and safe publication of the header, clause, and parameter hierarchies:
(1) no default constructors; (2) all fields are final; (3) no subclass methods are called
in the constructor; (4) synchronize access to mutable fields that are visible to subclasses
(for example, the Provide-Capability header does its own parameter parsing and modifies the
clause collection after it has been published).

Pull out more common functionality within the header, clause, and parameter hierarchies.

Do not use the original header value as part of the equals and hashCode methods; otherwise,
it basically amounts to a string equals comparison.

Remove unnecessary implementations of equals and hashCode and rely on implementations in the
abstract classes as much as possible. Currently, the only exception is the filter directive
so that the filter comparison is not string equals.

Rewrite equals and hashCode in a format more familiar to this committer. There may have been
nothing wrong with the original implementations.

Support equivalent filter comparisons rather than just string equals:
(1) Cache a simple filter and override equals/hashCode in the filter directive rather than
rely on a string comparison in the abstract parameter.
(2) Override equals/hashCode in the simple filter rather than rely on an identity comparison.
(3) Use sets rather than lists in the simple filter so that equivalent filters are equal and
have the same hashCode. For example, the following two filters are equal: (&(a=b)(y=z))
and (&(y=z)(a=b)).

In the equality test:
(1) Ensure that equivalent versions and clauses are equal.
(2) Include default values for the effective directive.
(3) Use the correct version range attribute name (i.e. "bundle-version" instead of "version")
for the Require-Bundle header.
(4) Make the subsystem manifest equality check more robust so that default values and equivalent
orderings are included.
(5) Use valid clause syntax. For example, the path must come first.
(6) Remove unnecessary references to header names. The header name is implied based on which
header class is instantiated and is ignored as part of processing the value.

Add Subsystem-Type to the abstract header hierarchy.

Convert constructors taking a Requirement argument into static valueOf methods which translate
requirements back into their respective manifest headers. Implement unfinished functionality,
particularly with regard to extracting attributes from filters and creating filters from attributes.

Fix Subsystem-ImportService header and tests. Previously, the osgi.service requirement namespace
was used for the path, whereas the correct path is the value of the namespace attribute.

Fix the filter generation within OsgiExecutionEnvironmentRequirement and tests. Previously,
the filter would contain unnecessary operators for unary attributes. This broke ManifestHeaderProce

Support both "version" and "bundle-version" as version range attribute names.

Add default value for version range attribute to Require-Bundle and convert versions into

Add resolution directive default value to the Import-Package header.

> Make equals and hashCode comparisons within the header, clause, and parameter hierarchies
based on equivalency rather than string equals.
> -----------------------------------------------------------------------------------------------------------------------------------------
>                 Key: ARIES-1387
>                 URL:
>             Project: Aries
>          Issue Type: Improvement
>          Components: Subsystem
>            Reporter: Cristiano GaviĆ£o
>            Assignee: John Ross
> Currently the org.apache.aries.subsystem.core.archive.SubsystemContentHeader class (line
210) and other headers classes uses a HashSet in order to hold its clauses.
> HashSet doesn't ensure the order of its items and then its impossible to have a reproducible
build of any manifest file. As the SubsystemManifest class doesn't provide a equals() method,
we can't compare a generated manifest file with any template in a test, it will fail.
> The propose it to change the used HashSet for the LinkedHashSet class.

This message was sent by Atlassian JIRA

View raw message