maven-doxia-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Siveton" <vincent.sive...@gmail.com>
Subject Re: svn commit: r723989 - /maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
Date Mon, 08 Dec 2008 11:20:38 GMT
Hi Benjamin,

Right and I fixed it in r724309.

Thanks!

Vincent

2008/12/6 Benjamin Bentmann <benjamin.bentmann@udo.edu>:
> Hi Vincent,
>
>> Author: vsiveton
>> Date: Sat Dec  6 06:41:44 2008
>> New Revision: 723989
>>
>> URL: http://svn.apache.org/viewvc?rev=723989&view=rev
>> Log:
>> DOXIA-265: Add an EntityResolver in AbstractXmlParser#getXmlReader()
>>
>> o added a simple cached file mechanism
>>
>> Modified:
>>
>>  maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
>> [...]
>> +            byte[] res = (byte[]) cache.get( systemId );
>> +            // already cached?
>> +            if ( res == null )
>> +            {
>> +                File temp =
>> +                    new File( System.getProperty( "java.io.tmpdir" ),
>> FileUtils.getFile( systemId ).getName() );
>> +                // maybe already as a temp file?
>> +                if ( !temp.exists() )
>> +                {
>> +                    res = IOUtil.toByteArray( new URL( systemId
>> ).openStream() );
>> +                    IOUtil.copy( res, WriterFactory.newPlatformWriter(
>> temp ) );
>> +                }
>> +                else
>> +                {
>> +                    res = IOUtil.toByteArray(
>> ReaderFactory.newPlatformReader( temp ) );
>> +                }
>> +
>> +                cache.put( systemId, res );
>> +            }
>> +
>> +            InputSource is = new InputSource( new ByteArrayInputStream(
>> res ) );
>> +            is.setPublicId( publicId );
>> +            is.setSystemId( systemId );
>> +
>
> Is it safe to use a reader here, especially a platform reader? Byte streams
> that don't match the intended encoding get crippled but is the encoding of
> the data known here? Should this maybe just use
>  IOUtil.copy( byte[], OutputStream )
> and
>  IOUtil.toByteArray( InputStream )
> i.e. simply move bytes around instead of thinking about characters?
>
>
> Benjamin
>

Mime
View raw message