This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new b33c70d56fdc CAMEL-28015: camel-salesforce: pkChunking options have no
effect, and approval header values stay on the endpoint (#31238)
b33c70d56fdc is described below
commit b33c70d56fdcbfff4d0e017f2be840cc352a0e11
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Dec 2 11:53:17 2026 +0100
CAMEL-28015: camel-salesforce: pkChunking options have no effect, and
approval header values stay on the endpoint (#31238)
Two bugs in camel-salesforce:
- The pkChunking, pkChunkingChunkSize, pkChunkingParent and
pkChunkingStartRow options
were missing from SalesforceEndpointConfig.toValueMap(), so setting them
on the
endpoint had no effect.
- processApproval() mutated the shared ApprovalRequest of the endpoint with
the
approval.* header values, so they leaked into later exchanges. The
request is now
copied first (ApprovalRequest.copy(), which also keeps
skipEntryCriteria=true).
Upgrade guide entry for the pkChunking options that now take effect.
Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet.
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
.../salesforce/SalesforceEndpointConfig.java | 4 ++
.../api/dto/approval/ApprovalRequest.java | 18 ++++++
.../internal/processor/AbstractRestProcessor.java | 10 ++-
.../SalesforceEndpointConfigToValueMapTest.java | 63 +++++++++++++++++++
.../AbstractRestProcessorApprovalTest.java | 71 ++++++++++++++++++++++
.../internal/processor/BulkApiProcessorTest.java | 19 +++++-
.../ROOT/pages/camel-4x-upgrade-guide-4_25.adoc | 10 +++
7 files changed, 193 insertions(+), 2 deletions(-)
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java
index 06e8dedd82ca..ec988776d9a1 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java
+++
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java
@@ -882,6 +882,10 @@ public class SalesforceEndpointConfig implements Cloneable
{
valueMap.put(JOB_ID, jobId);
valueMap.put(BATCH_ID, batchId);
valueMap.put(RESULT_ID, resultId);
+ valueMap.put(PK_CHUNKING, pkChunking);
+ valueMap.put(PK_CHUNKING_CHUNK_SIZE, pkChunkingChunkSize);
+ valueMap.put(PK_CHUNKING_PARENT, pkChunkingParent);
+ valueMap.put(PK_CHUNKING_START_ROW, pkChunkingStartRow);
if (locator != null) {
valueMap.put(LOCATOR, locator);
}
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequest.java
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequest.java
index 4e12a61cbc16..f83686b17982 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequest.java
+++
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequest.java
@@ -80,6 +80,24 @@ public final class ApprovalRequest implements Serializable {
nextApproverIds.add(nextApproverId);
}
+ /**
+ * Creates a full copy of this {@link ApprovalRequest}. Unlike {@link
#applyTemplate}, this method copies all fields
+ * including the primitive {@code skipEntryCriteria} field, so a {@code
true} value is preserved.
+ *
+ * @return a new {@link ApprovalRequest} with all fields copied from this
instance
+ */
+ public ApprovalRequest copy() {
+ final ApprovalRequest copy = new ApprovalRequest();
+ copy.actionType = actionType;
+ copy.contextActorId = contextActorId;
+ copy.contextId = contextId;
+ copy.comments = comments;
+ copy.nextApproverIds = nextApproverIds != null ? new
ArrayList<>(nextApproverIds) : null;
+ copy.processDefinitionNameOrId = processDefinitionNameOrId;
+ copy.skipEntryCriteria = skipEntryCriteria;
+ return copy;
+ }
+
/**
* Creates new {@link ApprovalRequest} by combining values from the given
template with the values currently
* present. If the value is not present and the template has the
corresponding value, then the template value is
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java
index 6e70f8910379..d058410bb62d 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java
+++
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java
@@ -249,7 +249,15 @@ public abstract class AbstractRestProcessor extends
AbstractSalesforceProcessor
// find if there is a ApprovalRequest as `approval` in the message
// header
- final ApprovalRequest approvalHeader =
Optional.ofNullable(approvalRequestFromHeader).orElse(new ApprovalRequest());
+ // Work on a copy so that processApprovalHeaderValues() mutations via
setPropertyValue()
+ // do not bleed back into the shared endpoint config's ApprovalRequest
instance.
+ // Use copy() rather than new ApprovalRequest().applyTemplate(r):
applyTemplate() checks
+ // currentValue == null to decide whether to inherit the template
value, but skipEntryCriteria
+ // is a primitive boolean whose default is false (not null), so a
template value of true would
+ // never be copied. copy() copies all fields directly, including
primitives.
+ final ApprovalRequest approvalHeader
+ =
Optional.ofNullable(approvalRequestFromHeader).map(ApprovalRequest::copy)
+ .orElse(new ApprovalRequest());
final Message incomingMessage = exchange.getIn();
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/SalesforceEndpointConfigToValueMapTest.java
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/SalesforceEndpointConfigToValueMapTest.java
new file mode 100644
index 000000000000..9bc998b70d19
--- /dev/null
+++
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/SalesforceEndpointConfigToValueMapTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.salesforce;
+
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class SalesforceEndpointConfigToValueMapTest {
+
+ @Test
+ void pkChunkingOptionsAreIncludedInValueMap() {
+ SalesforceEndpointConfig config = new SalesforceEndpointConfig();
+ config.setPkChunking(true);
+ config.setPkChunkingChunkSize(50000);
+ config.setPkChunkingParent("Account");
+ config.setPkChunkingStartRow("001000000000001");
+
+ Map<String, Object> valueMap = config.toValueMap();
+
+ assertEquals(Boolean.TRUE,
valueMap.get(SalesforceEndpointConfig.PK_CHUNKING),
+ "PK_CHUNKING must be present in toValueMap()");
+ assertEquals(50000,
valueMap.get(SalesforceEndpointConfig.PK_CHUNKING_CHUNK_SIZE),
+ "PK_CHUNKING_CHUNK_SIZE must be present in toValueMap()");
+ assertEquals("Account",
valueMap.get(SalesforceEndpointConfig.PK_CHUNKING_PARENT),
+ "PK_CHUNKING_PARENT must be present in toValueMap()");
+ assertEquals("001000000000001",
valueMap.get(SalesforceEndpointConfig.PK_CHUNKING_START_ROW),
+ "PK_CHUNKING_START_ROW must be present in toValueMap()");
+ }
+
+ @Test
+ void pkChunkingOptionsAreNullWhenNotSet() {
+ SalesforceEndpointConfig config = new SalesforceEndpointConfig();
+
+ Map<String, Object> valueMap = config.toValueMap();
+
+ assertNull(valueMap.get(SalesforceEndpointConfig.PK_CHUNKING),
+ "PK_CHUNKING should be null when not configured");
+
assertNull(valueMap.get(SalesforceEndpointConfig.PK_CHUNKING_CHUNK_SIZE),
+ "PK_CHUNKING_CHUNK_SIZE should be null when not configured");
+ assertNull(valueMap.get(SalesforceEndpointConfig.PK_CHUNKING_PARENT),
+ "PK_CHUNKING_PARENT should be null when not configured");
+
assertNull(valueMap.get(SalesforceEndpointConfig.PK_CHUNKING_START_ROW),
+ "PK_CHUNKING_START_ROW should be null when not configured");
+ }
+}
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessorApprovalTest.java
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessorApprovalTest.java
index ba62ef0e8e87..10ae42335f52 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessorApprovalTest.java
+++
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessorApprovalTest.java
@@ -45,6 +45,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
public class AbstractRestProcessorApprovalTest {
@@ -251,6 +252,76 @@ public class AbstractRestProcessorApprovalTest {
verify(processor3).getRequestStream(any(Message.class), eq(new
ApprovalRequests(requestWithComment("first priority"))));
}
+ @Test
+ public void endpointTemplateShouldPreserveSkipEntryCriteriaTrue() throws
SalesforceException {
+ // Regression guard for CAMEL-28015 bug 2: the original fix used
+ // new ApprovalRequest().applyTemplate(r) for the copy, but
applyTemplate() cannot copy
+ // the primitive boolean field skipEntryCriteria when it is true: the
fresh object has
+ // skipEntryCriteria=false, which is not null, so the template value
of true is never applied.
+ // The fix replaces applyTemplate() with copy() which copies all
fields directly.
+ final SalesforceEndpointConfig config =
TestRestProcessor.configuration();
+ final ApprovalRequest endpointTemplate = new ApprovalRequest();
+ endpointTemplate.setSkipEntryCriteria(true);
+ config.setApproval(endpointTemplate);
+
+ final SalesforceEndpoint endpoint = new SalesforceEndpoint(
+ notUsed(), TestRestProcessor.component(), config,
+ notUsed(), notUsed());
+ final TestRestProcessor processor = spy(new
TestRestProcessor(endpoint, mock(RestClient.class)));
+
+ final CamelContext context = new DefaultCamelContext();
+ final Exchange exchange = new DefaultExchange(context);
+ exchange.setIn(new DefaultMessage(context));
+
+ processor.processApproval(exchange, notUsed());
+
+ final ApprovalRequest expected = new ApprovalRequest();
+ expected.setSkipEntryCriteria(true);
+
+ verify(processor).getRequestStream(any(Message.class), eq(new
ApprovalRequests(expected)));
+ }
+
+ @Test
+ public void
approvalTemplateFromEndpointConfigShouldNotBleedAcrossExchanges() throws
SalesforceException {
+ // Reproduce CAMEL-28015 bug 2: processApprovalHeaderValues() used to
mutate the ApprovalRequest
+ // object returned from the shared endpoint config map, so the first
exchange's approval.* headers
+ // would bleed into subsequent exchanges processed by the same
endpoint.
+
+ // Build an endpoint whose config has an approval template with a
fixed action type.
+ final SalesforceEndpointConfig config =
TestRestProcessor.configuration();
+ final ApprovalRequest endpointTemplate = new ApprovalRequest();
+ endpointTemplate.setActionType(Action.Submit);
+ config.setApproval(endpointTemplate);
+
+ final SalesforceEndpoint endpoint = new SalesforceEndpoint(
+ notUsed(), TestRestProcessor.component(), config,
+ notUsed(), notUsed());
+ final TestRestProcessor processor = spy(new
TestRestProcessor(endpoint, mock(RestClient.class)));
+
+ // Exchange 1: adds a comment via approval.Comments header.
+ final CamelContext context = new DefaultCamelContext();
+ final Exchange exchange1 = new DefaultExchange(context);
+ final Message msg1 = new DefaultMessage(context);
+ msg1.setHeaders(Collections.singletonMap("approval.Comments",
"exchange-one-comment"));
+ exchange1.setIn(msg1);
+
+ processor.processApproval(exchange1, notUsed());
+
+ // Exchange 2: no approval.* headers — must NOT inherit exchange 1's
comment.
+ final Exchange exchange2 = new DefaultExchange(context);
+ final Message msg2 = new DefaultMessage(context);
+ exchange2.setIn(msg2);
+
+ processor.processApproval(exchange2, notUsed());
+
+ // Exchange 2 must only have the endpoint template's actionType, not
exchange 1's comment.
+ final ApprovalRequest expectedForExchange2 = new ApprovalRequest();
+ expectedForExchange2.setActionType(Action.Submit);
+
+ verify(processor, times(1))
+ .getRequestStream(any(Message.class), eq(new
ApprovalRequests(expectedForExchange2)));
+ }
+
TestRestProcessor sendBody(final Object body) throws SalesforceException {
return sendBodyAndHeader(body, null);
}
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessorTest.java
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessorTest.java
index 925812658151..58f35753e966 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessorTest.java
+++
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessorTest.java
@@ -69,9 +69,26 @@ public class BulkApiProcessorTest {
assertThat(headers).doesNotContainKey(PK_CHUNKING_HEADER);
}
+ @Test
+ public void pkChunkingFromEndpointConfig() throws Exception {
+ SalesforceEndpointConfig config = new SalesforceEndpointConfig();
+ config.setPkChunking(true);
+ config.setPkChunkingChunkSize(1000);
+
+ Map<String, List<String>> headers = determineHeaders(Map.of(), config);
+
+ assertThat(headers).containsEntry(PK_CHUNKING_HEADER,
List.of("chunkSize=1000"));
+ }
+
private static Map<String, List<String>> determineHeaders(Map<String,
Object> messageHeaders) throws Exception {
+ return determineHeaders(messageHeaders, new
SalesforceEndpointConfig());
+ }
+
+ private static Map<String, List<String>> determineHeaders(
+ Map<String, Object> messageHeaders, SalesforceEndpointConfig
config)
+ throws Exception {
SalesforceEndpoint endpoint = new SalesforceEndpoint(
- "", new SalesforceComponent(), new SalesforceEndpointConfig(),
OperationName.CREATE_JOB, "");
+ "", new SalesforceComponent(), config,
OperationName.CREATE_JOB, "");
try (DefaultCamelContext context = new DefaultCamelContext();
BulkApiProcessor processor = new BulkApiProcessor(endpoint)) {
Exchange exchange = new DefaultExchange(context);
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
index d560799c36ec..2ddc39a88fc6 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
@@ -324,6 +324,16 @@ As a result, applications that use `camel-infinispan` no
longer get `infinispan-
Hibernate Search or Lucene on their classpath through it. If your application
also starts an embedded cache manager or
uses the embedded query engine, use `camel-infinispan-embedded`, or add these
dependencies yourself.
+=== camel-salesforce - pkChunking options now take effect
+
+The endpoint options `pkChunking`, `pkChunkingChunkSize`, `pkChunkingParent`,
and `pkChunkingStartRow` previously had
+no effect because they were not included in the value map read by the Bulk API
processor. They are now forwarded as
+the `Sforce-Enable-PKChunking` request header when `pkChunking=true` is set.
+
+If you rely on `pkChunking*` options being silently ignored — for example if
you set them in an endpoint URI but
+intended jobs to run without chunking — remove those options or set
`pkChunking=false` to restore the previous
+behaviour.
+
=== camel-spring-redis - SpringRedisIdempotentRepository.clear() deletes only
the set of the repository
`SpringRedisIdempotentRepository.clear()` (also the `clear` JMX operation) now
deletes only the Redis set named by