-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
A lot of operators don't check they actually have a Scannable for scanUnsafe(Attr<Scannable>) #895
Comments
Backward-compatible solution design When encountering these This can be generalized in In order to still be able to get the raw value from operators for these cases, a new |
This commit makes scanning of ACTUAL and PARENT safer by introducing a safe converter in the Attr class. By default, no converter is defined and the old behavior of force-casting is still used. For the two attributes above however, the value from `scanUnsafe` goes through `Scannable#from` first when calling `scan` or `scanOrDefaul`. That way, even though a lot of operators blindly return something that is Scannable _in most case but not necessarily_ (e.g. a Publisher), the outer scan will not fail. Added companion `RawAttr` for ACTUAL and PARENT which are `Attr<Object>` always returning the raw value from the operator (downcasted to Object).
This commit makes scanning of ACTUAL and PARENT safer by introducing a safe converter in the Attr class. By default, no converter is defined and the old behavior of force-casting is still used. For the two attributes above however, the value from `scanUnsafe` goes through `Scannable#from` first when calling `scan` or `scanOrDefaul`. That way, even though a lot of operators blindly return something that is Scannable _in most case but not necessarily_ (e.g. a Publisher), the outer scan will not fail. Added companion `RawAttr` for ACTUAL and PARENT which are `Attr<Object>` always returning the raw value from the operator (downcasted to Object).
This commit makes scanning of ACTUAL and PARENT safer by introducing a safe converter in the Attr class. By default, no converter is defined and the old behavior of force-casting is still used. For the two attributes above however, the value from `scanUnsafe` goes through `Scannable#from` first when calling `scan` or `scanOrDefaul`. That way, even though a lot of operators blindly return something that is Scannable _in most case but not necessarily_ (e.g. a Publisher), the outer scan will not fail. Added companion `RawAttr` for ACTUAL and PARENT which are `Attr<Object>` always returning the raw value from the operator (downcasted to Object).
Expected behavior
All
scanUnsafe
implementations should return aScannable
when called withPARENT
orACTUAL
.Actual behavior
A lot of operators don't necessarily check that this is the case. They will happily return e.g. a
CoreSubscriber
, which happens to have mostlyScannable
implementations (including the ones used in tests). But if you create an operator with anactual
bareCoreSubsriber
, scanning it for ACTUAL will fail with aClassCastException
.Steps to reproduce
Reactor Core version
3.1.0.RELEASE
The text was updated successfully, but these errors were encountered: