On 31/01/2020 17:30, Daniel Fuchs wrote:
:
doh! trying to be too smart. I don't think we need the volatile given
that getImpl() synchronizes and we (now) can ever observe true if
create() has been called. Unless you're concerned about getImpl()
being called before the constructor has set created to true?
http://cr.openjdk.java.net/~dfuchs/webrev_8238231/webrev.01
This has the same bug as it reads "created" outside of the synchronized
block. If you change it to volatile then it will fix that issue.
In addition, setting "created" to true in the constructor will
confuse future maintainers as to whether it means the impl object has
been created vs. the socket.
It is the same since createImpl() calls impl.create().
This is confusing for the reader. I think we should keep the comment
from the patch attached to the bug and also set "created" to true
immediately after calling impl.create(). That will avoid potential
confusion on the semantics of the "created" flag. It means that the
impl's create method has been called to create the socket, it does not
mean that the impl object has been created.
-Alan