sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [12/14] sqoop git commit: SQOOP-1773: Sqoop2: ClassAvailable validator null handling
Date Sat, 22 Nov 2014 01:43:57 GMT
SQOOP-1773: Sqoop2: ClassAvailable validator null handling

(Abraham Elmahrek via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/5d0862f8
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/5d0862f8
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/5d0862f8

Branch: refs/heads/cdh5-1.99.4
Commit: 5d0862f8272e09fbffcd3f3fa4541772eecb641c
Parents: 0b33c54
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Thu Nov 20 16:47:30 2014 -0800
Committer: Abraham Elmahrek <abraham@elmahrek.com>
Committed: Fri Nov 21 17:43:13 2014 -0800

----------------------------------------------------------------------
 .../sqoop/validation/validators/ClassAvailable.java     | 12 ++++++++----
 .../sqoop/validation/validators/TestClassAvailable.java |  5 +++++
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/5d0862f8/common/src/main/java/org/apache/sqoop/validation/validators/ClassAvailable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/validators/ClassAvailable.java
b/common/src/main/java/org/apache/sqoop/validation/validators/ClassAvailable.java
index 371a6b7..ed7434f 100644
--- a/common/src/main/java/org/apache/sqoop/validation/validators/ClassAvailable.java
+++ b/common/src/main/java/org/apache/sqoop/validation/validators/ClassAvailable.java
@@ -26,10 +26,14 @@ import org.apache.sqoop.validation.Status;
 public class ClassAvailable extends AbstractValidator<String> {
   @Override
   public void validate(String klass) {
-    try {
-      Class.forName(klass);
-    } catch (ClassNotFoundException e) {
-      addMessage(new Message(Status.ERROR, "Class not found"));
+    if (klass == null) {
+      addMessage(new Message(Status.ERROR, "Class cannot be null"));
+    } else {
+      try {
+        Class.forName(klass);
+      } catch (ClassNotFoundException e) {
+        addMessage(new Message(Status.ERROR, "Class not found"));
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/5d0862f8/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
b/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
index c08cf0a..cdfa2a9 100644
--- a/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
+++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
@@ -44,5 +44,10 @@ public class TestClassAvailable {
     assertEquals(1, validator.getMessages().size());
     messages = validator.getMessages();
     assertEquals(Status.ERROR, messages.get(0).getStatus());
+
+    validator.validate(null);
+    assertEquals(2, validator.getMessages().size());
+    messages = validator.getMessages();
+    assertEquals(Status.ERROR, messages.get(1).getStatus());
   }
 }


Mime
View raw message