Re: [POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-06 Thread sebb
On 6 October 2014 11:22, Bernd wrote: > Dont worry, currentTimesMillis does not step backward if the timezone > changes automatically, as it is in UTC time. > > However it does jump if somebody manually corrects the time (or allows NTP > zu jump the time). Both operations are however a general pro

Re: [POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-06 Thread Bernd
Dont worry, currentTimesMillis does not step backward if the timezone changes automatically, as it is in UTC time. However it does jump if somebody manually corrects the time (or allows NTP zu jump the time). Both operations are however a general problem on Java servers, should be avoided. If you

Re: [POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-06 Thread Jörg Schaible
Hi, Jacopo Cappellato wrote: > > On Oct 6, 2014, at 2:31 AM, sebb wrote: > >>> The only way to do it is to make >>> lastReturnTime field thread-safe using locks. >> >> Volatile does make the field thread-safe. >> It's just a question of whether the JVM can re-order the statements >> when vola

Re: [POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-05 Thread Jacopo Cappellato
On Oct 6, 2014, at 2:31 AM, sebb wrote: >> The only way to do it is to make >> lastReturnTime field thread-safe using locks. > > Volatile does make the field thread-safe. > It's just a question of whether the JVM can re-order the statements > when volatile is used. I think Xavier's comments ar

Re: [POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-05 Thread sebb
On 5 October 2014 23:39, Xavier Detant wrote: > Hello, > > I'm afraid the fix is wrong since, as Bernd said, no JMM property is used. > The JVM is allowed to reorder statments and inlining statments. I'd forgotten about re-ordering. > The volatile keyword assure you to have the most «fresh» valu

Re: [POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-05 Thread Xavier Detant
Hello, I'm afraid the fix is wrong since, as Bernd said, no JMM property is used. The JVM is allowed to reorder statments and inlining statments. The volatile keyword assure you to have the most «fresh» value at the moment of the reading, but since the System.currentTimeMillis() has no side effect

Re: [POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-05 Thread sebb
On 5 October 2014 13:13, Bernd wrote: > Hmm, > > I am not sure about this, the local variable fetch does not use any > property of the Java Memory Model to make it gurantee to work. That's not the issue - see my recent update to the JIRA. > I would > simply return 0 if the difference is negative

[POOL-279] Thread concurrency issue in DefaultPooledObject.getIdleTimeMillis()

2014-10-05 Thread Bernd
Hmm, I am not sure about this, the local variable fetch does not use any property of the Java Memory Model to make it gurantee to work. I would simply return 0 if the difference is negative. And of course making the last used value volatile. Greetings Bernd BTW: for what is that idle time used?