sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject sqoop git commit: SQOOP-1786: Sqoop2: Stop using JSONValue.parse method call
Date Wed, 26 Nov 2014 11:10:05 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 6ea427f9f -> 39e99cc5f


SQOOP-1786: Sqoop2: Stop using JSONValue.parse method call

(Jarek Jarcec Cecho via Abraham Elmahrek)


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

Branch: refs/heads/sqoop2
Commit: 39e99cc5f049aca32dbc9ce25f28b85500b843f1
Parents: 6ea427f
Author: Abraham Elmahrek <abraham@elmahrek.com>
Authored: Wed Nov 26 02:47:11 2014 -0800
Committer: Abraham Elmahrek <abraham@elmahrek.com>
Committed: Wed Nov 26 02:47:11 2014 -0800

----------------------------------------------------------------------
 .../request/ConnectorResourceRequest.java       |  4 +-
 .../client/request/DriverResourceRequest.java   |  4 +-
 .../client/request/JobResourceRequest.java      | 10 +--
 .../client/request/LinkResourceRequest.java     |  8 +--
 .../sqoop/client/request/ResourceRequest.java   |  4 +-
 .../request/SubmissionResourceRequest.java      |  4 +-
 .../client/request/VersionResourceRequest.java  |  4 +-
 .../java/org/apache/sqoop/json/JSONUtils.java   | 70 ++++++++++++++++++++
 .../sqoop/json/util/SerializationError.java     |  2 +
 .../org/apache/sqoop/model/ConfigUtils.java     |  4 +-
 .../apache/sqoop/json/TestConnectorBean.java    |  3 +-
 .../apache/sqoop/json/TestConnectorsBean.java   |  7 +-
 .../org/apache/sqoop/json/TestDriverBean.java   |  3 +-
 .../org/apache/sqoop/json/TestJSONUtils.java    | 64 ++++++++++++++++++
 .../java/org/apache/sqoop/json/TestJobBean.java |  3 +-
 .../org/apache/sqoop/json/TestJobsBean.java     |  3 +-
 .../org/apache/sqoop/json/TestLinkBean.java     |  3 +-
 .../org/apache/sqoop/json/TestLinksBean.java    |  3 +-
 .../org/apache/sqoop/json/TestSchemaBean.java   |  3 +-
 .../apache/sqoop/json/TestSubmissionBean.java   |  5 +-
 .../apache/sqoop/json/TestThrowableBean.java    |  3 +-
 .../sqoop/json/TestValidationResultBean.java    |  5 +-
 .../json/util/TestConfigSerialization.java      |  8 +--
 .../json/util/TestSchemaSerialization.java      |  6 +-
 .../sqoop/job/mr/MRConfigurationUtils.java      |  4 +-
 .../apache/sqoop/handler/JobRequestHandler.java |  4 +-
 .../sqoop/handler/LinkRequestHandler.java       |  4 +-
 .../sqoop/tools/tool/RepositoryLoadTool.java    |  4 +-
 28 files changed, 187 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
index 5d41b3f..c6232d0 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
@@ -19,8 +19,8 @@ package org.apache.sqoop.client.request;
 
 import org.apache.sqoop.json.ConnectorBean;
 import org.apache.sqoop.json.ConnectorsBean;
