Community
Participate
Working Groups
The following incident was reported via the automated error reporting: java.lang.NullPointerException: null at com.codetrails.connect.hippie.OverrideFrequencyModel.getMethodOverrideCount(OverrideFrequencyModel.java:40) at com.codetrails.connect.internal.hippie.rcp.completion.OverrideCompletionSessionProcessor.getScoredProposal(OverrideCompletionSessionProcessor.java:99) at com.codetrails.connect.internal.hippie.rcp.completion.AbstractCompletionSessionProcessor.startSession(AbstractCompletionSessionProcessor.java:112) at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.fireStartSession(IntelligentCompletionProposalComputer.java:304) at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.computeCompletionProposals(IntelligentCompletionProposalComputer.java:170) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:333) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:337) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:325) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:282) at org.eclipse.jface.text.contentassist.ContentAssistant$5.run(ContentAssistant.java:1904) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) ... General Information: eclipse-build-id: 4.5.1.M20150904-0015 eclipse-product: org.eclipse.epp.package.jee.product operating system: Windows7 6.1.0 (x86_64) - win32 jre-version: 1.8.0_65-b17 The following plug-ins were present on the execution stack (*): 1. com.codetrails.connect.hippie_1.8.1.v20151109-0927-b295 2. com.codetrails.connect.hippie.rcp_1.8.1.v20151109-0927-b295 3. org.eclipse.core.commands_3.7.0.v20150422-0725 4. org.eclipse.core.databinding.observable_1.5.0.v20150422-0725 5. org.eclipse.core.databinding_1.5.0.v20150422-0725 6. org.eclipse.core.runtime_3.11.1.v20150903-1804 7. org.eclipse.e4.core.commands_0.11.0.v20150422-0725 8. org.eclipse.e4.core.contexts_1.4.0.v20150828-0818 9. org.eclipse.e4.core.di_1.5.0.v20150421-2214 10. org.eclipse.e4.ui.bindings_0.11.0.v20150422-0725 11. org.eclipse.e4.ui.workbench_1.3.0.v20150531-1948 12. org.eclipse.e4.ui.workbench.swt_0.13.0.v20150504-0621 13. org.eclipse.equinox.app_1.3.300.v20150423-1356 14. org.eclipse.equinox.launcher_1.3.100.v20150511-1540 15. org.eclipse.jdt.ui_3.10.2.v20141014-1419 16. org.eclipse.jdt_3.10.1.v20150204-1700 17. org.eclipse.jface_3.11.0.v20150602-1400 18. org.eclipse.jface.text_3.10.0.v20150603-1752 19. org.eclipse.recommenders.completion.rcp_2.2.4.v20150914-0857 20. org.eclipse.swt_3.104.1.v20150825-0743 21. org.eclipse.ui_3.107.0.v20150507-1945 22. org.eclipse.ui.ide.application_1.1.0.v20150422-0725 23. org.eclipse.ui.ide_3.11.0.v20150825-2158 Other Resources: * Report: https://dev.eclipse.org/recommenders/committers/confess/#/problems/56420146e4b00c5a2b563c76 * Manual: https://dev.eclipse.org/recommenders/community/confess/#/guide This bug was created on behalf of andreas.sewe@xxxxxxxxxxxx.
While the NPE occurs in a third-party plugin (Codetrails Connect), this nevertheless hints at an issue in org.eclipse.recommenders.utils and Gson. Hence, I am *not* closing as NOT_ECLIPSE for now. A bit more context about the third-party code, some of which was written by me: An OverrideFrequencyModel is deserialized using Gson, from a JSON string which has an "overrides" property. But apparently OverrideFrequencyModel.overrides is null. @SerializedName("overrides") private final Multiset<IMethodName> f = HashMultiset.create(); Now, I am 100% sure that the JSON strings that we deserialize do not contain "overrides": null so the question is how this field ends up being null (instead of the default, non-null value). Here's my theory: @SerializedName is not honored, so the "overrides" property in the JSON input is not copied over into f. Alas, due to this Gson 2.2.4 bug [1], the default value of HashMultiset.create() is not used for f either. As to why @SerializedName is not honored, this may be a wiring issue, which arises in the following scenario: 1. The user installs Code Recommenders and with it org.eclipse.recommenders.utils and version X of com.google.gson. 2. Equinox wires org.eclipse.recommenders.utils to the package com.google.gson from com.google.gson, version X. 3. Some other installation causes com.google.gson, version Y > X, to be installed. The wiring for org.eclipse.recommenders.utils remains unchanged. 4. The user installs Codetrails Connect and with it com.codetrails.connect.hippie. This bundle requires org.eclipse.recommenders.utils and imports both com.google.gson and com.google.gson.annotations (for @SerializedName). Because of the uses constraints of o.e.r.utils, the package com.google.gson gets wired to version X (the same version as used by o.e.r.utils). However, o.e.r does not import com.google.gson.annotations and hence places no constraints on it. Hence, Equinox chooses the newer version Y. 5. com.codetrails.connect.hippie uses com.google.gson, version X, to deserialize its data. However, Gson does not recognize the @SerializedName annotation, as it is loaded with the classloader of com.google.gson, version Y. Thus, whatever is in the "overrides" property is not put into field f. 6. Now, bug [1] kicks in, so we don't get the default value of HashMultiset.create() either, but null instead. [1] <https://github.com/google/gson/issues/513>
(In reply to Andreas Sewe from comment #1) > Here's my theory: > > @SerializedName is not honored, so the "overrides" property in the JSON > input is not copied over into f. Alas, due to this Gson 2.2.4 bug [1], the > default value of HashMultiset.create() is not used for f either. > > As to why @SerializedName is not honored, this may be a wiring issue, which > arises in the following scenario: > > 1. The user installs Code Recommenders and with it > org.eclipse.recommenders.utils and version X of com.google.gson. > > 2. Equinox wires org.eclipse.recommenders.utils to the package > com.google.gson from com.google.gson, version X. > > 3. Some other installation causes com.google.gson, version Y > X, to be > installed. The wiring for org.eclipse.recommenders.utils remains unchanged. > > 4. The user installs Codetrails Connect and with it > com.codetrails.connect.hippie. This bundle requires > org.eclipse.recommenders.utils and imports both com.google.gson and > com.google.gson.annotations (for @SerializedName). Because of the uses > constraints of o.e.r.utils, the package com.google.gson gets wired to > version X (the same version as used by o.e.r.utils). However, o.e.r does not > import com.google.gson.annotations and hence places no constraints on it. > Hence, Equinox chooses the newer version Y. > > 5. com.codetrails.connect.hippie uses com.google.gson, version X, to > deserialize its data. However, Gson does not recognize the @SerializedName > annotation, as it is loaded with the classloader of com.google.gson, version > Y. Thus, whatever is in the "overrides" property is not put into field f. If the com.google.gson bundle includes uses constraints, this issue cannot happen: The constraints on com.google.gson would prevent com.codetrails.connect.hippie to wire to different versions of com.google.gson and com.google.gson.annotations. I hence filed a bug with Gson [1] to add such constraints. [1] <https://github.com/google/gson/issues/735>
I admit that the theory in comment 1 is a bit far-fetched. Alas, it is ATM the only one I have that can explain the NPE on this line return overrides.count(method); given that private final Multiset<IMethodName> overrides = HashMultiset.create(); I am afraid, we need some more information from the user who reported this issue. Could you please do the following: - Open the "Console" view. - Select the "Host OGSi console" (pre-installed in Eclipse for JEE Developers). - Enter the following commands and report their result here: ss gson p com.google.gson p com.google.gson.annotations p com.google.gson.reflect p com.google.gson.stream Thank you very much.
FYI, a second incident (same reporter) occurred in virtually identical situation [1]. [1] <https://dev.eclipse.org/recommenders/committers/confess//#/problems/564302fee4b0c02da2cfddc0/triage>