gnodet-bot commented on code in PR #26267:
URL: https://github.com/apache/camel/pull/26267#discussion_r3980469855
##########
components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsEndpoint.java:
##########
@@ -82,10 +93,27 @@ public Exchange createExchange(Message message) {
exchange.getIn().setHeader(JGroupsConstants.HEADER_JGROUPS_ORIGINAL_MESSAGE,
message);
exchange.getIn().setHeader(JGroupsConstants.HEADER_JGROUPS_SRC,
message.getSrc());
exchange.getIn().setHeader(JGroupsConstants.HEADER_JGROUPS_DEST,
message.getDest());
- exchange.getIn().setBody(message.getObject());
+ Object body = message.getObject();
+ if (body != null && deserializationFilter != null &&
!deserializationFilter.isBlank()) {
+ checkDeserializedType(body.getClass());
+ }
+ exchange.getIn().setBody(body);
return exchange;
}
+ private void checkDeserializedType(Class<?> type) {
+ if (resolvedDeserializationFilter == null) {
Review Comment:
🔴 **Compilation error:** `resolvedDeserializationFilter` is used here but
never declared as a field on the class. The field declaration is missing.
Add it alongside the other fields (after `deserializationFilter`):
```suggestion
if (resolvedDeserializationFilter == null) {
```
(This line itself is fine — but add the field somewhere in the field
declaration block, e.g. after line 68):
```java
private ObjectInputFilter resolvedDeserializationFilter;
```
Note: since `createExchange(Message)` can be called from JGroups' receiver
thread pool, consider resolving the filter eagerly in `doStart()` to avoid the
need for synchronization on the lazy-init path. This is also the pattern other
Camel components use (resolve at start, store as a field, only call
`checkClass` on the hot path).
##########
components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsEndpoint.java:
##########
@@ -82,10 +93,27 @@ public Exchange createExchange(Message message) {
exchange.getIn().setHeader(JGroupsConstants.HEADER_JGROUPS_ORIGINAL_MESSAGE,
message);
exchange.getIn().setHeader(JGroupsConstants.HEADER_JGROUPS_SRC,
message.getSrc());
exchange.getIn().setHeader(JGroupsConstants.HEADER_JGROUPS_DEST,
message.getDest());
- exchange.getIn().setBody(message.getObject());
+ Object body = message.getObject();
+ if (body != null && deserializationFilter != null &&
!deserializationFilter.isBlank()) {
+ checkDeserializedType(body.getClass());
+ }
+ exchange.getIn().setBody(body);
return exchange;
}
+ private void checkDeserializedType(Class<?> type) {
+ if (resolvedDeserializationFilter == null) {
+ resolvedDeserializationFilter =
DeserializationFilterHelper.resolveDeserializationFilter(deserializationFilter);
+ }
+ if
(DeserializationFilterHelper.checkClass(resolvedDeserializationFilter, type) ==
ObjectInputFilter.Status.REJECTED) {
+ throw new JGroupsException(
+ "Rejected message body of type " + type.getName()
+ + " received from the JGroups cluster:
it is not permitted by the configured"
+ + " deserializationFilter");
+ }
+ }
+ }
Review Comment:
🔴 **Compilation error:** Stray closing brace. Line 114 closes
`checkDeserializedType()` correctly, but line 115 is an extra `}` that closes
the class body prematurely — everything after this point
(`createExchange(View)`, `doStart()`, `doStop()`, getters/setters) falls
outside the class.
Remove this line:
```suggestion
}
```
--
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]