This is an automated email from the ASF dual-hosted git repository.

jamesnetherton 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 c1b297d0669b CAMEL-22784: Fix potential NPE in 
FileLockClusterView.tryLock
c1b297d0669b is described below

commit c1b297d0669b8b88c951f38ee2d955aef5e42510
Author: James Netherton <[email protected]>
AuthorDate: Tue Dec 23 14:21:57 2025 +0000

    CAMEL-22784: Fix potential NPE in FileLockClusterView.tryLock
---
 .../apache/camel/component/file/cluster/FileLockClusterView.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-file/src/main/java/org/apache/camel/component/file/cluster/FileLockClusterView.java
 
b/components/camel-file/src/main/java/org/apache/camel/component/file/cluster/FileLockClusterView.java
index 80896e1f1c32..c7b5971728a3 100644
--- 
a/components/camel-file/src/main/java/org/apache/camel/component/file/cluster/FileLockClusterView.java
+++ 
b/components/camel-file/src/main/java/org/apache/camel/component/file/cluster/FileLockClusterView.java
@@ -263,11 +263,13 @@ public class FileLockClusterView extends 
AbstractCamelClusterView {
 
                     // Attempt to obtain cluster leadership
                     LOGGER.debug("Try to acquire a lock on {} 
(cluster-member-id={})", leaderLockPath, localMember.getUuid());
-                    leaderLockFile = createRandomAccessFile(leaderLockPath);
-                    leaderDataFile = createRandomAccessFile(leaderDataPath);
 
                     lock = null;
-                    lock = leaderLockFile.getChannel().tryLock(0, Math.max(1, 
leaderLockFile.getChannel().size()), false);
+                    leaderLockFile = createRandomAccessFile(leaderLockPath);
+                    leaderDataFile = createRandomAccessFile(leaderDataPath);
+                    if (leaderLockFile != null && leaderDataFile != null) {
+                        lock = leaderLockFile.getChannel().tryLock(0, 
Math.max(1, leaderLockFile.getChannel().size()), false);
+                    }
 
                     if (lockIsValid()) {
                         LOGGER.info("Lock on file {} acquired (lock={}, 
cluster-member-id={})", leaderLockPath, lock,

Reply via email to