Fix rest-openapi, observation, and twitter-salesforce examples - #210
Open
Croway wants to merge 3 commits into
Open
Fix rest-openapi, observation, and twitter-salesforce examples#210Croway wants to merge 3 commits into
Croway wants to merge 3 commits into
Conversation
…ple log The actuator base URL in the README had a trailing slash which 404s; the working URL has none. The sample startup log was also stale, showing Spring Boot 1.5.10/Camel 2.22.0-SNAPSHOT output from 2017. Replaced it with output from a verified run against the current Spring Boot/Camel versions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wgr7MBBqUbNGG6xrH6ybWq
The reflection in TwitterSalesforceRoute was meant to prefer the Contact DTO generated by camel-salesforce-maven-plugin (only present when built with -Dgenerate.dto against a live org) and otherwise fall back to a bundled DTO, so the module compiles without live Salesforce credentials. But Class.forName(x) != null never returns false - a missing class throws ClassNotFoundException immediately, so the fallback branch was dead code, and the bundled fallback DTO was itself an abstract class that didn't extend AbstractSObjectBase, so it could neither be instantiated nor be recognized by the Salesforce component. Without running the generate.dto profile, every tweet mention failed. - Replace the abstract draftdto.Contact with a concrete example.mention.dto.Contact extending AbstractSObjectBase, with @JsonProperty annotations preserving Salesforce's case-sensitive field API names (LastName, TwitterScreenName__c) - without them Jackson decapitalizes the leading letter of bean-derived property names and would silently send the wrong field names. - Fix the Class.forName check with a proper try/catch(ClassNotFoundException). - Pin build-helper-maven-plugin to 3.0.0, matching other examples in this repo. - Clarify in the README that the bundled Twitter/X and Salesforce credentials are illustrative placeholders (the Twitter ones predate the 2023 API overhaul and are very likely dead) that must be replaced with self-provisioned ones, and document the DTO fallback design. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wgr7MBBqUbNGG6xrH6ybWq
The reflection preferred the DTO generated by camel-salesforce-maven-plugin (only present after building with -Dgenerate.dto against a live org) over the bundled Contact DTO, but the route only ever calls setLastName and setTwitterScreenName__c either way. AbstractSObjectBase already gives both classes the same standard fields, and upsertSObject's create/update path only casts the body to AbstractSObjectBase - it doesn't use the generated DTO's extra fields or its SObjectDescription metadata. So the reflection had no effect on behavior; it only added a failure mode. Reference the bundled Contact DTO directly instead. The generate-salesforce-dto profile and camel-salesforce-maven-plugin wiring stay as documented, optional tooling for extending the route to more fields - just no longer glued to it via reflection. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wgr7MBBqUbNGG6xrH6ybWq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
http://localhost:8080/actuator/(trailing slash) returns a 404; the working URL has no trailing slash. Also refreshed the stale sample startup log, which showed Spring Boot 1.5.10.RELEASE / Camel 2.22.0-SNAPSHOT output from 2017, with output captured from a verified run against the current stack (Spring Boot 4.1.1, Camel 4.23.0-SNAPSHOT, Java 25)micrometer-tracing-bomimport that was overriding the version managed by the parent BOMClass.forNameto prefer a Contact DTO generated bycamel-salesforce-maven-plugin(only present when built with-Dgenerate.dtoagainst a live org) and otherwise fall back to a bundled DTO. ButClass.forName(x) != nullnever returns false — a missing class throwsClassNotFoundExceptionimmediately, so the fallback branch was dead code, and the bundled fallback DTO was itself an abstract class that didn't extendAbstractSObjectBase, so it could neither be instantiated nor be recognized by the Salesforce component. Without running thegenerate.dtoprofile, every tweet mention failed.draftdto.Contactwith a concreteexample.mention.dto.ContactextendingAbstractSObjectBase, with@JsonPropertyannotations preserving Salesforce's case-sensitive field API names (LastName,TwitterScreenName__c) — without them Jackson decapitalizes the leading letter of bean-derived property names and would silently send the wrong field namesupsertSObject's create/update path only casts the body toAbstractSObjectBase— it never uses the generated DTO's extra fields or itsSObjectDescriptionmetadata. So preferring the generated class had no effect on behavior, only an extra failure mode. The route now references the bundledContactDTO directlybuild-helper-maven-pluginto3.0.0, matching other examples in this repogenerate-salesforce-dtoprofile /camel-salesforce-maven-pluginwiring as documented, optional tooling for extending the route to more fields — just no longer glued to it via reflectionTest plan
rest-openapi: built and ran the example; verified/actuatorreturns 200 and/actuator/returns 404; verified/api/users(CRUD),/api/api-doc, and/actuator/prometheusall work as documentedobservation: confirmed the tracing bom version now comes cleanly from the parent BOM with no overridestwitter-salesforce:mvn compilesucceeds offline with no Salesforce credentials; verified via a standalone harness that theContactDTO instantiates, extendsAbstractSObjectBase, and serializes with the correct Salesforce field casing (LastName,TwitterScreenName__c)