jbonofre opened a new issue, #749:
URL: https://github.com/apache/camel-karaf/issues/749

   The `camel-google-*` features wrap `com.google.api/gax` but never install a
   `com.google.code.gson/gson` bundle. `gax` needs Gson at runtime for its
   structured logging, so the first call that reaches
   `com.google.api.gax.logging.LogData` dies in class initialisation.
   
   Observed in the CI run for PR #742, on both Java 17 and Java 21:
   
   ```
   Caused by: java.lang.ExceptionInInitializerError: Exception 
java.lang.NoClassDefFoundError: com/google/gson/Gson
        at com.google.api.gax.logging.LogData.<clinit>(LogData.java:43)
        at 
com.google.api.gax.grpc.GrpcLoggingInterceptor$1.<init>(GrpcLoggingInterceptor.java:69)
        at 
com.google.api.gax.grpc.GrpcLoggingInterceptor.interceptCall(GrpcLoggingInterceptor.java:68)
        ...
        at 
com.google.cloud.pubsub.v1.SubscriptionAdminClient.getSubscription(SubscriptionAdminClient.java:1247)
        at 
org.apache.camel.component.google.pubsub.GooglePubsubConsumer.resolveMaxDeliveryAttempts(GooglePubsubConsumer.java:178)
        at 
org.apache.camel.component.google.pubsub.GooglePubsubConsumer.doStart(GooglePubsubConsumer.java:98)
   Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson not found 
by wrap_com.google.api.gax [166]
   ```
   
   `ClassNotFoundException ... not found by wrap_com.google.api.gax` is the
   diagnostic bit: no bundle in the feature provides `com.google.gson`, and the
   `wrap:` import for it is optional, so the bundle resolves cleanly and then
   fails on first use.
   
   The visible symptom is the consumer failing to start, so the route never
   delivers and `CamelGooglePubsubITest.testResultMock` reports
   `Expected: <1> but was: <0>`.
   
   ### Affected features
   
   All six features that wrap `gax` are missing the gson bundle. `LogData` lives
   in the `gax` artifact itself, so it is present in all six; what differs is 
how
   easily it is reached:
   
   | feature | gax | gax-grpc | gax-httpjson | gson bundle |
   | --- | --- | --- | --- | --- |
   | `camel-google-pubsub` | yes | yes | - | **missing** |
   | `camel-google-storage` | yes | - | yes | **missing** |
   | `camel-google-functions` | yes | - | - | **missing** |
   | `camel-google-pubsub-lite` | yes | - | - | **missing** |
   | `camel-google-secret-manager` | yes | - | - | **missing** |
   | `camel-google-vertexai` | yes | - | - | **missing** |
   
   Only `camel-google-pubsub` is observed failing, because it is the only one
   whose integration test makes a live gRPC call. `camel-google-storage` is the
   next most likely via the `gax-httpjson` logging interceptor. The remaining
   four are latent.
   
   ### Not caused by the Camel 4.18.4 upgrade
   
   Worth stating plainly, because the failure surfaced on PR #742: this gap is
   **not** introduced by that upgrade.
   
   - `LogData` first appears in gax **2.68.0** (absent in 2.61.0 and earlier).
   - Camel 4.18.1, 4.18.2 and 4.18.4 all pin `google-cloud-pubsub` 1.145.0, 
which
     pulls gax **2.73.1**. Verified by `dependency:tree` for 4.18.1 and from the
     PR #742 CI log for 4.18.4.
   - The `camel-google-pubsub` feature block is byte-identical on `main` and on
     PR #742.
   
   So `main` carries exactly the same missing bundle against exactly the same 
gax
   version. `main` is currently green on this test, so the trigger is
   environmental rather than deterministic — gax only installs its logging
   interceptor when it detects an SLF4J binding, and in OSGi what the `gax` 
bundle
   can see depends on wiring and resolution order. The missing bundle is a real
   defect either way, and the fix is the same.
   
   ### Fix
   
   Add the gson bundle to the affected features, matching the form already used
   by three other features in `camel-features.xml`:
   
   ```xml
   <bundle 
dependency='true'>mvn:com.google.code.gson/gson/${gson-version}</bundle>
   ```
   
   `gson-version` (2.13.2) is already defined in the root `pom.xml`, so no new
   property is needed.
   
   I checked the history and found no sign gson was ever deliberately excluded
   from these features.
   


-- 
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]

Reply via email to