harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r964136 - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/archive/src/main/java/java/util/zip/ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ classlib/mo...
Date Wed, 14 Jul 2010 18:59:21 GMT
Author: hindessm
Date: Wed Jul 14 18:59:20 2010
New Revision: 964136

URL: http://svn.apache.org/viewvc?rev=964136&view=rev
Log:
Merge changes from trunk@964042.

Added:
    harmony/enhanced/java/branches/java6/classlib/support/src/test/java/tests/resources/hyts_flushed.jar
      - copied unchanged from r964042, harmony/enhanced/java/trunk/classlib/support/src/test/java/tests/resources/hyts_flushed.jar
Modified:
    harmony/enhanced/java/branches/java6/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/depends/libs/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/modules/archive/src/main/java/java/util/zip/ZipFile.java
    harmony/enhanced/java/branches/java6/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/InetSocketAddress.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLConnection.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramPacketTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 14 18:59:20 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-963699
+/harmony/enhanced/java/trunk:929253-964042
 /harmony/enhanced/trunk:476395-929252
 /incubator/harmony/enhanced/trunk:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 14 18:59:20 2010
@@ -1,7 +1,7 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
 /harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-963699
+/harmony/enhanced/java/trunk/classlib:929253-964042
 /harmony/enhanced/trunk/classlib:476395-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/classlib:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 14 18:59:20 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-963699
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-964042
 /harmony/enhanced/trunk/classlib/depends/libs:476395-929252
 /incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394

Modified: harmony/enhanced/java/branches/java6/classlib/modules/archive/src/main/java/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/archive/src/main/java/java/util/zip/ZipFile.java?rev=964136&r1=964135&r2=964136&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/archive/src/main/java/java/util/zip/ZipFile.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/archive/src/main/java/java/util/zip/ZipFile.java
Wed Jul 14 18:59:20 2010
@@ -347,8 +347,28 @@ public class ZipFile implements ZipConst
 
         /*
          * Seek to the first CDE and read all entries.
+         * However, when Z_SYNC_FLUSH is used the offset may not point directly
+         * to the CDE so skip over until we find it. 
+         * At most it will be 6 bytes away (one or two bytes for empty block, 4 bytes for
+         * empty block signature).  
          */
-        rafs = new RAFStream(mRaf, centralDirOffset);
+        scanOffset = centralDirOffset;
+        stopOffset = scanOffset + 6;
+        
+        while (true) {
+            mRaf.seek(scanOffset);
+            if (ZipEntry.readIntLE(mRaf) == CENSIG) {
+                break;
+            }
+
+            scanOffset++;
+            if (scanOffset > stopOffset) {
+                throw new ZipException(Messages.getString("archive.3A"));
+            }
+        }
+        
+        // If CDE is found then go and read all the entries
+        rafs = new RAFStream(mRaf, scanOffset);
         bin = new BufferedInputStream(rafs, 4096);
         for (int i = 0; i < numEntries; i++) {
             ZipEntry newEntry = new ZipEntry(ler, bin);

Modified: harmony/enhanced/java/branches/java6/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java?rev=964136&r1=964135&r2=964136&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
Wed Jul 14 18:59:20 2010
@@ -661,4 +661,12 @@ public class JarFileTest extends TestCas
         res = jarFile.getInputStream(zipEntry).read();
         assertEquals("Wrong length of empty jar entry", -1, res);
     }
+
+    public void testJarWrittenWithFlush() throws IOException {
+        File f = new File(resources, "hyts_flushed.jar");
+        Support_Resources.copyFile(resources, null, "hyts_flushed.jar");
+
+        // Harmony crashes with ZipException: Central Directory Entry not found
+        new JarFile(f);
+    }
 }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/InetSocketAddress.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/InetSocketAddress.java?rev=964136&r1=964135&r2=964136&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/InetSocketAddress.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/InetSocketAddress.java
Wed Jul 14 18:59:20 2010
@@ -34,6 +34,8 @@ public class InetSocketAddress extends S
 
     private int port;
 
+    private transient boolean gotHostname = false;
+
     /**
      * Creates a socket endpoint with the given port number {@code port} and the
      * wildcard address {@code InetAddress.ANY}. The range for valid port numbers
@@ -102,7 +104,6 @@ public class InetSocketAddress extends S
         if (needResolved) {
             try {
                 addr = InetAddress.getByName(hostname);
-                hostname = null;
             } catch (UnknownHostException e) {
                 // Ignored
             }
@@ -153,7 +154,11 @@ public class InetSocketAddress extends S
      * @return the socket endpoint hostname.
      */
     public final String getHostName() {
-        return (null != addr) ? addr.getHostName() : hostname;
+        if (addr != null && !gotHostname) {
+            gotHostname = true;
+            hostname = addr.getHostName();
+        }
+        return  hostname;
     }
 
     /**

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLConnection.java?rev=964136&r1=964135&r2=964136&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLConnection.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLConnection.java
Wed Jul 14 18:59:20 2010
@@ -22,8 +22,10 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -103,6 +105,11 @@ public abstract class URLConnection {
     static Hashtable<String, Object> contentHandlers = new Hashtable<String, Object>();
 
     /**
+     * HashMap for storing request property key-valuelist pairs
+     */
+    private HashMap<String, List<String>> requestProperties = new HashMap<String,
List<String>>();
+
+    /**
      * A hashtable that maps the filename extension (key) to a MIME-type
      * (element)
      */
