apache / camel-kamelets

Apache Camel Kamelets Repository
https://camel.apache.org
Apache License 2.0
54 stars 72 forks source link

Fix AWS DDB Streams Source Kamelet #2008

Closed christophd closed 2 months ago

christophd commented 2 months ago

AWS DDB Streams source Kamelet raises error during marshal operation. This is due to Gson library not able to handle Java time instant type OOTB. PR introduces a data type transformer in camel-kamelets-utils library to handle Gson marshalling in aws2-ddb-streams-source Kamelet.

Errors raised looked like this:

Source                                   ID                             Processor                                          Elapsed (ms)
aws-ddb-streams-source.kamelet.yaml:129  source/source                  from[aws2-ddbstream://DynamoDBSourceKameletITCase1    254789243
 ...
aws-ddb-streams-source.kamelet.yaml:140  source/marshal1                marshal[org.apache.camel.model.dataformat.JsonData            0

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------: 
com.google.gson.JsonIOException: Failed making field 'java.time.Instant#seconds' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.time.Instant.seconds accessible: module java.base does not "opens java.time" to unnamed module @8e0379d
 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
 at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
 at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
 at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:35)