Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
0.5.0, 0.6.0
-
None
-
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr8ifx-20100609_59383 (JIT enabled, AOT enabled)
2.6.35-24-generic #42-Ubuntu SMP (Ubuntu 10.10)
Description
The following exception is thrown when using SFTP client FileZilla and Mina is running on the IBM JVM:
java.util.FormatFlagsConversionMismatchException: Mismatched Convertor =s, Flags= #
at java.util.Formatter$Transformer.transformFromString(Formatter.java:1020)
at java.util.Formatter$Transformer.transform(Formatter.java:861)
at java.util.Formatter.format(Formatter.java:565)
at java.util.Formatter.format(Formatter.java:509)
at java.lang.String.format(String.java:1960)
at org.apache.sshd.server.sftp.SftpSubsystem.getLongName(SftpSubsystem.java:843)
at org.apache.sshd.server.sftp.SftpSubsystem.sendPath(SftpSubsystem.java:806)
at org.apache.sshd.server.sftp.SftpSubsystem.process(SftpSubsystem.java:719)
at org.apache.sshd.server.sftp.SftpSubsystem.run(SftpSubsystem.java:331)
at java.lang.Thread.run(Thread.java:736)
Latest source shows the problem line:
847 long length = f.getSize();
848 String lengthString = String.format("%1$#8s", length);
Simple test code also reproduces the problem:
public static void main(String [] args)
If I understand the Formatter class documentation, I'm surprised the format call works at all on the Sun JVM. It says the # flag is only applicable for Integral types with o, x, and X conversions only. Further down in the documentation for 's' conversion, it says
"If the '#' flag is given and the argument is not a Formattable , then a FormatFlagsConversionMismatchException will be thrown."
Assuming the long above is autoboxed to Long, Long does not implement Formattable.
I believe a different method should be used for converting this long to string. I'm not sure of the original intent, but maybe the the 'd' conversion was intended rather than the 's' conversion to output the long in base 10, but then I don't understand the use of #.