(BTW I think this is also related to the Shutdown Thread. It looks like
this pattern is used around the disposalFuture. See
AbstractIoService.dispose().)
On Thu, 2009-06-04 at 11:39 +0200, Emmanuel Lecharny wrote:
> Steve Crane wrote:
> > Hi there,
> >
> Good catch !!!
> > DefaultIoFuture.awaitUninterrruptibly() calls await0(Log.MAX_VALUE,
> > false) which does:
> >
> > long endTime = System.currentTimeMillis() + timeoutMillis;
> >
> > i.e.,
> > long endTime = System.currentTimeMillis() + Long.MAX_VALUE;
> >
> > This comes out <0 which leads to:
> >
> > if (ready) {
> > return ready;
> > } else if (timeoutMillis <= 0) {
> > return ready;
> > }
> >
> > Doesn't really matter what is returned here because the return value is
> > ignored by the caller:
> >
> > try {
> > await0(Long.MAX_VALUE, false);
> > } catch ( InterruptedException ie) {
> > // Do nothing : this catch is just mandatory by contract
> > }
> >
> > The right solution IMHO would be to use a timeout of -1 to wait forever
> > and 0 for a poll. However you might prefer:
> >
> > long endTime = timeoutMillis;
> > if (endTime != Long.MAX_VALUE)
> > endTime += System.currentTimeMillis();
> >
>
> I think that something like :
>
> private boolean await0(long timeoutMillis, boolean interruptable)
> throws InterruptedException {
> long endTime = System.currentTimeMillis() + timeoutMillis;
>
> if (endTime < 0) {
> endTime = Long.MAX_VALUE;
> }
> ...
>
I guess that would work.
> would be better.
>
> wdyt ?
> > Cheers,
> > Steve
> >
> >
> >
> >
>
>