[ 
https://jira.codehaus.org/browse/JIBX-441?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stevo Slavic resolved JIBX-441.
-------------------------------

       Resolution: Fixed
    Fix Version/s: JiBX 1.2

Issue wasn't in usage of String.replace, it was in logic for resolving binding 
name specified from binding file path, when binding name is not explicitly 
specified in binding file. Issue would manifest on Windows if binding file path 
passed to JiBX compiler contains mixed Windows and Linux style separators.

Here is relevant code from 1.1.5 which has the issue:
{code:title=org.jibx.binding.Utility}
...
    public static BindingDefinition loadFileBinding(String path, boolean valid)
        throws JiBXException, IOException {
        
        // extract basic name of binding file from path
        String fname = fileName(path);
        String sname = fname;
        int split = sname.indexOf('.');
        if (split > 0) {
            sname = sname.substring(0, split);
        }
        sname = convertName(sname);
        
        // construct and return the binding definition
        File file = new File(path);
        return loadBinding(fname, sname, new FileInputStream(file),
            file.toURL(), valid);
    }

    public static String fileName(String path) {
        int split = path.lastIndexOf(File.separatorChar);
        return path.substring(split+1);
    }
...
{code}

And here is relevant code from 1.2.3 where this issue is resolved:
{code:title=org.jibx.binding.Utility}
...
    public static BindingDefinition loadFileBinding(String path, boolean valid)
        throws JiBXException, IOException {
        
        // extract basic name of binding file from path
        File file = new File(path);
        String fname = fileName(file.getAbsolutePath());
        String sname = bindingFromFileName(fname);
        
        // construct and return the binding definition
        return loadBinding(fname, sname, new FileInputStream(file),
            file.toURI().toURL(), valid);
    }
        
    public static String bindingFromFileName(String fname) {
        String sname = fname;
        int split = sname.indexOf('.');
        if (split > 0) {
            sname = sname.substring(0, split);
        }
        return BindingDirectory.convertName(sname);
    }
        
    public static String fileName(String path) {
        if (File.separatorChar != '/') {
            path = path.replace('/', File.separatorChar);
        }
        int split = path.lastIndexOf(File.separatorChar);
        return path.substring(split+1);
    }
...
{code}

I've tested and this issue has been resolved with JiBX 1.2 release. Affected 
version 1.2.3 should be removed from issue details.

Options for users are either to upgrade to JiBX 1.2+ or specify binding name 
explicitly in binding file.
                
> Determining default binding from file name is broken on Windows
> ---------------------------------------------------------------
>
>                 Key: JIBX-441
>                 URL: https://jira.codehaus.org/browse/JIBX-441
>             Project: JiBX
>          Issue Type: Bug
>    Affects Versions: JiBX 1.1.5, JiBX 1.2.3
>            Reporter: Stevo Slavic
>            Priority: Minor
>             Fix For: JiBX 1.2
>
>         Attachments: jibx-reactor-default_binding_Windows.patch
>
>
> If a path to binding file contains multiple directories, and if separator in 
> path "/" is used, method {{fileName(String path)}} from 
> {{org.jibx.binding.Utility}} class which should extract base file name from a 
> full path will replace only first "/" character in path with operating system 
> file separator, instead of all "/" characters, leaving rest of the logic 
> broken on Windows.
> Here is patch, [^jibx-reactor-default_binding_Windows.patch] which fixes this.
> This issue is root cause of a build issue in Spring framework 
> https://jira.springsource.org/browse/SPR-8360

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
jibx-devs mailing list
jibx-devs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to