lofifnc opened a new pull request, #39310: URL: https://github.com/apache/beam/pull/39310
## Summary `ByteBuddyDoFnInvokerFactory` currently resolves a `DoFn`'s input and output type descriptors before every generated-constructor cache lookup. Runners that create a new invoker at each bundle boundary therefore repeat reflective generic-type resolution even when they reuse the same `DoFn` instance and the constructor cache hits. This change adds a weak, identity-keyed cache from each live `DoFn` instance to its selected generated constructor. A new or deserialized instance still resolves its descriptors and uses the existing `(DoFn class, input type, output type)` constructor cache. Later invoker creation for that instance skips descriptor resolution. The constructor value does not reference its `DoFn` key, so weak keys remain collectible. Identity equality is intentional: separate instances that compare equal can still expose different generic descriptors. The patch preserves the generic cache-collision fix from #37355. It also strengthens that regression test by using equal `DoFn` instances with different descriptors. Fixes #39309. ## Validation - `./gradlew :sdks:java:core:test --tests org.apache.beam.sdk.transforms.reflect.DoFnInvokersTest` - `./gradlew :sdks:java:core:check` Both pass on Java 21. The full core check includes formatting, compilation, unit tests, Checkstyle, SpotBugs, Javadocs, and shaded-JAR validation. ------------------------ Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Mention the appropriate issue in your description (`Fixes #39309`). - [x] Update `CHANGES.md` with noteworthy changes. - [x] This is not a large contribution; an ICLA is not required for its size. See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
