dev@glassfish.java.net

Re: patch review request for int-> long overflows

From: Shalini Muthukrishnan <Shalini.Muthukrishnan_at_Sun.COM>
Date: Tue, 29 Sep 2009 13:15:05 +0530

Hi Dies,

The ConnectionPool.java fix looks good.

Thanks,
Shalini.

Dies Koper wrote:
> Hi Ken, Jan, Marina, Hong, Shalini, Jagadish, Lloyd,
>
> In April I found and fixed an issue in JTA where the multiplication of
> two integers and a subsequent cast to a long led to
> IllegalArgumentException because the value had become negative.
>
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=7979
>
> For example:
> timer.schedule(this,timeout * 1000);
>
> schedule() takes a long, but if 'timeout' is bigger than MAX_INT/1000,
> the value will become negative.
>
> Searching through the V3 source code I found 40 more cases in your
> components: ejb, web, jta/jta, deploy, connection pool, jms, jmx.
>
> Some of the 'timeout' variables might never reach a big value, or code
> might not be used any more in V3, but as it's better safe than sorry
> I've addressed them in the attached patch (added 'L' to integer 1000).
> May I commit it to V3?
>
> I found these by grepping "1000;" and "1000);", so I might have missed some.
>
> Thanks,
> Dies
>