Skip to content

Null pointer exception when validating embedded message with ReflectiveValidatorIndex #208

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

Closed
dainiusfigoras opened this issue May 25, 2019 · 2 comments · Fixed by #211
Closed
Labels
Bug Reports and/or fixes a bug Java Java/JVM language support

Comments

@dainiusfigoras
Copy link

Hi,

some of our proto messages have embedded messages, that looks something like this:

message TokenUse {
  message Payload {
    string token = 1;
  }
  Payload payload = 1;
}

but when running server validation (with ReflectiveValidatorIndex) it generates null pointer exception:

java.lang.NullPointerException: null
	at io.envoyproxy.pgv.ReflectiveValidatorIndex.lambda$reflectiveValidatorFor$1(ReflectiveValidatorIndex.java:39)

it's even more strange/disturbing because there is no validation conditions, so I would expect it to use ALWAYS_VALID (or something like that).

I think it happens because embedded message is translated to inner class (TokenUse$Payload) and reflector doesn't find (or generate) it.
And then

ValidatorImpl impl = (ValidatorImpl)validatorClass.getDeclaredMethod("validatorFor", Class.class).invoke((Object)null, clazz);

returns null and then impl.assertValid(proto, this); fails with null pointer.

@seime
Copy link

seime commented May 29, 2019

Were you able to reproduce this one @rmichela ?

@rmichela
Copy link
Contributor

Yes.

@rmichela rmichela added Bug Reports and/or fixes a bug Java Java/JVM language support labels May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reports and/or fixes a bug Java Java/JVM language support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants