From b57bbdabf68ae448c591e14f26292bfccdf22649 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Tue, 14 Jun 2016 10:44:53 -0500 Subject: [PATCH] HHH-10811 - Fix character encoding issues with Enver's XML mappings when JVM encoding isn't UTF-8. (cherry picked from commit 77a4a95) --- .../AdditionalJaxbMappingProducerImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/AdditionalJaxbMappingProducerImpl.java b/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/AdditionalJaxbMappingProducerImpl.java index 380efab845..5d27508dff 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/AdditionalJaxbMappingProducerImpl.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/AdditionalJaxbMappingProducerImpl.java @@ -7,15 +7,21 @@ package org.hibernate.envers.boot.internal; import java.io.BufferedInputStream; +import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; import org.hibernate.HibernateException; import org.hibernate.boot.jaxb.Origin; import org.hibernate.boot.jaxb.SourceType; @@ -28,15 +34,9 @@ import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.envers.configuration.internal.MappingCollector; import org.hibernate.service.ServiceRegistry; - import org.jboss.jandex.IndexView; import org.jboss.logging.Logger; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.io.OutputFormat; -import org.dom4j.io.XMLWriter; - /** * @author Steve Ebersole */ @@ -77,8 +77,8 @@ public class AdditionalJaxbMappingProducerImpl implements AdditionalJaxbMappingP // this form at least allows us to get better error messages final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final Writer w = new PrintWriter( baos ); try { + final Writer w = new BufferedWriter( new OutputStreamWriter( baos, "UTF-8" ) ); final XMLWriter xw = new XMLWriter( w, new OutputFormat( " ", true ) ); xw.write( document ); w.flush();