Drop guava dependency from code generator#9
Merged
Conversation
jibx-tools was only used in Util.plural / Util.singular to derive accessor names for `repeated` fields (addItem / getItemsCount / etc.). It transitively pulled in log4j 1.2.17 (multiple CVEs) and ~10 ancient Eclipse JDT jars. The relevant pluralize/depluralize logic from JiBX NameUtilities is ~40 lines of rule-based suffix manipulation with no irregular-plural handling, so vendor it directly into Util (BSD 3-clause, attribution in comment). Generated output is byte-identical; all 262 existing tests pass unchanged. Add UtilTest covering every branch of plural / singular, including the case-sensitivity quirk in jibx where "ANY" pluralizes to "ANYs".
guava was used in the code generator only for three small utilities:
- Joiner.on('/').join(arr) -> String.join("/", arr)
- Maps.newHashMap() -> new HashMap<>()
- CaseFormat.LOWER_UNDERSCORE.to(LOWER_CAMEL, s) and the inverse,
used in Util.camelCase / Util.upperCase
The CaseFormat conversions were replaced by lowerUnderscoreToLowerCamel
and lowerCamelToLowerUnderscore helpers in Util. Their behavior was
verified against guava's CaseFormat across every input shape that
appears in the codebase (proto field names, gRPC method names, short
prefixes like "get"/"set", and the embedded-camel "_msgSize" input
where guava's normalization lowercases internal uppercase letters).
Generated source is byte-identical; all 262 integration tests pass.
Removes guava and its 6 transitive jars (failureaccess,
listenablefuture, jsr305, checker-qual, error_prone_annotations,
j2objc-annotations) from the code-generator runtime tree.
# Conflicts: # code-generator/pom.xml # code-generator/src/main/java/io/streamnative/lightproto/generator/Util.java # code-generator/src/test/java/io/streamnative/lightproto/generator/UtilTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes
com.google.guava:guavafromlightproto-code-generator. Guava was used for three small utilities, each replaced inline:Joiner.on('/').join(arr)→String.join("/", arr)(JDK)Maps.newHashMap()→new HashMap<>()(JDK)CaseFormat.LOWER_UNDERSCORE.to(LOWER_CAMEL, s)and the inverse → two small helpers inUtil(lowerUnderscoreToLowerCamel,lowerCamelToLowerUnderscore)The case-format helpers were verified against guava's
CaseFormatfor every input shape that actually appears in the codebase (proto field names, gRPC method names, short prefixes likeget/set, and the embedded-camel_msgSizeinput where guava's normalization lowercases internal uppercase letters). Generated source is byte-identical to before.After this change, the code-generator runtime dep tree is just protobuf + slf4j + roaster — guava and its 6 transitive jars (
failureaccess,listenablefuture,jsr305,checker-qual,error_prone_annotations,j2objc-annotations) are gone.Test plan
mvn installbuilds clean across all moduleslightproto-testspass unchanged (these exercise generated code that depends onUtil.camelCase/Util.upperCasefor accessor naming)UtilTestextended with 25 new cases covering both case-format helpersmvn -pl code-generator dependency:treeno longer mentionsguava,com.google.common, or any of guava's annotation deps