mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Bulebush (JIRA)" <j...@apache.org>
Subject [jira] Updated: (SSHD-104) FormatFlagsConversionMismatchException when using IBM JVM. Format String is invalid.
Date Wed, 23 Feb 2011 17:48:38 GMT

     [ https://issues.apache.org/jira/browse/SSHD-104?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kevin Bulebush updated SSHD-104:
--------------------------------


I believe the right fix is to remove the # flag from the format string.  My patch, built against
tag sshd-0.5.0 is:

### Eclipse Workspace Patch 1.0
#P sshd-core
Index: src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java
===================================================================
--- src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java	(revision 1073841)
+++ src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java	(working copy)
@@ -840,7 +840,7 @@
         }
 
         long length = f.getSize();
-        String lengthString = String.format("%1$#8s", length);
+        String lengthString = String.format("%1$8s", length);
 
         StringBuilder sb = new StringBuilder();
         sb.append((f.isDirectory() ? "d" : "-"));

> 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
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message