@@ -441,7 +448,12 @@ public abstract class URLConnection {
         if (connected) {
             throw new IllegalStateException(Messages.getString("luni.5E")); //$NON-NLS-1$
         }
-        return Collections.emptyMap();
+
+        HashMap<String, List<String>> map = new HashMap<String, List<String>>();
+        for (String key : requestProperties.keySet()) {
+            map.put(key, Collections.unmodifiableList(requestProperties.get(key)));
+        }
+        return Collections.unmodifiableMap(map);
     }
 
     /**
@@ -465,6 +477,15 @@ public abstract class URLConnection {
         if (field == null) {
             throw new NullPointerException(Messages.getString("luni.95")); //$NON-NLS-1$
         }
+
+        List<String> valuesList = requestProperties.get(field);
+        if (valuesList == null) {
+            valuesList = new ArrayList<String>();
+            valuesList.add(0, newValue);
+            requestProperties.put(field, valuesList);
+        } else {
+            valuesList.add(0, newValue);
+        }
     }
 
     /**
@@ -607,8 +628,7 @@ public abstract class URLConnection {
 
     /**
      * Gets the value of the request header property specified by {code field}
-     * or {@code null} if there is no field with this name. The current
-     * implementation of this method returns always {@code null}.
+     * or {@code null} if there is no field with this name.
      * 
      * @param field
      *            the name of the request header property.
@@ -620,7 +640,11 @@ public abstract class URLConnection {
         if (connected) {
             throw new IllegalStateException(Messages.getString("luni.5E")); //$NON-NLS-1$
         }
-        return null;
+        List<String> valuesList = requestProperties.get(field);
+        if (valuesList == null) {
+            return null;
+        }
+        return valuesList.get(0);
     }
 
     /**
@@ -955,6 +979,10 @@ public abstract class URLConnection {
         if (field == null) {
             throw new NullPointerException(Messages.getString("luni.95")); //$NON-NLS-1$
         }
+
+        List<String> valuesList = new ArrayList<String>();
+        valuesList.add(newValue);
+        requestProperties.put(field, valuesList);
     }
 
     /**

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramPacketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramPacketTest.java?rev=964136&r1=964135&r2=964136&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramPacketTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramPacketTest.java
Wed Jul 14 18:59:20 2010
@@ -134,43 +134,9 @@ public class DatagramPacketTest extends 
         DatagramSocket socket = new DatagramSocket(0, localhost);
         final int port = socket.getLocalPort();
 
-        final Object lock = new Object();
-
-        Thread thread = new Thread(new Runnable() {
-            public void run() {
-                DatagramSocket socket = null;
-                try {
-                    socket = new DatagramSocket(0, localhost);
-                    synchronized (lock) {
-                        started = true;
-                        lock.notifyAll();
-                    }
-                    socket.setSoTimeout(3000);
-                    DatagramPacket packet = new DatagramPacket(new byte[256],
-                            256);
-                    socket.receive(packet);
-                    socket.send(packet);
-                    socket.close();
-                } catch (IOException e) {
-                    System.out.println("thread exception: " + e);
-                    if (socket != null)
-                        socket.close();
-                }
-            }
-        });
-        thread.start();
-
         socket.setSoTimeout(3000);
         DatagramPacket packet = new DatagramPacket(new byte[] { 1, 2, 3, 4, 5,
                 6 }, 6, localhost, port);
-        synchronized (lock) {
-            while (!started) {
-                try {
-                    lock.wait();
-                } catch (InterruptedException e) {
-                }
-            }
-        }
         socket.send(packet);
         socket.receive(packet);
         socket.close();

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java?rev=964136&r1=964135&r2=964136&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java
Wed Jul 14 18:59:20 2010
@@ -31,7 +31,10 @@ public class InetSocketAddressTest exten
     public void test_ConstructorLjava_lang_StringI() throws Exception {
         // regression test for Harmony-1042
         InetSocketAddress address = new InetSocketAddress("127.0.0.1", 0);
-        assertNotNull(address.getHostName());
+        assertEquals("/127.0.0.1:0", address.toString());
+        String localhostName = address.getHostName();
+        assertNotNull(localhostName);
+        assertEquals(localhostName+"/127.0.0.1:0", address.toString());
     }
     
     /**

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java?rev=964136&r1=964135&r2=964136&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
Wed Jul 14 18:59:20 2010
@@ -38,7 +38,9 @@ import java.net.URLConnection;
 import java.net.URLStreamHandler;
 import java.security.Permission;
 import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.GregorianCalendar;
 import java.util.List;
 import java.util.Map;
@@ -129,6 +131,32 @@ public class URLConnectionTest extends j
             // expected
         }
 
+        u.addRequestProperty("key", "value");
+        u.addRequestProperty("key", "value2");
+        assertEquals("value2", u.getRequestProperty("key"));
+        ArrayList list = new ArrayList();
+        list.add("value2");
+        list.add("value");
+
+        Map<String,List<String>> propertyMap = u.getRequestProperties();
+        // Check this map is unmodifiable
+        try {
+            propertyMap.put("test", null);
+            fail("Map returned by URLConnection.getRequestProperties() should be unmodifiable");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+
+        List<String> valuesList = propertyMap.get("key");
+        // Check this list is also unmodifiable
+        try {
+            valuesList.add("test");
+            fail("List entries in the map returned by URLConnection.getRequestProperties()
should be unmodifiable");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+        assertEquals(list, valuesList);
+
         u.connect();
         try {
             // state of connection is checked first
@@ -1020,7 +1048,7 @@ public class URLConnectionTest extends j
         URL url = new URL("http", "test", 80, "index.html", new NewHandler());
         URLConnection urlCon = url.openConnection();
         urlCon.setRequestProperty("test", "testProperty");
-        assertNull(urlCon.getRequestProperty("test"));
+        assertEquals("testProperty", urlCon.getRequestProperty("test"));
 
         urlCon.connect();
         try {
@@ -1293,8 +1321,16 @@ public class URLConnectionTest extends j
      * @tests java.net.URLConnection#setRequestProperty(java.lang.String,
      *        java.lang.String)
      */
-    public void test_setRequestPropertyLjava_lang_StringLjava_lang_String() {
-        assertTrue("Used to test", true);
+    public void test_setRequestPropertyLjava_lang_StringLjava_lang_String() 
+                throws MalformedURLException{
+        MockURLConnection u = new MockURLConnection(new URL(
+                "http://www.apache.org"));
+
+        u.setRequestProperty("", "");
+        assertEquals("", u.getRequestProperty(""));
+
+        u.setRequestProperty("key", "value");
+        assertEquals("value", u.getRequestProperty("key"));
     }
 
     /**

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 14 18:59:20 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-963699
+/harmony/enhanced/java/trunk/drlvm:929253-964042
 /harmony/enhanced/trunk/drlvm:476395-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/drlvm:292550-476394

Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 14 18:59:20 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-963699
+/harmony/enhanced/java/trunk/jdktools:929253-964042
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:476395-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message