harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r1038521 - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java drlvm/ jdktools/
Date Wed, 24 Nov 2010 08:29:29 GMT
Author: hindessm
Date: Wed Nov 24 08:29:28 2010
New Revision: 1038521

URL: http://svn.apache.org/viewvc?rev=1038521&view=rev
Log:
Merge change from /harmony/enhanced/java/trunk@1038506:

  r1038506 | regisxu | 2010-11-24 07:23:48 +0000 (Wed, 24 Nov 2010) | 1 line
  
  Improve patch for HARMONY-6675 at r1035930: remove field 'isEnable' and mark more fileds
as 'final'.

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/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.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 Nov 24 08:29:28 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-1029636,1029773,1029853,1030005,1033407,1035930
+/harmony/enhanced/java/trunk:929253-1029636,1029773,1029853,1030005,1033407,1035930,1038506
 /harmony/enhanced/trunk:476395-929252
 /incubator/harmony/enhanced/trunk:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 24 08:29:28 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-1029636,1029773,1029853,1030005,1033407,1035930
+/harmony/enhanced/java/trunk/classlib:929253-1029636,1029773,1029853,1030005,1033407,1035930,1038506
 /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 Nov 24 08:29:28 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-1029636,1029773,1029853,1030005,1033407,1035930
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-1029636,1029773,1029853,1030005,1033407,1035930,1038506
 /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/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java?rev=1038521&r1=1038520&r2=1038521&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java
Wed Nov 24 08:29:28 2010
@@ -29,9 +29,9 @@ import java.util.LinkedList;
 public class FileCanonPathCache {
 
     static private class CacheElement {
-        String canonicalPath;
+        final String canonicalPath;
 
-        long timestamp;
+        final long timestamp;
 
         public CacheElement(String path) {
             this.canonicalPath = path;
@@ -44,25 +44,20 @@ public class FileCanonPathCache {
      */
     public static final int CACHE_SIZE = 256;
 
-    private static HashMap<String, CacheElement> cache = new HashMap<String, CacheElement>(
+    private static final HashMap<String, CacheElement> cache = new HashMap<String,
CacheElement>(
             CACHE_SIZE);
 
     /**
      * FIFO queue for tracking age of elements.
      */
-    private static LinkedList<String> list = new LinkedList<String>();
+    private static final LinkedList<String> list = new LinkedList<String>();
 
-    private static Object lock = new Object();
+    private static final Object lock = new Object();
 
     /**
      * Expired time, 0 disable this cache.
      */
-    private static long timeout = 30000;
-
-    /**
-     * Whether to enable this cache.
-     */
-    private static boolean isEnable = true;
+    private static volatile long timeout = 30000;
 
     public static final String FILE_CANONICAL_PATH_CACHE_TIMEOUT = "org.apache.harmony.file.canonical.path.cache.timeout";
 
@@ -74,8 +69,8 @@ public class FileCanonPathCache {
             // use default timeout value
         }
 
-        if (timeout <= 0) {
-            isEnable = false;
+        if (timeout < 0) {
+            timeout = 0;
         }
     }
 
@@ -88,7 +83,8 @@ public class FileCanonPathCache {
      * 
      */
     public static String get(String path) {
-        if (!isEnable) {
+        long localTimeout = timeout;
+        if (localTimeout == 0) {
             return null;
         }
 
@@ -102,7 +98,7 @@ public class FileCanonPathCache {
         }
 
         long time = System.currentTimeMillis();
-        if (time - element.timestamp > timeout) {
+        if (time - element.timestamp > localTimeout) {
             // remove all elements older than this one
             synchronized (lock) {
                 if (cache.get(path) != null) {
@@ -128,7 +124,7 @@ public class FileCanonPathCache {
      *            the canonical path of <code>path</code>.
      */
     public static void put(String path, String canonicalPath) {
-        if (!isEnable) {
+        if (timeout == 0) {
             return;
         }
 
@@ -148,7 +144,7 @@ public class FileCanonPathCache {
      * Remove all elements from cache.
      */
     public static void clear() {
-        if (!isEnable) {
+        if (timeout == 0) {
             return;
         }
 
@@ -163,10 +159,12 @@ public class FileCanonPathCache {
     }
 
     public static void setTimeout(long timeout) {
-        FileCanonPathCache.timeout = timeout;
-        if (timeout <= 0) {
-            clear();
-            isEnable = false;
+        synchronized (lock) {
+            if (timeout <= 0) {
+                timeout = 0;
+                clear();
+            }
+            FileCanonPathCache.timeout = timeout;
         }
     }
 }

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 24 08:29:28 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-1029636,1029773,1029853,1030005,1033407,1035930
+/harmony/enhanced/java/trunk/drlvm:929253-1029636,1029773,1029853,1030005,1033407,1035930,1038506
 /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 Nov 24 08:29:28 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-1029636,1029773,1029853,1030005,1033407,1035930
+/harmony/enhanced/java/trunk/jdktools:929253-1029636,1029773,1029853,1030005,1033407,1035930,1038506
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:476395-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message