hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077513 - /hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/filecache/DistributedCache.java
Date Fri, 04 Mar 2011 04:22:34 GMT
Author: omalley
Date: Fri Mar  4 04:22:33 2011
New Revision: 1077513

URL: http://svn.apache.org/viewvc?rev=1077513&view=rev
Log:
commit 3b48aac81171baefcb24a15f412784b4a9d0d662
Author: Amareshwari Sri Ramadasu <amarsri@yahoo-inc.com>
Date:   Thu Jun 24 09:50:11 2010 +0530

    MAPREDUCE-572 from https://issues.apache.org/jira/secure/attachment/12446321/patch-572-ydist.txt
    
    +++ b/YAHOO-CHANGES.txt
    +    MAPREDUCE-572. Fixes DistributedCache.checkURIs to throw error if link is
    +    missing for uri in cache archives. (amareshwari)
    +

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/filecache/DistributedCache.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/filecache/DistributedCache.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/filecache/DistributedCache.java?rev=1077513&r1=1077512&r2=1077513&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/filecache/DistributedCache.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/filecache/DistributedCache.java
Fri Mar  4 04:22:33 2011
@@ -705,39 +705,41 @@ public class DistributedCache {
    * @param uriFiles The uri array of urifiles
    * @param uriArchives the uri array of uri archives
    */
-  public static boolean checkURIs(URI[]  uriFiles, URI[] uriArchives){
+  public static boolean checkURIs(URI[]  uriFiles, URI[] uriArchives) {
     if ((uriFiles == null) && (uriArchives == null)){
       return true;
     }
-    if (uriFiles != null){
-      for (int i = 0; i < uriFiles.length; i++){
-        String frag1 = uriFiles[i].getFragment();
-        if (frag1 == null)
+    // check if fragment is null for any uri
+    // also check if there are any conflicts in fragment names
+    Set<String> fragments = new HashSet<String>();
+    
+    // iterate over file uris
+    if (uriFiles != null) {
+      for (int i = 0; i < uriFiles.length; i++) {
+        String fragment = uriFiles[i].getFragment();
+        if (fragment == null) {
           return false;
-        for (int j=i+1; j < uriFiles.length; j++){
-          String frag2 = uriFiles[j].getFragment();
-          if (frag2 == null)
-            return false;
-          if (frag1.equalsIgnoreCase(frag2))
-            return false;
         }
-        if (uriArchives != null){
-          for (int j = 0; j < uriArchives.length; j++){
-            String frag2 = uriArchives[j].getFragment();
-            if (frag2 == null){
-              return false;
-            }
-            if (frag1.equalsIgnoreCase(frag2))
-              return false;
-            for (int k=j+1; k < uriArchives.length; k++){
-              String frag3 = uriArchives[k].getFragment();
-              if (frag3 == null)
-                return false;
-              if (frag2.equalsIgnoreCase(frag3))
-                return false;
-            }
-          }
+        String lowerCaseFragment = fragment.toLowerCase();
+        if (fragments.contains(lowerCaseFragment)) {
+          return false;
+        }
+        fragments.add(lowerCaseFragment);
+      }
+    }
+    
+    // iterate over archive uris
+    if (uriArchives != null) {
+      for (int i = 0; i < uriArchives.length; i++) {
+        String fragment = uriArchives[i].getFragment();
+        if (fragment == null) {
+          return false;
+        }
+        String lowerCaseFragment = fragment.toLowerCase();
+        if (fragments.contains(lowerCaseFragment)) {
+          return false;
         }
+        fragments.add(lowerCaseFragment);
       }
     }
     return true;



Mime
View raw message