Skip to content

java: append correct literal suffix for map keys/values constraints #294

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

Merged
merged 4 commits into from
Dec 29, 2019

Conversation

bjaglin
Copy link
Contributor

@bjaglin bjaglin commented Dec 1, 2019

Without specific handling for maps in javaTypeLiteralSuffixFor, no literal suffix was ever appended, resulting in compilation error in the validator for constraints on (Java) long, float or double. This commit mimics the structure of javaTypeFor to infer the suffix based on whether keys or values are targeted.

@bjaglin bjaglin force-pushed the java-map-keys-values-literal-suffix branch 2 times, most recently from 581f658 to 7aa38cf Compare December 1, 2019 13:28
Without specific handling for maps in `javaTypeLiteralSuffixFor`,
no literal suffix was ever appended, resulting in compilation error in
the validator for constraints on (Java) long, float or double. This
commit mimics the structure of `javaTypeFor` to infer the suffix based
on whether keys or values are targeted.

Signed-off-by: Brice Jaglin <[email protected]>
@bjaglin bjaglin force-pushed the java-map-keys-values-literal-suffix branch from 7aa38cf to 6769053 Compare December 1, 2019 19:53
@bjaglin bjaglin marked this pull request as ready for review December 1, 2019 20:26
@rmichela
Copy link
Contributor

rmichela commented Dec 2, 2019

Excellent find! Is it possible to make a test case that verifies the generated Java compiles?

@rmichela rmichela added Bug Reports and/or fixes a bug Java Java/JVM language support labels Dec 2, 2019
@@ -17,7 +17,7 @@ message MapNoSparse {
message Msg {}
}

message MapKeys { map<sint32, string> val = 1 [(validate.rules).map.keys.sint32.lt = 0]; }
message MapKeys { map<sint64, string> val = 1 [(validate.rules).map.keys.sint64.lt = 0]; }
Copy link
Contributor Author

@bjaglin bjaglin Dec 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmichela this triggers a compilation error on pgv-java-validation without the fix - did you have another specific test case in mind?

@bjaglin
Copy link
Contributor Author

bjaglin commented Dec 20, 2019

Is there anything else I can do to get this in? Also, what's the (maven central) release policy? In other words, when can I roughly expect this fix to land in a released JAR? Thanks in advance!

@rmichela
Copy link
Contributor

@rodaine I'd like to do a java release to get this bugfix in. Is that OK with you?

@rmichela
Copy link
Contributor

I suspect the build failure is related to #290

@rmichela rmichela merged commit fced6c0 into bufbuild:master Dec 29, 2019
@rmichela
Copy link
Contributor

Next step. Release a dot release of the java libs.

@bjaglin
Copy link
Contributor Author

bjaglin commented Feb 11, 2020

Hi @rmichela, any update on cutting a patch release? Thanks!

@rmichela
Copy link
Contributor

@bjaglin Sorry that took three months to release, but it's out. https://github.com/envoyproxy/protoc-gen-validate/releases/tag/v0.3.0-java

@bjaglin
Copy link
Contributor Author

bjaglin commented Feb 21, 2020

@rmichela thanks!

hexdigest pushed a commit to hexdigest/protoc-gen-validate that referenced this pull request Mar 26, 2020
…ufbuild#294)

Without specific handling for maps in `javaTypeLiteralSuffixFor`,
no literal suffix was ever appended, resulting in compilation error in
the validator for constraints on (Java) long, float or double. This
commit mimics the structure of `javaTypeFor` to infer the suffix based
on whether keys or values are targeted.

Signed-off-by: Brice Jaglin <[email protected]>

Co-authored-by: Ryan Michela <[email protected]>
Signed-off-by: Maxim Chechel <[email protected]>
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 this pull request may close these issues.

3 participants