-
Notifications
You must be signed in to change notification settings - Fork 534
2.12 Clarify "object equality" #318
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
Comments
Rule 2.12 is strange because it implies each Processor must track and remember every Subscriber it saw, causing more memory use and retention. We have a few cases where a completely safe Subscriber can handle any number of (non concurrent) onSubscribe calls during its lifetime. If we'd obey this rule, that requires a meaningless instantiation of the same Subscriber just to satisfy the equality check. See #290. Same view applies to the dual rule of 1.10. We talking about this with @smaldini and we think both rules should be weakened in the next update by saying if you want Subscriber reuse, you are on your own and consider all possible call patterns. In this case, object equality or identity doesn't mean anything anymore. |
Requiring "equals" was just to accommodate the use of proxies and the like. I don't think changing it will much affect #290. |
From a garbage-tracking perspective, mandating that Publisher keep a history of all Subscribers they've seen is unreasonable. However, if a Publisher keeps track of its current Subscribers, it should also be responsible and prevent double-subscriptions, to be a good citizen. Does that make sense? As for object equality, it is strictly preferable over instance equality from a wrapper/delegate/proxy PoV. |
Thanks for mentioning the case of proxies etc., makes sense to me. I believe it would be useful to add this as a footnote to the specification, exactly as @viktorklang said: What do you think? |
@anthonyvdotbe I've been meaning to affix a "Rationale"/"Intent" to each of the spec rules to provide more background. Hopefully I'll have time to start doing that soon, it'll need to get vetted by the SIG but it should be massively beneficial to readers. |
BTW we do suffer the issue in a tck doing reference equality check for errors. It prevents any sort of error proxy/serialization/decorator. Another test related to this is the Subscriber dereferencing test which should be updated accordingly to support immutable publisher/subscriber relationship (and dereferenced once publisher and subscriber have both dereferenced, currently the tck is holding the publisher reference). |
Hmmm, what do you propose for the TCK to check the errors? |
For the errors : a For the Pub/Sub relationship, I'm talking about 3#13 TCK test that forces |
@smaldini True, but technically, a Processor is allowed to "recover" from an upstream onError, so I wonder how the TCK would be able to verify. Any idea how we could solve that? IGNORE THIS (Read 2.13 and not 3.13): As for 3.13 that concerns the case when the signal methods throw exceptions and therefor violate the spec. I'm probably not understanding what you mean, could you give an example? §3.13 intends to make sure that Publishers do not leak Subscriber references which have cancelled their subscription. How would it otherwise be guaranteed? |
the question of equality was addressed while providing the rationales for the rules. |
Rule 2.12 mentions "based on object equality". Is this meant to be as in "a == b" or as in "a.equals(b)"?
I believe the semantics ought to be as in "a == b", and thus the wording "based on object identity" would be clearer. In case of the latter, "based on Object::equals" would be better, in my opinion.
In my opinion, it would be worthwhile to update rule 1.10 accordingly by clarifying "different", for example:
Publisher.subscribe MAY be called as many times as wanted but MUST be with a different (based on object identity) Subscriber each time [see 2.12].
The text was updated successfully, but these errors were encountered: