slfan1989 commented on PR #7343: URL: https://github.com/apache/hadoop/pull/7343#issuecomment-2629179820
@cnauroth Thank you very much for reviewing this PR! I apologize for not providing a detailed explanation of why we made these changes. Let me explain in detail why we made these modifications. After upgrading Jersey to version 2.46, we found that Jersey 2 handles requests differently compared to Jersey 1. Overall, it has become stricter. - Change 1: TestHsWebServices#testInvalidAccept This unit test is for the following interface: AMWebServices#get, with the code as follows: https://github.com/apache/hadoop/blob/44a5cba78ac7d29a72d3452fbd807f31ae90c325/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AMWebServices.java#L239-L245 This interface only accepts `MediaType.APPLICATION_JSON` and `MediaType.APPLICATION_XML` types, and does not accept `MediaType.TEXT_PLAIN`. Therefore, if we call it with `MediaType.TEXT_PLAIN`, a `NotAcceptableException` will be thrown. Therefore, we need to improve this unit test. - Change 2: TestHsWebServices#testInvalidAccept TestHsWebServices#testInvalidAccept also requires improvement for reasons similar to Change 1. - Change 3: ApplicationEntity#getQueue ApplicationEntity#getQueue is a necessary change. We made this modification because the unit test was failing previously. We can see this error at the following link: # https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7335/3/artifact/out/patch-unit-hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-jobclient.txt ``` [ERROR] org.apache.hadoop.mapred.TestMRTimelineEventHandling.testMRNewTimelineServiceEventHandling Time elapsed: 87.424 s <<< FAILURE! java.lang.AssertionError: Expected event : JOB_FINISHED not found in the file /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-7335/ubuntu-focal/src/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/target/TestMRTimelineEventHandling-test_dir/timeline_service_data/entities/yarn_cluster/jenkins/test-job-succeed/1/1738269699937/application_1738269698564_0001/MAPREDUCE_JOB/job_1738269698564_0001.thist at org.junit.Assert.fail(Assert.java:89) ....... ``` This is a somewhat subtle error. I spent a long time debugging before discovering it. This is a subtle error, and it took me a long time to identify the issue. The problem arises from the difference in how Jersey 1 and Jersey 2 handle complex type conversions to JSON. In Jersey 1, we could customize the conversion process, but in Jersey 2, we need to define custom JSON readers and writers. In my case, I defined a `TimelineEntitiesWriter.java`, which relies on `com.fasterxml.jackson.databind.ObjectMapper` for the conversion. If the object contains null values, a `NullPointerException` occurs during the conversion. Therefore, I have implemented handling for the conversion of this field. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