+import org.apache.sqoop.json.JSONUtils;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 /**
  * Provide Read semantics over RESTfull HTTP API for connectors. Only read is
@@ -37,7 +37,7 @@ public class ConnectorResourceRequest extends ResourceRequest {
     } else {
       response = super.get(serverUrl + RESOURCE + cid);
     }
-    JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
+    JSONObject jsonObject = JSONUtils.parse(response);
     // defaults to all
     ConnectorBean bean = new ConnectorsBean();
     if (cid != null) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
index ca82f59..95bb12c 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
@@ -18,8 +18,8 @@
 package org.apache.sqoop.client.request;
 
 import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.json.JSONUtils;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 /**
  * Provide read semantics over RESTfull HTTP API for driver
@@ -31,7 +31,7 @@ public class DriverResourceRequest extends ResourceRequest {
   public DriverBean read(String serverUrl) {
     String response = null;
     response = super.get(serverUrl + RESOURCE);
-    JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
+    JSONObject jsonObject = JSONUtils.parse(response);
     DriverBean driverBean = new DriverBean();
     driverBean.restore(jsonObject);
     return driverBean;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
index 55c8db2..167e8be 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
@@ -17,13 +17,13 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.JobsBean;
 import org.apache.sqoop.json.SubmissionBean;
 import org.apache.sqoop.json.ValidationResultBean;
 import org.apache.sqoop.model.MJob;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 /**
  * Provide CRUD semantics over RESTfull HTTP API for jobs. All operations are
@@ -46,7 +46,7 @@ public class JobResourceRequest extends ResourceRequest {
     } else {
       response = super.get(serverUrl + RESOURCE + jobId);
     }
-    JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
+    JSONObject jsonObject = JSONUtils.parse(response);
     // defaults to all
     JobBean bean = new JobsBean();
     if (jobId != null) {
@@ -62,7 +62,7 @@ public class JobResourceRequest extends ResourceRequest {
     JSONObject jobJson = jobBean.extract(false);
     String response = super.post(serverUrl + RESOURCE, jobJson.toJSONString());
     ValidationResultBean validationResultBean = new ValidationResultBean();
-    validationResultBean.restore((JSONObject) JSONValue.parse(response));
+    validationResultBean.restore(JSONUtils.parse(response));
     return validationResultBean;
   }
 
@@ -73,7 +73,7 @@ public class JobResourceRequest extends ResourceRequest {
     String response = super.put(serverUrl + RESOURCE + job.getPersistenceId(),
         jobJson.toJSONString());
     ValidationResultBean validationBean = new ValidationResultBean();
-    validationBean.restore((JSONObject) JSONValue.parse(response));
+    validationBean.restore(JSONUtils.parse(response));
     return validationBean;
   }
 
@@ -106,7 +106,7 @@ public class JobResourceRequest extends ResourceRequest {
 
   private SubmissionBean createJobSubmissionResponse(String response) {
     SubmissionBean submissionBean = new SubmissionBean();
-    submissionBean.restore((JSONObject) JSONValue.parse(response));
+    submissionBean.restore(JSONUtils.parse(response));
     return submissionBean;
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
index f03acb4..9a4a134 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
@@ -17,12 +17,12 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.LinkBean;
 import org.apache.sqoop.json.LinksBean;
 import org.apache.sqoop.json.ValidationResultBean;
 import org.apache.sqoop.model.MLink;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 /**
  * Provide CRUD semantics over RESTfull HTTP API for links. All operations
@@ -42,7 +42,7 @@ public class LinkResourceRequest extends ResourceRequest {
     } else {
       response = super.get(serverUrl + LINK_RESOURCE + linkId);
     }
-    JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
+    JSONObject jsonObject = JSONUtils.parse(response);
     // defaults to all
     LinkBean bean = new LinksBean();
     if (linkId != null) {
@@ -58,7 +58,7 @@ public class LinkResourceRequest extends ResourceRequest {
     JSONObject linkJson = linkBean.extract(false);
     String response = super.post(serverUrl + LINK_RESOURCE, linkJson.toJSONString());
     ValidationResultBean validationBean = new ValidationResultBean();
-    validationBean.restore((JSONObject) JSONValue.parse(response));
+    validationBean.restore(JSONUtils.parse(response));
     return validationBean;
   }
 
@@ -68,7 +68,7 @@ public class LinkResourceRequest extends ResourceRequest {
     JSONObject linkJson = linkBean.extract(false);
     String response = super.put(serverUrl + LINK_RESOURCE + link.getPersistenceId(), linkJson.toJSONString());
     ValidationResultBean validationBean = new ValidationResultBean();
-    validationBean.restore((JSONObject) JSONValue.parse(response));
+    validationBean.restore(JSONUtils.parse(response));
     return validationBean;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
index 3c4a4d2..6be1db8 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
@@ -23,9 +23,9 @@ import org.apache.log4j.Logger;
 import org.apache.sqoop.client.ClientError;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.common.SqoopProtocolConstants;
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.ThrowableBean;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.MediaType;
@@ -107,7 +107,7 @@ public class ResourceRequest {
           }
           reader.close();
 
-          JSONObject json = (JSONObject) JSONValue.parse(result.toString());
+          JSONObject json = JSONUtils.parse(result.toString());
           ex.restore(json);
 
           throw new SqoopException(ClientError.CLIENT_0001, ex.getThrowable());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
index e3b70bc..47a0a94 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
@@ -17,9 +17,9 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.SubmissionsBean;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 /**
  * Provide CRD semantics over RESTfull HTTP API for submissions. Please note
@@ -36,7 +36,7 @@ public class SubmissionResourceRequest extends  ResourceRequest {
     } else {
       response = super.get(serverUrl + RESOURCE + jid);
     }
-    JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
+    JSONObject jsonObject = JSONUtils.parse(response);
     SubmissionsBean submissionBean = new SubmissionsBean();
     submissionBean.restore(jsonObject);
     return submissionBean;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
index cdd2a9b..7bd0dba 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
@@ -17,15 +17,15 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.VersionBean;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 public class VersionResourceRequest extends ResourceRequest
 {
   public VersionBean read(String serverUrl) {
     String response = super.get(serverUrl + "version");
-    JSONObject jsonObject = (JSONObject)JSONValue.parse(response);
+    JSONObject jsonObject = JSONUtils.parse(response);
 
     VersionBean versionBean = new VersionBean();
     versionBean.restore(jsonObject);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/main/java/org/apache/sqoop/json/JSONUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/JSONUtils.java b/common/src/main/java/org/apache/sqoop/json/JSONUtils.java
new file mode 100644
index 0000000..e7551d2
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/json/JSONUtils.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.json;
+
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.json.util.SerializationError;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+import org.json.simple.parser.ParseException;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ */
+public class JSONUtils {
+
+  /**
+   * Parse given string as JSON and return corresponding JSONObject.
+   *
+   * This method will throw SqoopException on any parsing error.
+   *
+   * @param input JSON encoded String
+   * @return
+   */
+  public static JSONObject parse(String input) {
+    try {
+      return (JSONObject) JSONValue.parseWithException(input);
+    } catch (ParseException e) {
+      throw new SqoopException(SerializationError.SERIALIZATION_002, e);
+    }
+  }
+
+  /**
+   * Parse given reader as JSON and return corresponding JSONObject.
+   *
+   * This method will throw SqoopException on any parsing error.
+   *
+   * @param reader
+   * @return
+   */
+  public static JSONObject parse(Reader reader) {
+    try {
+      return (JSONObject) JSONValue.parseWithException(reader);
+    } catch (ParseException e) {
+      throw new SqoopException(SerializationError.SERIALIZATION_002, e);
+    } catch (IOException e) {
+      throw new SqoopException(SerializationError.SERIALIZATION_002, e);
+    }
+  }
+
+  private JSONUtils() {
+    // Instantiation is prohibited
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/main/java/org/apache/sqoop/json/util/SerializationError.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/SerializationError.java b/common/src/main/java/org/apache/sqoop/json/util/SerializationError.java
index 13989a3..3d440da 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/SerializationError.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/SerializationError.java
@@ -23,6 +23,8 @@ public enum SerializationError implements ErrorCode {
 
   SERIALIZATION_001("Attempt to pass a non-map object to MAP type."),
 
+  SERIALIZATION_002("Invalid JSON"),
+
   ;
 
   private final String message;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
index 40db6f4..3765a6d 100644
--- a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
@@ -19,12 +19,12 @@ package org.apache.sqoop.model;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.utils.ClassUtils;
 import org.apache.sqoop.validation.ConfigValidationRunner;
 import org.apache.sqoop.validation.Message;
 import org.apache.sqoop.validation.ConfigValidationResult;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 import java.lang.reflect.Field;
 import java.util.HashMap;
@@ -456,7 +456,7 @@ public class  ConfigUtils {
     Class<?> klass = configuration.getClass();
 
     Set<String> configNames = new HashSet<String>();
-    JSONObject jsonConfigs = (JSONObject) JSONValue.parse(json);
+    JSONObject jsonConfigs = JSONUtils.parse(json);
 
     for(Field configField : klass.getDeclaredFields()) {
       configField.setAccessible(true);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
index bc73f1e..44d7dd9 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
@@ -30,7 +30,6 @@ import org.apache.sqoop.json.util.BeanTestUtil;
 import org.apache.sqoop.json.util.ConfigTestUtil;
 import org.apache.sqoop.model.MConnector;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 public class TestConnectorBean {
@@ -57,7 +56,7 @@ public class TestConnectorBean {
     String connectorJSONString = connectorJSON.toJSONString();
 
     // Retrieved transferred object
-    JSONObject parsedConnectors = (JSONObject) JSONValue.parse(connectorJSONString);
+    JSONObject parsedConnectors = JSONUtils.parse(connectorJSONString);
     ConnectorBean parsedConnectorBean = new ConnectorBean();
     parsedConnectorBean.restore(parsedConnectors);
     assertEquals(connectors.size(), 1);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java
index c76e407..b4370e6 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java
@@ -30,7 +30,6 @@ import org.apache.sqoop.json.util.BeanTestUtil;
 import org.apache.sqoop.json.util.ConfigTestUtil;
 import org.apache.sqoop.model.MConnector;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 public class TestConnectorsBean {
@@ -55,7 +54,7 @@ public class TestConnectorsBean {
     String connectorsJSONString = connectorsJSON.toJSONString();
 
     // Retrieved transferred object
-    JSONObject parsedConnectors = (JSONObject) JSONValue.parse(connectorsJSONString);
+    JSONObject parsedConnectors = JSONUtils.parse(connectorsJSONString);
     ConnectorsBean parsedConnectorsBean = new ConnectorsBean();
     parsedConnectorsBean.restore(parsedConnectors);
 
@@ -89,7 +88,7 @@ public class TestConnectorsBean {
     String string = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     ConnectorsBean retrievedBean = new ConnectorsBean();
     retrievedBean.restore(retrievedJson);
 
@@ -118,7 +117,7 @@ public class TestConnectorsBean {
     String string = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     ConnectorsBean retrievedBean = new ConnectorsBean();
     retrievedBean.restore(retrievedJson);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java b/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java
index 0c7f8bf..b72c432 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java
@@ -24,7 +24,6 @@ import java.util.ResourceBundle;
 import org.apache.sqoop.json.util.ConfigTestUtil;
 import org.apache.sqoop.model.MDriver;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 /**
@@ -48,7 +47,7 @@ public class TestDriverBean {
     String string = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     DriverBean retrievedBean = new DriverBean();
     retrievedBean.restore(retrievedJson);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java b/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java
new file mode 100644
index 0000000..7efee21
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.json;
+
+import org.apache.sqoop.common.SqoopException;
+import org.json.simple.JSONObject;
+import org.junit.Test;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ */
+public class TestJSONUtils {
+
+  @Test
+  public void testString() {
+    JSONObject object = JSONUtils.parse("{\"id\":3}");
+    assertEquals((long)3, object.get("id"));
+  }
+
+  @Test(expected = SqoopException.class)
+  public void testStringInvalid() {
+    JSONUtils.parse("{");
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void testStringNull() {
+    JSONUtils.parse((String)null);
+  }
+
+  @Test
+  public void testReader() {
+    JSONObject object = JSONUtils.parse(new StringReader("{\"id\":3}"));
+    assertEquals((long)3, object.get("id"));
+  }
+
+  @Test(expected = SqoopException.class)
+  public void testReaderInvalid() {
+    JSONUtils.parse(new StringReader("{"));
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void testReaderNull() {
+    JSONUtils.parse((Reader)null);
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
index d01ab01..98cfee8 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
@@ -26,7 +26,6 @@ import org.apache.sqoop.json.util.BeanTestUtil;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.json.simple.parser.ParseException;
 import org.junit.Test;
 
@@ -53,7 +52,7 @@ public class TestJobBean {
     String jobJsonString = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject parsedJobJson = (JSONObject) JSONValue.parse(jobJsonString);
+    JSONObject parsedJobJson = JSONUtils.parse(jobJsonString);
     JobBean parsedJobBean = new JobBean();
     parsedJobBean.restore(parsedJobJson);
     MJob target = parsedJobBean.getJobs().get(0);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
index c365dac..42fbf9d 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
@@ -28,7 +28,6 @@ import org.apache.sqoop.json.util.BeanTestUtil;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.json.simple.parser.ParseException;
 import org.junit.Test;
 
@@ -60,7 +59,7 @@ public class TestJobsBean {
     String jobJsonString = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject parsedJobsJson = (JSONObject) JSONValue.parse(jobJsonString);
+    JSONObject parsedJobsJson = JSONUtils.parse(jobJsonString);
     JobsBean parsedJobsBean = new JobsBean();
     parsedJobsBean.restore(parsedJobsJson);
     MJob retrievedJob1 = parsedJobsBean.getJobs().get(0);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
index d97b3ff..704e4da 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
@@ -29,7 +29,6 @@ import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 public class TestLinkBean {
@@ -62,7 +61,7 @@ public class TestLinkBean {
     String linkJsonString = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject parsedLinkJson = (JSONObject) JSONValue.parse(linkJsonString);
+    JSONObject parsedLinkJson = JSONUtils.parse(linkJsonString);
     LinkBean retrievedBean = new LinkBean();
     retrievedBean.restore(parsedLinkJson);
     MLink retrievedLink = retrievedBean.getLinks().get(0);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java b/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java
index b9f12cc..9633c5e 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java
@@ -30,7 +30,6 @@ import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 public class TestLinksBean {
@@ -70,7 +69,7 @@ public class TestLinksBean {
     String linkJsonString = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject parsedLinkJson = (JSONObject) JSONValue.parse(linkJsonString);
+    JSONObject parsedLinkJson = JSONUtils.parse(linkJsonString);
     LinksBean retrievedBean = new LinksBean();
     retrievedBean.restore(parsedLinkJson);
     MLink targetLink1 = retrievedBean.getLinks().get(0);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java b/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
index c7a7b2e..e8bc085 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
@@ -20,7 +20,6 @@ package org.apache.sqoop.json;
 import org.apache.sqoop.json.util.TestSchemaSerialization;
 import org.apache.sqoop.schema.Schema;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 /**
  * Run the same tests as TestSchemaSerialization, but using the SchamaBean
@@ -41,7 +40,7 @@ public class TestSchemaBean extends TestSchemaSerialization {
 
     String transferredString = extractJson.toJSONString();
 
-    JSONObject restoreJson = (JSONObject) JSONValue.parse(transferredString);
+    JSONObject restoreJson = JSONUtils.parse(transferredString);
     SchemaBean restoreBean = new SchemaBean();
     restoreBean.restore(restoreJson);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
index 99435c5..d07eda9 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
@@ -26,7 +26,6 @@ import org.apache.sqoop.submission.counter.Counter;
 import org.apache.sqoop.submission.counter.CounterGroup;
 import org.apache.sqoop.submission.counter.Counters;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 import java.util.ArrayList;
@@ -460,7 +459,7 @@ public class TestSubmissionBean {
 
     String string = json.toString();
 
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     SubmissionsBean retrievedBean = new SubmissionsBean();
     retrievedBean.restore(retrievedJson);
 
@@ -479,7 +478,7 @@ public class TestSubmissionBean {
 
     String string = json.toString();
 
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     SubmissionsBean retrievedBean = new SubmissionsBean();
     retrievedBean.restore(retrievedJson);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java b/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java
index 3614ec5..a67283c 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java
@@ -20,7 +20,6 @@ package org.apache.sqoop.json;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.json.util.SerializationError;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -68,7 +67,7 @@ public class TestThrowableBean {
     String string = json.toJSONString();
 
     // Retrieved transferred object
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     ThrowableBean retrievedBean = new ThrowableBean();
     retrievedBean.restore(retrievedJson);
     return retrievedBean.getThrowable();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
index 6691c41..c119e02 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
@@ -21,7 +21,6 @@ import org.apache.sqoop.validation.Message;
 import org.apache.sqoop.validation.Status;
 import org.apache.sqoop.validation.ConfigValidationResult;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 import java.util.LinkedList;
@@ -115,7 +114,7 @@ public class TestValidationResultBean {
 
     String string = json.toString();
 
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     ValidationResultBean retrievedBean = new ValidationResultBean();
     retrievedBean.restore(retrievedJson);
 
@@ -128,7 +127,7 @@ public class TestValidationResultBean {
 
     String string = json.toString();
 
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+    JSONObject retrievedJson = JSONUtils.parse(string);
     ValidationResultBean retrievedBean = new ValidationResultBean();
     retrievedBean.restore(retrievedJson);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
index 61fffad..9ae764a 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.model.MBooleanInput;
 import org.apache.sqoop.model.MConfig;
 import org.apache.sqoop.model.MConfigType;
@@ -35,7 +36,6 @@ import org.apache.sqoop.model.MIntegerInput;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 /**
@@ -63,7 +63,7 @@ public class TestConfigSerialization {
 
     // Exchange the data on string level
     String serializedJson = jsonObject.toJSONString();
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
+    JSONObject retrievedJson = JSONUtils.parse(serializedJson);
 
     // And retrieve back from JSON representation
     MConfig retrieved = ConfigInputSerialization.restoreConfig(retrievedJson);
@@ -90,7 +90,7 @@ public class TestConfigSerialization {
     String serializedJson = jsonObject.toJSONString();
 
     // Deserialize
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
+    JSONObject retrievedJson = JSONUtils.parse(serializedJson);
     MConfig retrieved = ConfigInputSerialization.restoreConfig(retrievedJson);
     assertEquals(map, retrieved.getMapInput("Map").getValue());
   }
@@ -111,7 +111,7 @@ public class TestConfigSerialization {
     // Replace map value with a fake string to force exception
     String badSerializedJson = serializedJson.replace("{\"A\":\"B\"}", "\"nonsensical string\"");
     System.out.println(badSerializedJson);
-    JSONObject retrievedJson = (JSONObject) JSONValue.parse(badSerializedJson);
+    JSONObject retrievedJson = JSONUtils.parse(badSerializedJson);
     ConfigInputSerialization.restoreConfig(retrievedJson);
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
b/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
index 8ae856f..1779bce 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.schema.NullSchema;
 import org.apache.sqoop.schema.Schema;
 import org.apache.sqoop.schema.type.Array;
@@ -40,7 +41,6 @@ import org.apache.sqoop.schema.type.Text;
 import org.apache.sqoop.schema.type.Time;
 import org.apache.sqoop.schema.type.Unknown;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.junit.Test;
 
 /**
@@ -52,7 +52,7 @@ public class TestSchemaSerialization {
   public void testSchemaNull() {
     // a null schema is treated as a NullSchema
     JSONObject extractJson = SchemaSerialization.extractSchema(null);
-    JSONObject restoreJson = (JSONObject) JSONValue.parse(extractJson.toJSONString());
+    JSONObject restoreJson = JSONUtils.parse(extractJson.toJSONString());
     assertEquals(NullSchema.getInstance(), SchemaSerialization.restoreSchema(restoreJson));
   }
 
@@ -189,7 +189,7 @@ public class TestSchemaSerialization {
   protected Schema transfer(Schema schema) {
     JSONObject extractJson = SchemaSerialization.extractSchema(schema);
     String transferredString = extractJson.toJSONString();
-    JSONObject restoreJson = (JSONObject) JSONValue.parse(transferredString);
+    JSONObject restoreJson = JSONUtils.parse(transferredString);
     return SchemaSerialization.restoreSchema(restoreJson);
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/MRConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/MRConfigurationUtils.java
b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/MRConfigurationUtils.java
index fb10e3c..e07ddd7 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/MRConfigurationUtils.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/MRConfigurationUtils.java
@@ -24,12 +24,12 @@ import org.apache.hadoop.mapreduce.Job;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.sqoop.common.Direction;
 import org.apache.sqoop.job.MRJobConstants;
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.util.SchemaSerialization;
 import org.apache.sqoop.model.ConfigUtils;
 import org.apache.sqoop.schema.Schema;
 import org.apache.sqoop.utils.ClassUtils;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 import java.io.InputStream;
 import java.util.Properties;
@@ -228,7 +228,7 @@ public final class MRConfigurationUtils {
       return null;
     }
 
-    JSONObject jsonSchema = (JSONObject) JSONValue.parse(new String(bytes));
+    JSONObject jsonSchema = JSONUtils.parse(new String(bytes));
     return SchemaSerialization.restoreSchema(jsonSchema);
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index 1312941..dc237b8 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -30,6 +30,7 @@ import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.connector.spi.SqoopConnector;
 import org.apache.sqoop.driver.Driver;
 import org.apache.sqoop.driver.JobManager;
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.JobsBean;
 import org.apache.sqoop.json.JsonBean;
@@ -51,7 +52,6 @@ import org.apache.sqoop.server.common.ServerError;
 import org.apache.sqoop.validation.ConfigValidationResult;
 import org.apache.sqoop.validation.Status;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 public class JobRequestHandler implements RequestHandler {
 
@@ -156,7 +156,7 @@ public class JobRequestHandler implements RequestHandler {
     JobBean bean = new JobBean();
 
     try {
-      JSONObject json = (JSONObject) JSONValue.parse(ctx.getRequest().getReader());
+      JSONObject json = JSONUtils.parse(ctx.getRequest().getReader());
       bean.restore(json);
     } catch (IOException e) {
       throw new SqoopException(ServerError.SERVER_0003, "Can't read request content", e);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
index d2d080b..2e12217 100644
--- a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
@@ -27,6 +27,7 @@ import org.apache.sqoop.audit.AuditLoggerManager;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.connector.spi.SqoopConnector;
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.JsonBean;
 import org.apache.sqoop.json.LinkBean;
 import org.apache.sqoop.json.LinksBean;
@@ -42,7 +43,6 @@ import org.apache.sqoop.server.RequestHandler;
 import org.apache.sqoop.server.common.ServerError;
 import org.apache.sqoop.validation.ConfigValidationResult;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 public class LinkRequestHandler implements RequestHandler {
 
@@ -110,7 +110,7 @@ public class LinkRequestHandler implements RequestHandler {
 
     LinkBean linkBean = new LinkBean();
     try {
-      JSONObject postData = (JSONObject) JSONValue.parse(ctx.getRequest().getReader());
+      JSONObject postData = JSONUtils.parse(ctx.getRequest().getReader());
       linkBean.restore(postData);
     } catch (IOException e) {
       throw new SqoopException(ServerError.SERVER_0003, "Can't read request content", e);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/39e99cc5/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
index 64b08fc..d0ebaed 100644
--- a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
+++ b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
@@ -42,6 +42,7 @@ import org.apache.sqoop.connector.spi.ConnectorConfigurableUpgrader;
 import org.apache.sqoop.connector.spi.SqoopConnector;
 import org.apache.sqoop.driver.Driver;
 import org.apache.sqoop.driver.DriverUpgrader;
+import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.LinkBean;
 import org.apache.sqoop.json.SubmissionBean;
@@ -66,7 +67,6 @@ import org.apache.sqoop.validation.ConfigValidationRunner;
 import org.apache.sqoop.validation.Status;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 
 /**
  * Load user-created content of Sqoop repository from a JSON formatted file The
@@ -93,7 +93,7 @@ public class RepositoryLoadTool extends ConfiguredTool {
       LOG.info("Reading JSON from file" + inputFileName);
       InputStream input = new FileInputStream(inputFileName);
       String jsonTxt = IOUtils.toString(input, Charsets.UTF_8);
-      JSONObject json = (JSONObject) JSONValue.parse(jsonTxt);
+      JSONObject json = JSONUtils.parse(jsonTxt);
       boolean res = load(json);
       input.close();
       return res;


Mime
View raw message