Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 22154 invoked from network); 11 Oct 2009 03:14:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Oct 2009 03:14:09 -0000 Received: (qmail 79035 invoked by uid 500); 11 Oct 2009 03:14:09 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 78972 invoked by uid 500); 11 Oct 2009 03:14:09 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 78963 invoked by uid 99); 11 Oct 2009 03:14:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Oct 2009 03:14:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Oct 2009 03:14:05 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 389E823888DA; Sun, 11 Oct 2009 03:13:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r824006 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net: DatagramPacket.java DatagramSocket.java Date: Sun, 11 Oct 2009 03:13:44 -0000 To: commits@harmony.apache.org From: ndbeyer@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091011031344.389E823888DA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ndbeyer Date: Sun Oct 11 03:13:39 2009 New Revision: 824006 URL: http://svn.apache.org/viewvc?rev=824006&view=rev Log: add some package methods to provide consistent synchronization of access to instance fields Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java?rev=824006&r1=824005&r2=824006&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java Sun Oct 11 03:13:39 2009 @@ -215,6 +215,15 @@ } /** + * Gets the current capacity value. + * + * @return the current capacity value + */ + synchronized int getCapacity() { + return capacity; + } + + /** * Sets the length of the datagram packet. This length plus the offset must * be lesser than or equal to the buffer size. * @@ -230,6 +239,19 @@ } /** + * An alternative to {@link #setLength(int)}, that doesn't reset the {@link #capacity} + * field. + * + * @param len the length of this datagram packet + */ + synchronized void setLengthOnly(int len) { + if (0 > len || offset + len > data.length) { + throw new IllegalArgumentException(Msg.getString("K002f")); //$NON-NLS-1$ + } + length = len; + } + + /** * Sets the port number of the target host of this datagram packet. * * @param aPort Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java?rev=824006&r1=824005&r2=824006&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java Sun Oct 11 03:13:39 2009 @@ -361,8 +361,8 @@ if (e.getMessage().equals( "The socket does not support the operation")) { //$NON-NLS-1$ // receive packet to temporary buffer - tempPack = new DatagramPacket(new byte[pack.capacity], - pack.capacity); + tempPack = new DatagramPacket(new byte[pack.getCapacity()], + pack.getCapacity()); impl.receive(tempPack); // tempPack's length field is now updated, capacity is unchanged // let's extract address & port @@ -404,11 +404,11 @@ .getOffset(), tempPack.getLength()); // we shouldn't update the pack's capacity field in order to be // compatible with RI - pack.length = tempPack.length; + pack.setLengthOnly(tempPack.getLength()); pack.setAddress(tempPack.getAddress()); pack.setPort(tempPack.getPort()); } else { - pack.setLength(pack.capacity); + pack.setLength(pack.getCapacity()); impl.receive(pack); // pack's length field is now updated by native code call; // pack's capacity field is unchanged @@ -442,7 +442,7 @@ } else { // not connected so the target address is not allowed to be null if (packAddr == null) { - if (pack.port == -1) { + if (pack.getPort() == -1) { // KA019 Destination address is null throw new NullPointerException(Msg.getString("KA019")); //$NON-NLS-1$ }