Skip to content

Commit 2dea809

Browse files
committed
fix by review
1 parent 6bebef6 commit 2dea809

23 files changed

+147
-176
lines changed

hadoop-project/pom.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
<!-- jersey version -->
6868
<jersey2.version>2.46</jersey2.version>
6969

70+
<!-- eclipse persistence -->
71+
<eclipse-persistence.version>2.7.14</eclipse-persistence.version>
72+
7073
<!-- jaxb version -->
7174
<jaxb.version>2.3.9</jaxb.version>
7275

@@ -2147,9 +2150,9 @@
21472150
<version>${jersey2.version}</version>
21482151
</dependency>
21492152
<dependency>
2150-
<groupId>org.glassfish.jersey.media</groupId>
2151-
<artifactId>jersey-media-moxy</artifactId>
2152-
<version>${jersey2.version}</version>
2153+
<groupId>org.eclipse.persistence</groupId>
2154+
<artifactId>org.eclipse.persistence.moxy</artifactId>
2155+
<version>${eclipse-persistence.version}</version>
21532156
</dependency>
21542157
<dependency>
21552158
<groupId>org.glassfish.jaxb</groupId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public void setUp() throws Exception {
4040
}
4141

4242
public final WebTarget targetWithJsonObject() {
43-
return target();
43+
return target().register(new JettisonObjectProvider.App());
4444
}
4545
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
<scope>test</scope>
263263
</dependency>
264264
<dependency>
265-
<groupId>org.glassfish.jersey.media</groupId>
266-
<artifactId>jersey-media-moxy</artifactId>
265+
<groupId>org.eclipse.persistence</groupId>
266+
<artifactId>org.eclipse.persistence.moxy</artifactId>
267267
</dependency>
268268
<dependency>
269269
<groupId>org.mockito</groupId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.net.InetSocketAddress;
2424

2525
import org.apache.hadoop.conf.Configuration;
26-
2726
import org.slf4j.Logger;
2827
import org.slf4j.LoggerFactory;
2928
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/jsonprovider/JsonProviderFeature.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import javax.ws.rs.core.Feature;
2222
import javax.ws.rs.core.FeatureContext;
2323

24-
import org.glassfish.jersey.CommonProperties;
25-
2624
/**
2725
* A JAX-RS {@link Feature} that registers custom MOXy JSON providers
2826
* for handling serialization and deserialization of JSON with or without
@@ -35,8 +33,6 @@
3533
*
3634
* <p>Configuration details:</p>
3735
* <ul>
38-
* <li>Disables automatic MOXy JSON feature discovery by setting
39-
* {@link org.glassfish.jersey.CommonProperties#MOXY_JSON_FEATURE_DISABLE} to {@code true}.</li>
4036
* <li>Registers {@link IncludeRootJSONProvider} with priority {@code 2001}.</li>
4137
* <li>Registers {@link ExcludeRootJSONProvider} with priority {@code 2002}.</li>
4238
* </ul>
@@ -48,16 +44,15 @@
4844
public class JsonProviderFeature implements Feature {
4945

5046
/**
51-
* Configures the feature by registering the custom JSON providers
52-
* and disabling MOXy auto-discovery.
47+
* Configures the feature by registering the custom JSON providers.
5348
*
5449
* @param context the {@link FeatureContext} provided by the JAX-RS runtime
5550
* @return {@code true} to indicate that the feature was successfully configured
5651
*/
5752
@Override
5853
public boolean configure(FeatureContext context) {
59-
//Auto discovery should be disabled to ensure the custom providers will be used
60-
context.property(CommonProperties.MOXY_JSON_FEATURE_DISABLE, true);
54+
// Priorities are used to maintain order between the JSONProviders.
55+
// This way, we can improve the determinism of the app.
6156
context.register(IncludeRootJSONProvider.class, 2001);
6257
context.register(ExcludeRootJSONProvider.class, 2002);
6358
return true;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMHA.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ private void checkActiveRMWebServices() throws JSONException {
175175
.get(Response.class);
176176
assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
177177
response.getMediaType().toString());
178-
String raw = response.readEntity(String.class);
179-
JSONObject json = new JSONObject(raw);
178+
JSONObject json = response.readEntity(JSONObject.class);
180179

181180
assertEquals(1, json.length(), "incorrect number of elements");
182181
JSONObject appJson = json.getJSONObject("app");

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServiceAppsNodelabel.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
2020

21-
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.responseToJson;
2221
import static org.junit.jupiter.api.Assertions.assertEquals;
2322
import static org.junit.jupiter.api.Assertions.assertTrue;
2423
import static org.junit.jupiter.api.Assertions.fail;
@@ -154,7 +153,7 @@ public void testAppsFinished() throws JSONException, Exception {
154153
Response response =
155154
r.path("ws").path("v1").path("cluster").path("apps")
156155
.request(MediaType.APPLICATION_JSON).get(Response.class);
157-
JSONObject json = responseToJson(response);
156+
JSONObject json = response.readEntity(JSONObject.class);
158157
JSONObject apps = json.getJSONObject("apps");
159158
assertEquals(1, apps.length(), "incorrect number of elements");
160159
try {
@@ -195,7 +194,7 @@ public void testAppsRunning() throws JSONException, Exception {
195194

196195
Response response = r.path("ws").path("v1").path("cluster").path("apps")
197196
.request(MediaType.APPLICATION_JSON).get(Response.class);
198-
JSONObject json = responseToJson(response);
197+
JSONObject json = response.readEntity(JSONObject.class);
199198

200199
// Verify apps resource
201200
JSONObject apps = json.getJSONObject("apps");

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
2020

21-
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.responseToJson;
2221
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
2322
import static org.junit.jupiter.api.Assertions.assertEquals;
2423
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -244,7 +243,7 @@ public void testCluster() throws JSONException, Exception {
244243

245244
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
246245
response.getMediaType().toString());
247-
JSONObject json = responseToJson(response);
246+
JSONObject json = response.readEntity(JSONObject.class);
248247
verifyClusterInfo(json);
249248
}
250249

@@ -257,7 +256,7 @@ public void testClusterSlash() throws JSONException, Exception {
257256

258257
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
259258
response.getMediaType().toString());
260-
JSONObject json = responseToJson(response);
259+
JSONObject json = response.readEntity(JSONObject.class);
261260
verifyClusterInfo(json);
262261
}
263262

@@ -270,7 +269,7 @@ public void testClusterDefault() throws JSONException, Exception {
270269

271270
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
272271
response.getMediaType().toString());
273-
JSONObject json = responseToJson(response);
272+
JSONObject json = response.readEntity(JSONObject.class);
274273
verifyClusterInfo(json);
275274
}
276275

@@ -283,7 +282,7 @@ public void testInfo() throws JSONException, Exception {
283282

284283
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
285284
response.getMediaType().toString());
286-
JSONObject json = responseToJson(response);
285+
JSONObject json = response.readEntity(JSONObject.class);
287286
verifyClusterInfo(json);
288287
}
289288

@@ -297,7 +296,7 @@ public void testInfoSlash() throws JSONException, Exception {
297296

298297
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
299298
response.getMediaType().toString());
300-
JSONObject json = responseToJson(response);
299+
JSONObject json = response.readEntity(JSONObject.class);
301300
verifyClusterInfo(json);
302301
}
303302

@@ -309,7 +308,7 @@ public void testInfoDefault() throws JSONException, Exception {
309308

310309
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
311310
response.getMediaType().toString());
312-
JSONObject json = responseToJson(response);
311+
JSONObject json = response.readEntity(JSONObject.class);
313312
verifyClusterInfo(json);
314313
}
315314

@@ -397,7 +396,7 @@ public void testClusterMetrics() throws JSONException, Exception {
397396

398397
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
399398
response.getMediaType().toString());
400-
JSONObject json = responseToJson(response);
399+
JSONObject json = response.readEntity(JSONObject.class);
401400
verifyClusterMetricsJSON(json);
402401
}
403402

@@ -410,7 +409,7 @@ public void testClusterMetricsSlash() throws JSONException, Exception {
410409

411410
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
412411
response.getMediaType().toString());
413-
JSONObject json = responseToJson(response);
412+
JSONObject json = response.readEntity(JSONObject.class);
414413
verifyClusterMetricsJSON(json);
415414
}
416415

@@ -422,7 +421,7 @@ public void testClusterMetricsDefault() throws JSONException, Exception {
422421

423422
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
424423
response.getMediaType().toString());
425-
JSONObject json =responseToJson(response);
424+
JSONObject json = response.readEntity(JSONObject.class);
426425
verifyClusterMetricsJSON(json);
427426
}
428427

@@ -554,7 +553,7 @@ public void testClusterSchedulerFifo() throws JSONException, Exception {
554553

555554
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
556555
response.getMediaType().toString());
557-
JSONObject json = responseToJson(response);
556+
JSONObject json = response.readEntity(JSONObject.class);
558557
verifyClusterSchedulerFifo(json);
559558
}
560559

@@ -567,7 +566,7 @@ public void testClusterSchedulerFifoSlash() throws JSONException, Exception {
567566

568567
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
569568
response.getMediaType().toString());
570-
JSONObject json = responseToJson(response);
569+
JSONObject json = response.readEntity(JSONObject.class);
571570
verifyClusterSchedulerFifo(json);
572571
}
573572

@@ -579,7 +578,7 @@ public void testClusterSchedulerFifoDefault() throws JSONException, Exception {
579578

580579
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
581580
response.getMediaType().toString());
582-
JSONObject json = responseToJson(response);
581+
JSONObject json = response.readEntity(JSONObject.class);
583582
verifyClusterSchedulerFifo(json);
584583
}
585584

@@ -1091,7 +1090,7 @@ public void testClusterSchedulerOverviewFifo() throws JSONException, Exception {
10911090

10921091
assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
10931092
response.getMediaType().toString());
1094-
JSONObject json = responseToJson(response);
1093+
JSONObject json = response.readEntity(JSONObject.class);
10951094
JSONObject schedulerJson = json.getJSONObject("scheduler");
10961095
verifyClusterSchedulerOverView(schedulerJson, "Fifo Scheduler");
10971096
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesAppAttempts.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import java.io.StringReader;
6464
import java.util.Collection;
6565

66-
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.responseToJson;
6766
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
6867
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.checkStringMatch;
6968
import static org.assertj.core.api.Assertions.assertThat;
@@ -155,7 +154,7 @@ public void testCompletedAppAttempt() throws Exception {
155154
.path("apps").path(app1.getApplicationId().toString())
156155
.path("appattempts").request(MediaType.APPLICATION_JSON)
157156
.get(Response.class);
158-
JSONObject json = responseToJson(response);
157+
JSONObject json = response.readEntity(JSONObject.class);
159158
JSONObject jsonAppAttempts = json.getJSONObject("appAttempts");
160159
JSONArray jsonArray = jsonAppAttempts.getJSONArray("appAttempt");
161160
JSONObject info = jsonArray.getJSONObject(0);
@@ -247,7 +246,7 @@ public void testInvalidAppIdGetAttempts() throws Exception {
247246
assertResponseStatusCode(Response.Status.BAD_REQUEST, response.getStatusInfo());
248247
assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
249248
response.getMediaType().toString());
250-
JSONObject msg = responseToJson(response);
249+
JSONObject msg = response.readEntity(JSONObject.class);
251250
JSONObject exception = msg.getJSONObject("RemoteException");
252251
assertEquals(3, exception.length(), "incorrect number of elements");
253252
String message = exception.getString("message");
@@ -284,7 +283,7 @@ public void testInvalidAppAttemptId() throws Exception {
284283
response.getStatusInfo());
285284
assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
286285
response.getMediaType().toString());
287-
JSONObject msg = responseToJson(response);
286+
JSONObject msg = response.readEntity(JSONObject.class);
288287
JSONObject exception = msg.getJSONObject("RemoteException");
289288
assertEquals(3, exception.length(), "incorrect number of elements");
290289
String message = exception.getString("message");
@@ -325,7 +324,7 @@ public void testNonexistAppAttempts() throws Exception {
325324
assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
326325
response.getMediaType().toString());
327326

328-
JSONObject msg = responseToJson(response);
327+
JSONObject msg = response.readEntity(JSONObject.class);
329328
JSONObject exception = msg.getJSONObject("RemoteException");
330329
assertEquals(3, exception.length(), "incorrect number of elements");
331330
String message = exception.getString("message");
@@ -349,7 +348,7 @@ private void testAppAttemptsHelper(String path, RMApp app, String media)
349348
.get(Response.class);
350349
assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
351350
response.getMediaType().toString());
352-
JSONObject json = responseToJson(response);
351+
JSONObject json = response.readEntity(JSONObject.class);
353352
assertEquals(1, json.length(), "incorrect number of elements");
354353
JSONObject jsonAppAttempts = json.getJSONObject("appAttempts");
355354
assertEquals(1, jsonAppAttempts.length(), "incorrect number of elements");

0 commit comments

Comments
 (0)