azkaban-aplcache

issue #234 parameter substitution with parenthesis causes

5/9/2014 7:20:59 PM

Details

diff --git a/src/main/java/azkaban/execapp/JobRunner.java b/src/main/java/azkaban/execapp/JobRunner.java
index dd9ad96..3a2b8a4 100644
--- a/src/main/java/azkaban/execapp/JobRunner.java
+++ b/src/main/java/azkaban/execapp/JobRunner.java
@@ -503,7 +503,7 @@ public class JobRunner extends EventHandler implements Runnable {
 				job = jobtypeManager.buildJobExecutor(this.jobId, props, logger);
 			}
 			catch (JobTypeManagerException e) {
-				logger.error("Failed to build job type");
+				logger.error("Failed to build job type", e);
 				return false;
 			}
 		}
diff --git a/src/main/java/azkaban/utils/PropsUtils.java b/src/main/java/azkaban/utils/PropsUtils.java
index 2f826a3..6b05f62 100644
--- a/src/main/java/azkaban/utils/PropsUtils.java
+++ b/src/main/java/azkaban/utils/PropsUtils.java
@@ -268,6 +268,11 @@ public class PropsUtils {
 			throw new IllegalArgumentException("Expression " + value + " not well formed. " + e.getMessage(), e);
 		}
 		
+		if (result == null) {
+			// for backward compatibility it is best to return value
+			return value;
+		}
+		
 		String newValue = value.substring(0, lastIndex) + result.toString() + value.substring(nextClosed + 1);
 		return resolveVariableExpression(newValue, lastIndex, jexl);
 	}
diff --git a/unit/java/azkaban/test/jobExecutor/JavaProcessJobTest.java b/unit/java/azkaban/test/jobExecutor/JavaProcessJobTest.java
index e367a52..048801b 100644
--- a/unit/java/azkaban/test/jobExecutor/JavaProcessJobTest.java
+++ b/unit/java/azkaban/test/jobExecutor/JavaProcessJobTest.java
@@ -30,7 +30,7 @@ public class JavaProcessJobTest
     " By JULIE BOSMAN \n" +
     "Published: August 11, 2010 \n" +
     " \n" +
-    "Twelve years later, it may be Joe Fox���s turn to worry. Readers have gone from skipping small \n" +
+    "Twelve years later, it may be Joe Fox's turn to worry. Readers have gone from skipping small \n" +
     "bookstores to wondering if they need bookstores at all. More people are ordering books online  \n" +
     "or plucking them from the best-seller bin at Wal-Mart";
 
diff --git a/unit/java/azkaban/test/utils/PropsUtilsTest.java b/unit/java/azkaban/test/utils/PropsUtilsTest.java
index 6b34b48..75bc979 100644
--- a/unit/java/azkaban/test/utils/PropsUtilsTest.java
+++ b/unit/java/azkaban/test/utils/PropsUtilsTest.java
@@ -51,6 +51,19 @@ public class PropsUtilsTest {
 	}
 	
 	@Test
+	public void testInvalidSyntax() throws Exception {
+		Props propsGrandParent = new Props();
+		Props propsParent = new Props(propsGrandParent);
+		Props props = new Props(propsParent);
+		
+		propsParent.put("my", "name");
+		props.put("res1", "$(my)");
+		
+		Props resolved = PropsUtils.resolveProps(props);
+		Assert.assertEquals("$(my)", resolved.get("res1"));
+	}
+	
+	@Test
 	public void testExpressionResolution() throws IOException {
 		Props props = Props.of(
 			"normkey", "normal",