<div dir="ltr">Given the pattern of it, I might be able to produce a PMD checks for this. This way, you could run it across the code base and check for all occurences of it. </div><div class="gmail_extra"><br><div class="gmail_quote">On 10 September 2014 13:58, Alan Field <span dir="ltr"><<a href="mailto:afield@redhat.com" target="_blank">afield@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey Bela,<br>
<span class=""><br>
> Just a quick heads up. I'm currently working on<br>
> <a href="https://issues.jboss.org/browse/JGRP-1877" target="_blank">https://issues.jboss.org/browse/JGRP-1877</a>, which it critical as it may:<br>
> - cause RPCs to return prematurely (possibly with a TimeoutException), or<br>
> - cause RPCs to blocks for a long time (pick which one is worse :-))<br>
<br>
</span>How frequently can these errors occur? Is this something that is not very likely to happen or something that requires an external action to trigger it? (i.e. changing the time via NTP) Just trying to determine the priority of this issue.<br>
<br>
Thanks,<br>
Alan<br>
<div class="HOEnZb"><div class="h5"><br>
----- Original Message -----<br>
> From: "Bela Ban" <<a href="mailto:bban@redhat.com">bban@redhat.com</a>><br>
> To: <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
> Sent: Wednesday, September 10, 2014 12:05:11 PM<br>
> Subject: [infinispan-dev] JGRP-1877<br>
><br>
> Just a quick heads up. I'm currently working on<br>
> <a href="https://issues.jboss.org/browse/JGRP-1877" target="_blank">https://issues.jboss.org/browse/JGRP-1877</a>, which it critical as it may:<br>
> - cause RPCs to return prematurely (possibly with a TimeoutException), or<br>
> - cause RPCs to blocks for a long time (pick which one is worse :-))<br>
><br>
> This is due to my misunderstanding of the semantics of<br>
> System.nanoTime(), I frequently have code like this, which computes a<br>
> future deadline for a timeout:<br>
><br>
> long wait_time=TimeUnit.NANOSECONDS.convert(timeout,<br>
> TimeUnit.MILLISECONDS);<br>
> final long target_time=System.nanoTime() + wait_time;<br>
> while(wait_time > 0 && !hasResult) { /* Wait for responses: */<br>
> wait_time=target_time - System.nanoTime();<br>
> if(wait_time > 0) {<br>
> try {cond.await(wait_time, TimeUnit.NANOSECONDS);}<br>
> catch(Exception e) {}<br>
> }<br>
> }<br>
> if(!hasResult && wait_time <= 0)<br>
> throw new TimeoutException();<br>
><br>
> Variable target_time can possibly become *negative* if nanoTime()<br>
> returns a negative value. If so, hasResult is false and wait_time<br>
> negative, and therefore a TimeoutException would be thrown !<br>
><br>
> While I'm at it, I'll also fix my uses of System.currentTimeMillis(),<br>
> and replace it with nanoTime(). Our good friend Erik has run into issues<br>
> with RPCs (using currentTimeMillis()) hanging forever when their<br>
> NTP-based servers adjusted the time .... backwards !<br>
><br>
> Please be aware of nanoTime() in your own code, e.g.<br>
> long t0=nanoTime();<br>
> ...<br>
> long t1=nanoTime();<br>
><br>
> It is *not* guaranteed that t1 > t0 because of numeric overflow (t0<br>
> might be Long.MAX_VALUE-1 and t1 Long.MAX_VALUE +2 !). The only way to<br>
> compare them is t1 - t0 > 0 (t1 is more recent) or < 0 t0 is more recent.<br>
><br>
> Just thought I wanted to pass this on, in case somebody made the same<br>
> stupid mistake...<br>
><br>
> Thanks to David Lloyd for pointing this out !<br>
><br>
> --<br>
> Bela Ban, JGroups lead (<a href="http://www.jgroups.org" target="_blank">http://www.jgroups.org</a>)<br>
> _______________________________________________<br>
> infinispan-dev mailing list<br>
> <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
><br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Romain PELISSE,<br><i>"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it" -- Terry Pratchett</i><br><a href="http://blog.wordpress.belaran.eu/" target="_blank">Belaran ins Prussia (blog)</a> (... finally up and running !)
</div>