8238231: Custom DatagramSocketImpl's create method not called when with protected constructor
Daniel Fuchs
daniel.fuchs at oracle.com
Fri Jan 31 17:30:14 UTC 2020
Hi Alan!
On 31/01/2020 17:10, Alan Bateman wrote:
> On 31/01/2020 16:46, Daniel Fuchs wrote:
>> http://cr.openjdk.java.net/~dfuchs/webrev_8238231/webrev.00/
> This seems to have a few problems. Consider two threads calling
> getImpl() at around the same time. This can only work if "created "is
> volatile and you set it to true after impl.create() has been called.
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
> 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().
> Otherwise I agree with the eager creation to
> preserve long standing behavior.
>
> -Alan
best regards,
-- daniel
More information about the net-dev
mailing list