fix: avoid replacing dots in directory path when building output filename#481
Open
amitmishra11 wants to merge 1 commit into
Open
fix: avoid replacing dots in directory path when building output filename#481amitmishra11 wants to merge 1 commit into
amitmishra11 wants to merge 1 commit into
Conversation
…name
JavaCodeSerializer.save() was calling name.replace('.', '/') on the
entire name parameter, including any directory path prefix. This caused
directory components containing dots (e.g. version numbers like
reflections-0.9.16) to be treated as package separators, resulting in
serialized data being written to the wrong location.
The fix splits the name at the last '/' separator so that only the
class name portion (which legitimately uses dots as package separators)
is transformed. The directory prefix is kept unchanged.
Fixes ronmamo#478
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
Fixes #478
JavaCodeSerializer.save()converts thenameparameter to a filepath by calling
name.replace('.', '/'). However, this replaces alldots in the string, including dots that appear in directory path
components such as version numbers (e.g.
reflections-0.9.16-r6).As a result, when the output path contains dots in its directory
portion, the serialized
.javafile is written to the wrong location.Example:
Input name:
Before this fix, the output filename was:
After this fix, the output filename is:
Changes
nameparameter at the last/separator so that onlythe class name portion (which legitimately uses dots as package
separators) undergoes the dot-to-slash substitution. The directory
prefix is passed through unchanged.
Testing
The existing
JavaCodeSerializerTestcontinues to pass. It exercisesthe save-and-load round-trip and verifies that the generated store file
can be accessed via the expected class hierarchy.