falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1323 Reverse lookup of feeds causes NPE. Contributed by Ajay Yadava.
Date Tue, 28 Jul 2015 10:17:34 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 4cda54073 -> 60e96f4a4


FALCON-1323 Reverse lookup of feeds causes NPE. Contributed by Ajay Yadava.


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/60e96f4a
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/60e96f4a
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/60e96f4a

Branch: refs/heads/master
Commit: 60e96f4a4088eb70eab7d6842dfd6d51bd521c98
Parents: 4cda540
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Tue Jul 28 15:32:32 2015 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Tue Jul 28 15:32:32 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                             |  2 ++
 .../org/apache/falcon/resource/FeedLookupResult.java    |  1 +
 .../java/org/apache/falcon/util/FalconRadixUtils.java   |  6 +-----
 .../test/java/org/apache/falcon/util/RadixTreeTest.java | 12 +++++++++++-
 4 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/60e96f4a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6017dbc..9847422 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -65,6 +65,8 @@ Trunk (Unreleased)
     (Suhas Vasu)
 
   BUG FIXES
+    FALCON-1323 Reverse lookup of feeds causes NPE(Ajay Yadava)
+
     FALCON-1329 Falcon's idempotent behaviour breaks in some cases(Ajay Yadava)
 
     FALCON-1282 Incorrect hdfs servers property for feed replication in secured environment(Venkat
Ranganathan via Ajay Yadava)

http://git-wip-us.apache.org/repos/asf/falcon/blob/60e96f4a/client/src/main/java/org/apache/falcon/resource/FeedLookupResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/resource/FeedLookupResult.java b/client/src/main/java/org/apache/falcon/resource/FeedLookupResult.java
index 72b088d..f8d58ae 100644
--- a/client/src/main/java/org/apache/falcon/resource/FeedLookupResult.java
+++ b/client/src/main/java/org/apache/falcon/resource/FeedLookupResult.java
@@ -79,6 +79,7 @@ public class FeedLookupResult extends APIResult {
         if (elements != null) {
             for (FeedProperties element : elements) {
                 buffer.append(element.toString());
+                buffer.append("\n");
             }
         }
         return buffer.toString();

http://git-wip-us.apache.org/repos/asf/falcon/blob/60e96f4a/common/src/main/java/org/apache/falcon/util/FalconRadixUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/util/FalconRadixUtils.java b/common/src/main/java/org/apache/falcon/util/FalconRadixUtils.java
index 0374dc1..35f03b9 100644
--- a/common/src/main/java/org/apache/falcon/util/FalconRadixUtils.java
+++ b/common/src/main/java/org/apache/falcon/util/FalconRadixUtils.java
@@ -193,7 +193,7 @@ public class FalconRadixUtils {
                     String regex = key.substring(0, key.indexOf("}") + 1);
                     // match the text and the regex
                     FeedDataPath.VARS var = getMatchingRegex(regex);
-                    if (matchPart(regex, input.substring(0, var.getValueSize()))) {
+                    if (matchPart(regex, remainingText.substring(0, var.getValueSize())))
{
                         newRoot = child; // if it matches then this is the newRoot
                         break;
                     }
@@ -251,10 +251,6 @@ public class FalconRadixUtils {
 
         private FeedDataPath.VARS getMatchingRegex(String inputPart) {
             //inputPart will be something like ${YEAR}
-
-            inputPart = inputPart.replace("${", "\\$\\{");
-            inputPart = inputPart.replace("}", "\\}");
-
             for (FeedDataPath.VARS var : FeedDataPath.VARS.values()) {
                 if (inputPart.equals("${" + var.name() + "}")) {
                     return var;

http://git-wip-us.apache.org/repos/asf/falcon/blob/60e96f4a/common/src/test/java/org/apache/falcon/util/RadixTreeTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/util/RadixTreeTest.java b/common/src/test/java/org/apache/falcon/util/RadixTreeTest.java
index b602a09..e8b0e5b 100644
--- a/common/src/test/java/org/apache/falcon/util/RadixTreeTest.java
+++ b/common/src/test/java/org/apache/falcon/util/RadixTreeTest.java
@@ -26,6 +26,7 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -42,7 +43,6 @@ public class RadixTreeTest {
         tree.insert("key1", "value1");
         tree.insert("key2", "value2");
         tree.insert("random", "random");
-
     }
 
     @AfterMethod
@@ -67,7 +67,17 @@ public class RadixTreeTest {
         Assert.assertEquals(tree.find("duplicatekey").size(), 2);
         Assert.assertTrue(tree.find("duplicatekey").contains("value1"));
         Assert.assertTrue(tree.find("duplicatekey").contains("value2"));
+    }
 
+    @Test
+    public void testGetNextCandidate() {
+        tree.insert("/projects/userplatform/${YEAR}-${MONTH}-${DAY}", "feed1");
+        tree.insert("/projects/userplatform/another", "feed2");
+        Collection<String> result = tree.find("/projects/userplatform/another");
+        Assert.assertTrue(result.contains("feed2"));
+
+        result = tree.find("/projects/userplatform/2014-07-07", regexAlgorithm);
+        Assert.assertTrue(result.contains("feed1"));
     }
 
     @Test


Mime
View raw message