Skip to content

Commit 4d02075

Browse files
kgyrtkirkzchovan
authored andcommitted
HIVE-20071: Migrate to jackson 2.x and prevent usage (apache#2464) (Zoltan Haindrich reviewed by Krisztian Kasa)
1 parent 6436232 commit 4d02075

78 files changed

Lines changed: 348 additions & 252 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/src/java/org/apache/hadoop/hive/common/jsonexplain/Vertex.java

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,14 @@
1818

1919
package org.apache.hadoop.hive.common.jsonexplain;
2020

21-
import java.io.IOException;
2221
import java.util.ArrayList;
2322
import java.util.LinkedHashMap;
24-
import java.util.LinkedHashSet;
2523
import java.util.List;
2624
import java.util.Map;
2725
import java.util.Objects;
28-
import java.util.Set;
2926
import java.util.TreeMap;
3027

3128
import org.apache.hadoop.hive.common.jsonexplain.Op.OpType;
32-
import org.codehaus.jackson.JsonParseException;
33-
import org.codehaus.jackson.map.JsonMappingException;
3429
import org.json.JSONArray;
3530
import org.json.JSONException;
3631
import org.json.JSONObject;
@@ -68,7 +63,7 @@ public final class Vertex implements Comparable<Vertex>{
6863
// tag
6964
public String tag;
7065
protected final Logger LOG = LoggerFactory.getLogger(this.getClass().getName());
71-
66+
7267
public static enum VertexType {
7368
MAP, REDUCE, UNION, UNKNOWN
7469
};
@@ -106,16 +101,11 @@ public void addDependency(Connection connection) throws JSONException {
106101
}
107102

108103
/**
109-
* @throws JSONException
110-
* @throws JsonParseException
111-
* @throws JsonMappingException
112-
* @throws IOException
113104
* @throws Exception
114105
* We assume that there is a single top-level Map Operator Tree or a
115106
* Reduce Operator Tree in a vertex
116107
*/
117-
public void extractOpTree() throws JSONException, JsonParseException, JsonMappingException,
118-
IOException, Exception {
108+
public void extractOpTree() throws Exception {
119109
if (vertexObject.length() != 0) {
120110
for (String key : JSONObject.getNames(vertexObject)) {
121111
if (key.equals("Map Operator Tree:")) {
@@ -162,16 +152,11 @@ public void extractOpTree() throws JSONException, JsonParseException, JsonMappin
162152
* @param object
163153
* @param parent
164154
* @return
165-
* @throws JSONException
166-
* @throws JsonParseException
167-
* @throws JsonMappingException
168-
* @throws IOException
169155
* @throws Exception
170156
* assumption: each operator only has one parent but may have many
171157
* children
172158
*/
173-
Op extractOp(JSONObject object, Op parent) throws JSONException, JsonParseException, JsonMappingException,
174-
IOException, Exception {
159+
Op extractOp(JSONObject object, Op parent) throws Exception {
175160
String[] names = JSONObject.getNames(object);
176161
if (names.length != 1) {
177162
throw new Exception("Expect only one operator in " + object.toString());
@@ -224,8 +209,7 @@ Op extractOp(JSONObject object, Op parent) throws JSONException, JsonParseExcept
224209
}
225210
}
226211

227-
public void print(Printer printer, int indentFlag, String type, Vertex callingVertex)
228-
throws JSONException, Exception {
212+
public void print(Printer printer, int indentFlag, String type, Vertex callingVertex) throws Exception {
229213
// print vertexname
230214
if (parser.printSet.contains(this) && numReduceOp <= 1) {
231215
if (type != null) {
@@ -281,7 +265,7 @@ public void print(Printer printer, int indentFlag, String type, Vertex callingVe
281265

282266
/**
283267
* We check if a vertex has multiple reduce operators.
284-
* @throws JSONException
268+
* @throws JSONException
285269
*/
286270
public void checkMultiReduceOperator(boolean rewriteObject) throws JSONException {
287271
// check if it is a reduce vertex and its children is more than 1;
@@ -310,8 +294,12 @@ public void setType(String type) {
310294

311295
@Override
312296
public boolean equals(Object o) {
313-
if (this == o) return true;
314-
if (o == null || getClass() != o.getClass()) return false;
297+
if (this == o) {
298+
return true;
299+
}
300+
if (o == null || getClass() != o.getClass()) {
301+
return false;
302+
}
315303
Vertex vertex = (Vertex) o;
316304
return Objects.equals(name, vertex.name) &&
317305
Objects.equals(stage, vertex.stage) &&

common/src/java/org/apache/hive/http/JMXJsonServlet.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@
4444
import javax.servlet.http.HttpServletRequest;
4545
import javax.servlet.http.HttpServletResponse;
4646

47-
import org.codehaus.jackson.JsonFactory;
48-
import org.codehaus.jackson.JsonGenerator;
4947
import org.slf4j.Logger;
5048
import org.slf4j.LoggerFactory;
5149

50+
import com.fasterxml.jackson.core.JsonFactory;
51+
import com.fasterxml.jackson.core.JsonGenerator;
52+
5253
/*
5354
* This servlet is based off of the JMXProxyServlet from Tomcat 7.0.14. It has
5455
* been rewritten to be read only and to output in a JSON format so it is not
@@ -72,7 +73,7 @@
7273
* attribute of a JMX bean. The format of the URL is
7374
* <code>http://.../jmx?get=MXBeanName::AttributeName</code>
7475
* <p>
75-
* For example
76+
* For example
7677
* <code>
7778
* http://../jmx?get=Hadoop:service=NameNode,name=NameNodeInfo::ClusterId
7879
* </code> will return the cluster id of the namenode mxbean.
@@ -98,23 +99,23 @@
9899
* <p>
99100
* The servlet attempts to convert the JMXBeans into JSON. Each
100101
* bean's attributes will be converted to a JSON object member.
101-
*
102+
*
102103
* If the attribute is a boolean, a number, a string, or an array
103-
* it will be converted to the JSON equivalent.
104-
*
104+
* it will be converted to the JSON equivalent.
105+
*
105106
* If the value is a {@link CompositeData} then it will be converted
106107
* to a JSON object with the keys as the name of the JSON member and
107108
* the value is converted following these same rules.
108-
*
109+
*
109110
* If the value is a {@link TabularData} then it will be converted
110111
* to an array of the {@link CompositeData} elements that it contains.
111-
*
112+
*
112113
* All other objects will be converted to a string and output as such.
113-
*
114+
*
114115
* The bean's name and modelerType will be returned for all beans.
115116
*
116117
* Optional paramater "callback" should be used to deliver JSONP response.
117-
*
118+
*
118119
*/
119120
public class JMXJsonServlet extends HttpServlet {
120121
private static final Logger LOG = LoggerFactory.getLogger(JMXJsonServlet.class);
@@ -144,7 +145,7 @@ public void init() throws ServletException {
144145

145146
/**
146147
* Process a GET request for the specified resource.
147-
*
148+
*
148149
* @param request
149150
* The servlet request we are processing
150151
* @param response
@@ -210,8 +211,8 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {
210211
}
211212

212213
// --------------------------------------------------------- Private Methods
213-
private void listBeans(JsonGenerator jg, ObjectName qry, String attribute,
214-
HttpServletResponse response)
214+
private void listBeans(JsonGenerator jg, ObjectName qry, String attribute,
215+
HttpServletResponse response)
215216
throws IOException {
216217
LOG.debug("Listing beans for "+qry);
217218
Set<ObjectName> names = null;
@@ -255,7 +256,7 @@ private void listBeans(JsonGenerator jg, ObjectName qry, String attribute,
255256
+ " threw an exception", e);
256257
} catch ( ReflectionException e ) {
257258
// This happens when the code inside the JMX bean (setter?? from the
258-
// java docs) threw an exception, so log it and fall back on the
259+
// java docs) threw an exception, so log it and fall back on the
259260
// class name
260261
LOG.error("getting attribute " + prs + " of " + oname
261262
+ " threw an exception", e);

common/src/java/org/apache/hive/http/Log4j2ConfiguratorServlet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232
import org.apache.logging.log4j.core.LoggerContext;
3333
import org.apache.logging.log4j.core.config.Configuration;
3434
import org.apache.logging.log4j.core.config.LoggerConfig;
35-
import org.codehaus.jackson.map.ObjectMapper;
3635
import org.slf4j.Logger;
3736
import org.slf4j.LoggerFactory;
3837

38+
import com.fasterxml.jackson.databind.ObjectMapper;
39+
3940
/**
4041
* A servlet to configure log4j2.
4142
* <br>

hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAddPartitionMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package org.apache.hive.hcatalog.messaging.json;
2121

2222
import org.apache.hive.hcatalog.messaging.AddPartitionMessage;
23-
import org.codehaus.jackson.annotate.JsonProperty;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
2424

2525
import java.util.List;
2626
import java.util.Map;

hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterPartitionMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.apache.hive.hcatalog.common.HCatConstants;
2323
import org.apache.hive.hcatalog.messaging.AlterPartitionMessage;
2424
import org.apache.hive.hcatalog.messaging.AlterTableMessage;
25-
import org.codehaus.jackson.annotate.JsonProperty;
25+
import com.fasterxml.jackson.annotation.JsonProperty;
2626

2727
import java.util.ArrayList;
2828
import java.util.List;

hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterTableMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.apache.hadoop.hive.metastore.api.FieldSchema;
2222
import org.apache.hive.hcatalog.common.HCatConstants;
2323
import org.apache.hive.hcatalog.messaging.AlterTableMessage;
24-
import org.codehaus.jackson.annotate.JsonProperty;
24+
import com.fasterxml.jackson.annotation.JsonProperty;
2525

2626
import java.util.ArrayList;
2727
import java.util.List;

hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateDatabaseMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package org.apache.hive.hcatalog.messaging.json;
2121

2222
import org.apache.hive.hcatalog.messaging.CreateDatabaseMessage;
23-
import org.codehaus.jackson.annotate.JsonProperty;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
2424

2525
/**
2626
* JSON Implementation of CreateDatabaseMessage.

hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateFunctionMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
2424
import org.apache.hive.hcatalog.messaging.CreateFunctionMessage;
2525
import org.apache.thrift.TException;
26-
import org.codehaus.jackson.annotate.JsonProperty;
26+
import com.fasterxml.jackson.annotation.JsonProperty;
2727

2828
/**
2929
* JSON Implementation of CreateFunctionMessage.

hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateTableMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package org.apache.hive.hcatalog.messaging.json;
2121

2222
import org.apache.hive.hcatalog.messaging.CreateTableMessage;
23-
import org.codehaus.jackson.annotate.JsonProperty;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
2424

2525
/**
2626
* JSON implementation of CreateTableMessage.

hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropDatabaseMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package org.apache.hive.hcatalog.messaging.json;
2121

2222
import org.apache.hive.hcatalog.messaging.DropDatabaseMessage;
23-
import org.codehaus.jackson.annotate.JsonProperty;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
2424

2525
/**
2626
* JSON implementation of DropDatabaseMessage.

0 commit comments

Comments
 (0)