ltearno / pom-explorer

A tool to aid managing lots of maven projects
MIT License
371 stars 65 forks source link

NPE during analysis #24

Closed victornoel closed 7 years ago

victornoel commented 8 years ago

Hi, when doing analysis I get this error:

Analyzing directoy '/home/vnoel/Linagora/Petals/dev/git/petals/container/petals-esb-default-zip'...
possible options: quiet, nofetch, offline, profiles
analyzing '/home/vnoel/Linagora/Petals/dev/git/petals/container/petals-esb-default-zip'
loaded 1 projects

loaded projects:
org.ow2.petals:petals-esb-default-zip:5.0.3-SNAPSHOT (/home/vnoel/Linagora/Petals/dev/git/petals/container/petals-esb-default-zip/pom.xml)
Read profiles to use in the analyze...
fetching missing parents and boms...
fetched missing projects, 5 resolved projects and 0 unresolved projects
adding projects to graph
Cannot add project org.ow2.petals:petals-esb-default-zip:5.0.3-SNAPSHOT (/home/vnoel/Linagora/Petals/dev/git/petals/container/petals-esb-default-zip/pom.xml) to graph. Cause: null
java.lang.NullPointerException
fr.lteconsulting.pomexplorer.Project.getDeclaredDependencyManagement(Project.java:538)
fr.lteconsulting.pomexplorer.Project.getLocalDependencyManagement(Project.java:450)
fr.lteconsulting.pomexplorer.model.transitivity.DependencyNode.collectDependencyManagement(DependencyNode.java:39)
fr.lteconsulting.pomexplorer.Project.buildDependencyTree(Project.java:798)
fr.lteconsulting.pomexplorer.Project.getDependencyTree(Project.java:654)
fr.lteconsulting.pomexplorer.PomAnalyzer.addProjectToGraph(PomAnalyzer.java:138)
fr.lteconsulting.pomexplorer.PomAnalyzer.analyze(PomAnalyzer.java:85)
fr.lteconsulting.pomexplorer.commands.AnalyzeCommand.directory(AnalyzeCommand.java:28)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
fr.lteconsulting.pomexplorer.commands.Commands.takeCommand(Commands.java:248)
fr.lteconsulting.pomexplorer.AppFactory$1.onWebsocketMessage(AppFactory.java:169)
fr.lteconsulting.pomexplorer.webserver.WebServer$3$1.lambda$onFullTextMessage$0(WebServer.java:190)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)

I ran it with the debugger and apparently dependencyMap is null!

gcalis commented 8 years ago

The quick fix I applied was to add a null check at Project.Java line 531: if( projectProfiles != null && dependencyMap != null)

ltearno commented 8 years ago

Hi thanks for your fix. I guess it fixes the npe but I would like to investigate more about why this happens. Is it just me forgetting to check for null (which I doubt because I already analysed lots of projects with pomexplorer) or is it a more architectural problem which should be fixed at its source... Anyway I'm glad the fix makes it for you. I should have time to go into that next weeks. This days I just need to rest.... Thanks

Arnaud

Le mer. 28 sept. 2016 17:07, gcalis notifications@github.com a écrit :

The quick fix I applied was to add a null check at Project.Java line 531: if( projectProfiles != null && dependencyMap != null)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ltearno/pom-explorer/issues/24#issuecomment-250195620, or mute the thread https://github.com/notifications/unsubscribe-auth/AALqXXACwyB-dFUWBrsdIiKi99hToKNWks5quoLGgaJpZM4KFBMy .

victornoel commented 8 years ago

The thing is, from what I've seen of the project, there is nowhere where this method is called with a non-null dependencyMap! But I may have missed something ^^

Anyway, as you check in the code just above if the dependencyMap is null, there should also be a check before doing the collections maps and filters... there is an inconsistency somewhere in this method :)

MatanRubin commented 7 years ago

Hi, I'm seeing the exact same issue and can confirm that the fix @gcalis suggested solves the issue for me.

ltearno commented 7 years ago

Thanks to you both, it's already a long time ago, and i could not find any time before today to re-open the project. Your commit fixes the problem, thank you!