5 Replies Latest reply on Aug 17, 2015 10:38 AM by Jérôme Blanchard

    File with § character problem in wildfly

    Jérôme Blanchard Newbie

      When I try to open a file in some wildfly code using :

      File f = new File("/test/folder/§subfolder/file1.txt")

      the method f.exists() return false even if the file really exists when containing a character § in the file path

      The same code called from command line on the same machine via a simple java class with a main method gives correct result.

      I can't figure out what's make this code to fail in wildfly...

      - There is no SecurityManager enabled

      - Filesystem permissions are good

      - Filesystem is xfs

       

      Parent folders of the folder with the § are recognized as existing but starting from the folder with the §, the methof file.exists() return false for all the subtree...

       

      any help would be appreciated, best regards, Jérôme.

        • 1. Re: File with § character problem in wildfly
          Tomaz Cerar Master

          What exactly does fail in wildfly?

          • 2. Re: File with § character problem in wildfly
            Jérôme Blanchard Newbie

            What fails is that the file.exists() method return false instead of true.

            If I run the same code at command line (using the same jvm, probably not the same options) the methods return true but as soon as I'm in wildfly, the method return false.

            In another OS and with the same JVM, I have not the same problem.

            This cause my application to crash because of a file not exists exception...

             

            I have perform more investigation :

            1. {
            2.     "security-manager-exists": "false",
            3.     "file class name": "java.io.File",
            4.     "query-path": "/applis/ortolang-bags/sldr000850/data/head/objects/§doc",
            5.     "file.getAbsolutePath()": "/applis/ortolang-bags/sldr000850/data/head/objects/§doc",
            6.     "file.exists()": "false",
            7.     "file.getFreeSpace()": "0",
            8.     "path.isAbsolute()": "true",
            9.     "path.getFileSystem()": "sun.nio.fs.LinuxFileSystem@6d892bb2",
            10.     "path.toFile().exists": "false",
            11.     "Files.exists(path)": "true",
            12.     "Files.notExists(path)": "false",
            13.     "Files.getFileStore(path).name()": "/dev/mapper/data1-applis1",
            14.     "Files.isDirectory(path)": "true",
            15.     "Files.isRegularFile(path)": "false"
            16. }

             

            As you can see, files.exists() gives false whereas Files.exists(path) (using Path.get("/applis/ortolang-bags/sldr000850/data/head/objects/§doc")) gives true.

            It seems that in wlidfly on SLES11 (I don't know why, maybe an underlying file management package library different) the Java.IO API does not works with § in filenames...


            • 3. Re: File with § character problem in wildfly
              Greg Jewell Novice

              This is just a stab in the dark, but could this be an issue with AIO?  With your OS and filesystem, AIO is enabled in WildFly.  It is not used from a JSE application.  You don't specify the "other" OS where the problem doesn't exist, but I'm guessing it's not Linux, so NIO is used instead.

               

              I thought AIO was only used by HornetQ, but it may be used across all of WildFly.  Uninstall libaio and try again to see whether the problem persists.

              • 4. Re: File with § character problem in wildfly
                Tomaz Cerar Master

                Well I still don't see where exactly WildFly comes involved in your problem.

                 

                You are using Java NIO and IO api which WildFly doesn't modify or intercept in any way.

                 

                That said, it is possible that there is a bug in JDK itself, it wouldn't be the first time on this subject.

                Did you try using latest version of JDK as it could fix the problem. Also can you reproduce this on any other platform/ linux distro?

                • 5. Re: File with § character problem in wildfly
                  Jérôme Blanchard Newbie

                  Hi all,

                  I've found the problem. Wildfly is not the problem but the environment which lunch wildfly.

                  LANG in wildfly in en_US.UTF-8 whereas when I lunch the program in a shell, I don't know why, but even in root using sudo specifying not keeping the user env, I still in fr_FR.UTF-8.

                  Java.IO is using the default charset and because § char is not compliant in the two charset, there is a mistake. Java.NIO does handle this correctly.

                  I'm  very sorry for this, but my problem is a linux env problem in fact.

                  Thanks a lot for trying to help me, best regards, Jérôme.