-
Notifications
You must be signed in to change notification settings - Fork 2
feat: update handler map when field descriptor hashcode changes #13
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
feat: update handler map when field descriptor hashcode changes #13
Conversation
Dependencyjar
Dependencyjar
- add mockito extension to mock final classes ( ref: https://www.baeldung.com/mockito-final) [https://go-jek.atlassian.net/browse/DSTRM-1379]
dagger-common/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
Outdated
Show resolved
Hide resolved
- add test dependency of powermockito in dagger-common
dagger-common/build.gradle
Outdated
| testImplementation 'com.google.protobuf:protobuf-java-util:3.5.0' | ||
| testImplementation 'org.grpcmock:grpcmock-junit5:0.5.0' | ||
| testImplementation 'org.powermock:powermock-module-junit4:2.0.0-beta.5' | ||
| testImplementation 'org.powermock:powermock-api-mockito2:2.0.0-beta.5' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not use powermock if possible, it messes up the classpaths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
| @Test | ||
| public void shouldReturnDifferentCopiesOfHandlerObjectWhenFieldDescriptorFullNameIsSameButHashCodeIsDifferent() { | ||
| Descriptors.FieldDescriptor mapFieldDescriptor1 = TestBookingLogMessage.getDescriptor().findFieldByName("metadata"); | ||
| Descriptors.FieldDescriptor mapFieldDescriptor2 = PowerMockito.mock(Descriptors.FieldDescriptor.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you again create this, how the hashcode will be same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use protobuf libraries
* feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * test: fix tests * feat: auto stencil schema refresh * feat: auto stencil schema refresh * feat: auto stencil schema refresh * feat: auto stencil schema refresh * feat: auto stencil schema refresh * feat: auto stencil schema refresh * feat: auto stencil schema refresh * feat: auto stencil schema refresh * feat: auto schema refresh * feat: stencil auto refresh * feat: stencil auto refresh * feat: stencil auto refresh * feat: stencil auto refresh * feat: stencil auto refresh * feat: stencil auto refresh * feat: stencil auto refresh * tests: fix tests * fix: clear typehandlermap on schema update * fix: clear typehandlermap on schema update * fix: schema refresh strategy * fix: schema refresh strategy * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * feat: enable stencil auto schema refresh * tests: add tests for auto schema refresh * test: add tests for auto schema refresh * test: add tests for auto schema refresh * test: add tests for auto schema refresh * test: add tests for auto schema refresh * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * refactor: rename transformFromProtoMap() to transformFromProtoUsingCache() * test: add tests for auto schema refresh * fix: remove caching for nested types * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * feat: auto schema refresh * docs: add configs for auto schema refresh * docs: configs for auto schema refresh * refactor: change stencil config defaults * refactor: change stencil config defaults * refactor: change stencil config defaults * fix: remove non-serializable stencilconfig * tests: fix tests * tests: fix tests * tests: fix tests * tests: fix tests * feat: update handler map when field descriptor hashcode changes (#13) * chore: move stencil back to dependency * chore: version bump of dependencies * chore: version issues * feat: update handler map when field descriptor hashcode changes - add mockito extension to mock final classes ( ref: https://www.baeldung.com/mockito-final) [https://go-jek.atlassian.net/browse/DSTRM-1379] * feat: remove dead code and fix checkstyle issues [https://go-jek.atlassian.net/browse/DSTRM-1379] * feat: use PowerMockito instead of mockito plugin - add test dependency of powermockito in dagger-common * feat: remove dependency of power-mockito and use protobuf libs for test [https://go-jek.atlassian.net/browse/DSTRM-1379] --------- Co-authored-by: lavkesh <[email protected]> * fix: dont clear typehandlermap * fix: fix checkstyle * fix: revert cleartypehandler to protected --------- Co-authored-by: Meghajit Mazumdar <[email protected]> Co-authored-by: lavkesh <[email protected]>
Issue
In the dagger repository, the TypeHandlerFactory class maintains a static hash map, which memoizes which handler to use for serialization/deserialization for every proto full name. The type handler objects are created once using the field descriptor and saved as the value of this hash map.
The hypothesis was that this map was being persisted in the memory of a task manager, even when the job terminates or restarts. As a result the handler objects get reused and at the time of serialization when this method is called in the stacktrace:
the equals comparison fails and hence serialization also fails.
Fix
The fix is then to update the handler corresponding to the proto full name in the hash map, whenever the field descriptor hashcode is a new one.