sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-1773: Sqoop2: ClassAvailable validator null handling
Date Fri, 21 Nov 2014 00:48:07 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 ae24e4893 -> 3349ae263


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/3349ae26
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/3349ae26
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/3349ae26

Branch: refs/heads/sqoop2
Commit: 3349ae263d939dbbbac9d74e187e2f75600332c1
Parents: ae24e48
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Thu Nov 20 16:47:30 2014 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Thu Nov 20 16:47:30 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/3349ae26/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/3349ae26/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