beam icon indicating copy to clipboard operation
beam copied to clipboard

[Bug]: ByteBuddyDoFnInvokerFactory cache collision for DoFns with different generic types

Open Eliaaazzz opened this issue 10 months ago • 3 comments

What happened?

I discovered a bug in ByteBuddyDoFnInvokerFactory where the cache key strategy causes collisions for the same DoFn class used with different generic types.

Currently, the cache is keyed solely on the DoFn class. This causes incorrect invoker reuse when generics are erased. For example, MyDoFn and MyDoFn share the same cache key (MyDoFn.class). As a result, the invoker generated for String is returned for Integer.

Steps to reproduce

I reproduced this behavior with the following unit test in DoFnInvokersTest.java. The test fails with an AssertionError, proving that the generated invoker classes are identical despite the different generic types.

Image Image

Eliaaazzz avatar Jan 20 '26 04:01 Eliaaazzz

.take issue I would like to volunteer to fix this.

Eliaaazzz avatar Jan 20 '26 04:01 Eliaaazzz

Hi, I would like to work on this issue. I am a new contributor to Apache Beam. Could you please assign this issue to me or let me know if I can proceed? Thank you!

shivanshjais22 avatar Jan 26 '26 05:01 shivanshjais22

Hi, I would like to work on this issue. I am a new contributor to Apache Beam. Could you please assign this issue to me or let me know if I can proceed? Thank you!

Hi, this issue is assigned to me and a fix is already under review. Thanks!

Eliaaazzz avatar Jan 26 '26 05:01 Eliaaazzz