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

OboardingResponse#parseFrom causes NPE #99

Closed
original-codematrix opened this issue Mar 2, 2020 · 2 comments
Closed

OboardingResponse#parseFrom causes NPE #99

original-codematrix opened this issue Mar 2, 2020 · 2 comments
Assignees

Comments

@original-codematrix
Copy link

@original-codematrix original-codematrix commented Mar 2, 2020

Describe the bug
We use this library to interpret messages from the AgriRouter. With the current newest version we get a NullPointerException.

To Reproduce
We use Kotlin
We have an abstract class like this:

abstract class Foo<in K : GeneratedMessageV3?>(private val parser: ByteString.() -> K? = { null }) {...}

In there we have a method that gets a call from another class that executes the parser:

message. //Is a parameter from type K
    responsePayloadWrapper.
    details?.
    value?.
    parser() //Here the NullPointerException gets thrown

For this class, we have different implementations e. g.:

class Bar() : Foo<CloudVirtualizedAppRegistration.OnboardingResponse>(
	CloudVirtualizedAppRegistration.OnboardingResponse::parseFrom
) {...}

Expected behavior
No NullPointerException.

Desktop (please complete the following information):

  • Kotlin Version: 1.3.50
  • Library:
com.agrirouter.api.lmis:agrirouter-api-java-impl:0.0.1-SNAPSHOT
  • Java Version:
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (IcedTea 3.3.0) (Alpine 8.121.13-r0)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
@saschadoemer

This comment has been minimized.

Copy link
Member

@saschadoemer saschadoemer commented Mar 2, 2020

Hey,

are you able to share a small example project with a test to reproduce the behavior?

Regards

Sascha

P.S. Thanks for the details, thumbs up for a really great issue description!

@saschadoemer saschadoemer self-assigned this Mar 2, 2020
@original-codematrix

This comment has been minimized.

Copy link
Author

@original-codematrix original-codematrix commented Mar 4, 2020

Hello @saschadoemer,

we already fixed this issue on our side. The problem here is/was the feature from Kotlin that allows you to pass static-references in an extension function through the constructor of the class. The fix here is to call the static #parseForm-method inside of the working method instead of passing a static reference through the constructor. Also, we switched from the old 0.0.1-SNAPSHOT to the newest 1.0.0-jdk8-RC1 version.

I also need to say that the code above worked on my local machine fine but on our server-side, it causes the NPE but with our changes now the problem is solved. We may be the compiling process isn't configured right so it uses an older version of Kotlin which can cause this problem.

Regards,
Jan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.