gnodet commented on code in PR #25726:
URL: https://github.com/apache/camel/pull/25726#discussion_r3857122924
##########
components/camel-file/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentChangedRepositoryReadLockStrategy.java:
##########
@@ -115,8 +115,10 @@ public boolean
acquireExclusiveReadLock(GenericFileOperations<File> operations,
public void releaseExclusiveReadLockOnAbort(
Review Comment:
Same concern as the `FileIdempotentRepositoryReadLockStrategy` —
`releaseExclusiveReadLockOnAbort` can be reached after a successful acquire
when `preMove` fails. The exchange-property approach would fix both scenarios.
##########
components/camel-file/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentRepositoryReadLockStrategy.java:
##########
@@ -95,8 +95,9 @@ public boolean
acquireExclusiveReadLock(GenericFileOperations<File> operations,
public void releaseExclusiveReadLockOnAbort(
GenericFileOperations<File> operations, GenericFile<File> file,
Exchange exchange)
throws Exception {
Review Comment:
The comment says "this is only called after acquireExclusiveReadLock
failed," but `releaseExclusiveReadLockOnAbort` can also be called after a
**successful** acquire when `begin()` throws for reasons beyond lock failure.
Specifically: `GenericFileRenameProcessStrategy.begin()` calls
`super.begin()` (which acquires the lock successfully), then attempts `preMove`
rename. If `renameFile()` throws `GenericFileOperationFailedException`, the
exception propagates to `GenericFileConsumer.processExchange()`, `begin` stays
`false`, and `abort()` is called — which invokes this method. With this change
making it a no-op, the key added during the successful
`acquireExclusiveReadLock` leaks permanently.
This effectively reverts CAMEL-24093 point #2 (commit `82507e3eab0`) for
this specific scenario.
**Suggestion:** Track acquisition state via an exchange property (like
`MarkerFileExclusiveReadLockStrategy` already does with
`FILE_LOCK_FILE_ACQUIRED`). Then `releaseExclusiveReadLockOnAbort` can check
the property to distinguish "acquire never succeeded" from "acquire succeeded
but something else failed" — correctly handling both this PR's pre-existing-key
scenario and CAMEL-24093's abort-after-acquire scenario.
##########
components/camel-file/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentRenameRepositoryReadLockStrategy.java:
##########
@@ -107,8 +107,10 @@ public boolean
acquireExclusiveReadLock(GenericFileOperations<File> operations,
public void releaseExclusiveReadLockOnAbort(
Review Comment:
Same concern — consider the exchange-property tracking approach here as well.
##########
core/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileIdempotentChangedReadLockRemoveOnCommitTest.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.file.strategy;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spi.Registry;
+import
org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+public class FileIdempotentChangedReadLockRemoveOnCommitTest extends
ContextTestSupport {
Review Comment:
Minor: per project conventions, test class and test methods should be
package-private (no `public` modifier).
```suggestion
class FileIdempotentChangedReadLockRemoveOnCommitTest extends
ContextTestSupport {
```
--
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]