commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r645324 - /commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/NtpV3Impl.java
Date Sun, 06 Apr 2008 22:55:47 GMT
Author: sebb
Date: Sun Apr  6 15:55:39 2008
New Revision: 645324

URL: http://svn.apache.org/viewvc?rev=645324&view=rev
Log:
NET-195 - fix incorrect double-checked locking

Modified:
    commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/NtpV3Impl.java

Modified: commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/NtpV3Impl.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/NtpV3Impl.java?rev=645324&r1=645323&r2=645324&view=diff
==============================================================================
--- commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/NtpV3Impl.java (original)
+++ commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/NtpV3Impl.java Sun Apr  6
15:55:39 2008
@@ -507,15 +507,12 @@
      *
      * @return a datagram packet.
      */
-    public DatagramPacket getDatagramPacket()
+    public synchronized DatagramPacket getDatagramPacket()
     {
-        if (dp == null)
-            synchronized(this) {
-                if (dp == null) {
-                    dp = new DatagramPacket(buf, buf.length);
-                    dp.setPort(NTP_PORT);
-                }
-            }
+        if (dp == null) {
+            dp = new DatagramPacket(buf, buf.length);
+            dp.setPort(NTP_PORT);
+        }
         return dp;
     }
 



Mime
View raw message