gnodet-bot commented on code in PR #28336:
URL: https://github.com/apache/camel/pull/28336#discussion_r4357895222
##########
components/camel-keycloak/src/main/docs/keycloak-consumer.adoc:
##########
@@ -466,23 +471,26 @@ from("keycloak:adminEvents"
+ "&delay=10000")
.process(exchange -> {
AdminEventRepresentation event =
exchange.getIn().getBody(AdminEventRepresentation.class);
+ AuthDetailsRepresentation authDetails = event.getAuthDetails();
- // Build audit record
+ // Build audit record (every named parameter of the SQL insert needs a
value, null included)
Map<String, Object> auditRecord = new HashMap<>();
- auditRecord.put("timestamp", new Date(event.getTime()));
+ auditRecord.put("timestamp", event.getTime());
Review Comment:
⚠️ **Timestamp type regression**: `event.getTime()` returns `long` (epoch
ms). When passed as `Long` to `PreparedStatement.setObject()`, JDBC maps it to
`BIGINT` (per spec Table B-4) — not `TIMESTAMP`. This will fail at runtime on
most databases when targeting a `TIMESTAMP` column. The previous `new
Date(event.getTime())` was correct and should be restored:
```suggestion
auditRecord.put("timestamp", new Date(event.getTime()));
```
##########
components/camel-keycloak/src/main/docs/keycloak-consumer.adoc:
##########
@@ -500,22 +508,36 @@ YAML::
maxResults=100&
delay=10000
steps:
+ # build the audit record (every named parameter of the SQL insert
needs a value, null included)
- setBody:
- simple: >
- {
- "timestamp": ${body.time},
- "operation": "${body.operationType}",
- "resourceType": "${body.resourceType}",
- "resourcePath": "${body.resourcePath}",
- "userId": "${body.authDetails.userId}",
- "ipAddress": "${body.authDetails.ipAddress}"
- }
+ expression:
+ simple:
+ expression: >-
+ ${map(timestamp,${body.time},
Review Comment:
⚠️ **Same issue in the YAML DSL**: `${body.time}` resolves to
`AdminEventRepresentation.getTime()` which returns `long`. Stored as `Long`,
JDBC maps it to `BIGINT` rather than `TIMESTAMP`. Wrap it the same way the Java
DSL should:
```suggestion
${map(timestamp,${date:${body.time}:yyyy-MM-dd HH:mm:ss},
```
Or alternatively use a `simple` expression that produces a `java.util.Date`
for correct JDBC binding.
--
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]