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

Repeated warnings 'Failed to notify spy' when using with another core extension declared in .mvn folder #199

Open
jibidus opened this issue Mar 14, 2023 · 2 comments · May be fixed by #207

Comments

@jibidus
Copy link

jibidus commented Mar 14, 2023

When I use maven-profiler with another core extension where:

  • maven-profiler is installed in $M2_HOME/lib/ext folder
  • the other extension is declared in .mvn/ folder

.. I got the following line many times each time a use a maven command :

[WARNING] Failed to notify spy fr.jcgay.maven.profiler.ProfilerEventSpy: null

Here is the stack trace when adding -X parameter:

java.lang.NullPointerException
        at fr.jcgay.maven.profiler.ProfilerEventSpy.onEvent(ProfilerEventSpy.java:81)
        at org.apache.maven.eventspy.internal.EventSpyDispatcher.onEvent(EventSpyDispatcher.java:104)
        at org.apache.maven.eventspy.internal.EventSpyRepositoryListener.artifactResolved(EventSpyRepositoryListener.java:88)
        [...]

The exception is raised here, in ProfilerEventSpy where onEvent() is called before init().
Do someone know if it is an issue with maven-profiler, or with maven? And how how to solve this issue?
I can create a pull request if necessary.

I created a dedicated project for the demonstrate: https://github.com/jibidus/maven-profiler-bug-demo

@hazendaz
Copy link

Having same issue.

jcgay added a commit that referenced this issue Apr 13, 2024
When maven-profiler is installed in the Maven distribution ext folder
and a project uses other extension from the .mvn/extensions.xml configuration,
maven-profiler was failing with NPE in fr.jcgay.maven.profiler.ProfilerEventSpy#onEvent.

This is because the #init method of the extension was not yet called when Maven was loading
extension from .mvn/extensions.xml. Maven was firing event intercepted by maven-profiler
but as it was not yet initiated, the configuration and statistics internal state was not ready.

This commit also initiate its state in the constructor.
It will prevent NPE but the statistics gathered between the instantiation and the initialization
will be lost anyway 😥. Because #init will clean internal state, and we need this to have the extension
functional with mvnd.

Fixes #199
@jcgay
Copy link
Owner

jcgay commented Apr 13, 2024

Thank you for the very detailed report 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants