Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11298

Using chmodDirectory with full paths makes file producer to created directories relative to source



    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.18.2, 2.19.0
    • Fix Version/s: 2.18.5, 2.19.1, 2.20.0
    • Component/s: camel-core
    • Labels:
    • Environment:

      Arch Linux

    • Estimated Complexity:


      Tried using the chmodDirectory property on a file producer that writes to full system paths and noticed that with the chmodDirectory property the directories get created relative to the source/project.

      Without using the property the files get properly created using the full path that is given to them.

      I ran a debugger and found the source of the problem:

      Code is from org.apache.camel.component.file.FileOperations
      in buildDirectory method
      at lines 97 - 118

      if (permissions == null || permissions.isEmpty()) {
                  return dir.mkdirs();
              // create directory one part of a time and set permissions
              try {
                  String[] parts = dir.getPath().split("\\" + File.separatorChar);
                  File base = new File(".");
                  for (String part : parts) {
                      File subDir = new File(base, part);
                      if (!subDir.exists()) {
                          if (subDir.mkdir()) {
                              if (LOG.isTraceEnabled()) {
                                  LOG.trace("Setting chmod: {} on directory: {} ", PosixFilePermissions.toString(permissions), subDir);
                              Files.setPosixFilePermissions(subDir.toPath(), permissions);
                          } else {
                              return false;
                      base = new File(base, subDir.getName());

      Base File used to create all the folders and set their permissions is initialized with new File("."), effectively this always creates the directories given to it, relative to the source, and will not handle full system paths.

      Is there a reason I'm unaware of that this is implemented this way?

      I tested running folder creation code with new File("") as a base and it worked fine, would that be enough to handle the issue if it indeed is an issue?

      I can do this my self by issuing a pull request, let me know.



          Issue Links



              • Assignee:
                davsclaus Claus Ibsen
                Stabbz Damyan Damyanov
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: