FormatFlagsConversionMismatchException when using IBM JVM. Format String is
invalid.
------------------------------------------------------------------------------------
Key: SSHD-104
URL: https://issues.apache.org/jira/browse/SSHD-104
Project: MINA SSHD
Issue Type: Bug
Affects Versions: 0.5.0, 0.6.0
Environment: 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)
Reporter: Kevin Bulebush
Priority: Critical
Fix For: 0.6.0
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) {
long length = 12312342;
String lengthString = String.format("%1$#8s", length);
System.out.println(lengthString);
}
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 #.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.