Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Excluding depencency from arc based on group id only results in NoSuchElementException #43040

Closed
jochemvv opened this issue Sep 5, 2024 · 3 comments · Fixed by #43043
Closed
Assignees
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Milestone

Comments

@jochemvv
Copy link

jochemvv commented Sep 5, 2024

Describe the bug

When setting quarkus.arc.exclude-dependency..group-id, without quarkus.arc.exclude-dependency..artifact-id start up fails and a NoSuchElementException is thrown.

Expected behavior

It should be possible to exclude based on group-id only.

Actual behavior

Excluding based on group-id only, results in NoSuchElementException

How to Reproduce?

Reproducer:

  1. add a exclude configuration, e.g. quarkus.arc.exclude-dependency.acme.group-id=org.acme
  2. start the application

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@jochemvv jochemvv added the kind/bug Something isn't working label Sep 5, 2024
@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Sep 5, 2024
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 5, 2024

/cc @Ladicek (arc), @manovotn (arc), @mkouba (arc)

@jochemvv
Copy link
Author

jochemvv commented Sep 5, 2024

seems like some parentheses are missing in BeanArchiveProcessor.archiveMatches.

I think the following:

public static boolean archiveMatches(ArtifactKey key, String groupId, Optional<String> artifactId, Optional<String> classifier) {
        if (Objects.equals(key.getGroupId(), groupId) && artifactId.isEmpty() || Objects.equals(key.getArtifactId(), artifactId.get())) {
            if (classifier.isPresent() && Objects.equals(key.getClassifier(), classifier.get())) {
                return true;
            }

            if (!classifier.isPresent() && "".equals(key.getClassifier())) {
                return true;
            }
        }

        return false;
    }

should be:

public static boolean archiveMatches(ArtifactKey key, String groupId, Optional<String> artifactId, Optional<String> classifier) {
        if (Objects.equals(key.getGroupId(), groupId) && (artifactId.isEmpty() || Objects.equals(key.getArtifactId(), artifactId.get()))) {
            if (classifier.isPresent() && Objects.equals(key.getClassifier(), classifier.get())) {
                return true;
            }

            if (!classifier.isPresent() && "".equals(key.getClassifier())) {
                return true;
            }
        }

        return false;
    }

@manovotn
Copy link
Contributor

manovotn commented Sep 5, 2024

@jochemvv thank you for the report; you're correct that the if condition is wrong.
I've sent a PR and added a unit test.

@quarkus-bot quarkus-bot bot added this to the 3.16 - main milestone Sep 5, 2024
@gsmet gsmet modified the milestones: 3.16 - main, 3.14.3 Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants