dakotahNorth / solace-spring-boot-starter

0 stars 0 forks source link

Convert from FasterXML/Jackson to FastJSON #1

Closed dakotahNorth closed 6 months ago

dakotahNorth commented 6 months ago

Based on the results from these tests ... https://github.com/fabienrenaud/java-json-benchmark

From a performance POV, these tests demonstrate that FastJSON is faster then FasterXML/Jackson.

Switch the project from using FasterXML / Jackson to instead use the FastJSON API (https://github.com/alibaba/fastjson)

Other reason for switching is that Jackson wasn't playing nicely with manifold.systems JSON.

Checklist - [X] Modify `src/main/java/com/example/solace/springboot/starter/messaging/SolaceMessageListener.java` ✓ https://github.com/dakotahNorth/solace-spring-boot-starter/commit/eab5b3a1057c09ce48cffe5758afdd0262ce4867 [Edit](https://github.com/dakotahNorth/solace-spring-boot-starter/edit/sweep/convert_from_fasterxmljackson_to_fastjso/src/main/java/com/example/solace/springboot/starter/messaging/SolaceMessageListener.java) - [X] Running GitHub Actions for `src/main/java/com/example/solace/springboot/starter/messaging/SolaceMessageListener.java` ✓ [Edit](https://github.com/dakotahNorth/solace-spring-boot-starter/edit/sweep/convert_from_fasterxmljackson_to_fastjso/src/main/java/com/example/solace/springboot/starter/messaging/SolaceMessageListener.java) - [X] Modify `pom.xml` ✓ https://github.com/dakotahNorth/solace-spring-boot-starter/commit/a74738cfcaf00dfdb3713e70ce214f4b6d8a8631 [Edit](https://github.com/dakotahNorth/solace-spring-boot-starter/edit/sweep/convert_from_fasterxmljackson_to_fastjso/pom.xml) - [X] Running GitHub Actions for `pom.xml` ✓ [Edit](https://github.com/dakotahNorth/solace-spring-boot-starter/edit/sweep/convert_from_fasterxmljackson_to_fastjso/pom.xml)
sweep-ai[bot] commented 6 months ago

🚀 Here's the PR! #3

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: d6a749c99a)
Install Sweep Configs: Pull Request

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/dakotahNorth/solace-spring-boot-starter/blob/21916c89c89416cd4c8ca8bc7224fdb2bb8dcadc/src/main/java/com/example/solace/springboot/starter/messaging/MessageHandler.java#L1-L5 https://github.com/dakotahNorth/solace-spring-boot-starter/blob/21916c89c89416cd4c8ca8bc7224fdb2bb8dcadc/src/main/java/com/example/solace/springboot/starter/messaging/SolaceMessageListener.java#L1-L160 https://github.com/dakotahNorth/solace-spring-boot-starter/blob/21916c89c89416cd4c8ca8bc7224fdb2bb8dcadc/src/main/resources/application.conf#L1-L5 https://github.com/dakotahNorth/solace-spring-boot-starter/blob/21916c89c89416cd4c8ca8bc7224fdb2bb8dcadc/pom.xml#L1-L161

Step 2: ⌨️ Coding

--- 
+++ 
@@ -1,7 +1,7 @@
 package com.example.solace.springboot.starter.messaging;

-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.solacesystems.jcsmp.BytesXMLMessage;
 import com.solacesystems.jcsmp.ConsumerFlowProperties;
 import com.solacesystems.jcsmp.EndpointProperties;
@@ -68,7 +68,7 @@
     private Consumer createHandler(Method method, Class eventClass, Object bean) {
         return jsonNode -> {
             try {
-                Object event = objectMapper.treeToValue(jsonNode, eventClass);
+                Object event = JSON.toJavaObject(jsonNode, eventClass);
                 method.setAccessible(true);
                 method.invoke(bean, event);
             } catch (Exception e) {
@@ -122,7 +122,7 @@

     public void onMessageReceived(String messagePayload) {
         try {
-            JsonNode rootNode = objectMapper.readTree(messagePayload);
+            JSONObject rootNode = JSON.parseObject(messagePayload);
             String messageType = rootNode.path("messageType").asText();
             Consumer handler = messageTypeHandlers.get(messageType);
             if (handler != null) {

Ran GitHub Actions for eab5b3a1057c09ce48cffe5758afdd0262ce4867:

--- 
+++ 
@@ -100,6 +100,12 @@
             manifold-json-rt
             ${manifold.version}
         
+        
+        
+            com.alibaba
+            fastjson
+            1.2.78 
+        

     

Ran GitHub Actions for a74738cfcaf00dfdb3713e70ce214f4b6d8a8631:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/convert_from_fasterxmljackson_to_fastjso.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.

dakotahNorth commented 6 months ago

This PR was not merged in. There were too many issues with the conversion.

Instead Tabnine with ChatGPT4.0 Turbo was used in the IDE ... and those changes were merged into master.

https://github.com/dakotahNorth/solace-spring-boot-starter/commit/04b24c9800f7a6f782cd6f2dbd414ad5571467f9