-
Notifications
You must be signed in to change notification settings - Fork 115
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
Must a ConfigSource implementation be thread safe? #369
Comments
|
Does this mean (I think it must) that the mechanism by which |
I think that config sources have to be thread safe, otherwise the thread safety of The discussion about mutability is in #432. |
I agree that Regarding mutability, while #432 has focused on the dubious idea of snapshots, haven't (meanwhile) That is, I don't see anywhere in the specification where it says that the return values of several Since this is the case, shouldn't the specification change sooner rather than later such that the behavior of |
I agree. In particular I think it might be good to deprecate the But documenting the exact way in which an implementation is allowed to access the |
Thoroughly agreed. Now: if the behavior of |
That would probably have been better but there's really no way to do that without preserving binary compatibility, unfortunately. And it also voids the ability for implementations to perform any clever optimizations. |
So fine, |
Er, no; clearly not. That issue adds javadoc that says that the (Actually, that's not actually what the new javadoc says, but probably what it should say.) This of course does not address any thread-safety concerns about the individual |
I don't think that cardinality enters into it. I think that the guarantees provided by (for example)
Tracking cardinality would add the guarantee that any |
Leaving aside the specifics of this particular Github issue, and issue #497, and looking at the contract as it currently exists on Given that the return type is an
But:
…or the dance between But all of that it seems to me is better discussed over at #497 or another issue since it doesn't have to do with the thread safety of an individual |
Ah I see the source of confusion. The contract [1] of [1] "Returns
Sure, that makes sense. |
Note that the My much larger point is: any time iteration is not part of the object being returned from a method, or is otherwise not handled by encapsulation, the specification of how to perform iteration must be absolutely, unimpeachably clear. I don't feel like #497 et al. meets that bar and that the javadoc needs to be orders of magnitude larger and more specific. Regarding this issue, I think the original question remains: in what ways will the iterable objects given to me by |
I didn't see anywhere in the specification saying whether a
ConfigSource
must be thread safe. I assume it must, since it is accessible to an end user by way ofConfig#getConfigSources()
.Specifically, suppose a
ConfigSource
is constantly changing (is that allowed? the specification suggests but does not define that this is possible). That means, potentially, that the return values of itsgetPropertyNames()
and (redundant?)getProperties()
methods must have their behavior specified in the context of concurrent access by multiple threads.For example, are the property names returned by
getPropertyNames()
a snapshot-in-time of the property names, and hence safe to iterate over without synchronization, or are they "live" and backed by the underlyingConfigSource
? If they are intended to be live, then obviously a mechanism for synchronizing iteration must be supplied by the specification.The text was updated successfully, but these errors were encountered: