Incorrect file encoding of created jbi.xml
------------------------------------------

                 Key: SM-829
                 URL: https://issues.apache.org/activemq/browse/SM-829
             Project: ServiceMix
          Issue Type: Bug
          Components: tooling
    Affects Versions: 3.1, 3.0.1, 3.0
         Environment: Win XP, JDK 1.5.0_10
            Reporter: Anders Hammar
         Attachments: JbiServiceUnitDescriptorWriterTest.java

When the jbi.xml file is created by the jbi-maven-plugin tool, the file 
encoding isn't specified (the xml encoding for the xml header is defined 
though). As a FileWriter is used, the default system encoding is used which 
does not work for special characters.

I've attached a test case that shows this for the 
JbiServiceUnitDescriptorWriter class. However, the same problem exists in all 
DescriptorWriter classes. The affected classes are:
JbiComponentDescriptorWriter
JbiServiceAssemblyDescriptorWriter
JbiServiceUnitDescriptorWriter
JbiSharedLibraryDescriptorWriter

One solution is to change the used FileWriter to a PrintWriter and pass the 
encoding to the PrintWriter constructor. Like this:
{code:title=JbiServiceUnitDescriptorWriter.java|borderStyle=solid}
//...

public void write(File descriptor, boolean bc, String name, String description, 
List uris, List consumes, List provides)
        throws JbiPluginException {
    PrintWriter w;
    try {
        w = new PrintWriter(descriptor, encoding);
    } catch (IOException ex) {
        throw new JbiPluginException("Exception while opening file[" + 
descriptor.getAbsolutePath() + "]", ex);
    }

    //...
}

//...
{code}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to