Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

DependencyConstraint match is incorrect in version 2.9.1 #5

Open
krueger71 opened this issue Apr 16, 2014 · 0 comments
Open

DependencyConstraint match is incorrect in version 2.9.1 #5

krueger71 opened this issue Apr 16, 2014 · 0 comments

Comments

@krueger71
Copy link

In version 2.9.1 this method ends prematurely on the first successful package match

public boolean match(Collection expectedPackages) {

        if (packages.size() == expectedPackages.size()) {

            for (Iterator i = expectedPackages.iterator(); i.hasNext();) {
                Object next = i.next();
                if (next instanceof JavaPackage) {
                    JavaPackage nextPackage = (JavaPackage) next;
                    if (!matchPackage(nextPackage)) {
                        return false;
                    }
                } else {
                    break;
                }

                return true;
            }
        }

        return false;
    }

This version works as expected, letting all packages be matched before returning true

    public boolean match(Collection expectedPackages) {

        if (packages.size() == expectedPackages.size()) {

            for (Iterator i = expectedPackages.iterator(); i.hasNext();) {
                Object next = i.next();
                if (next instanceof JavaPackage) {
                    JavaPackage nextPackage = (JavaPackage) next;
                    if (!matchPackage(nextPackage)) {
                        return false;
                    }
                }
            }
            return true;
        }

        return false;
    }
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant