[
https://issues.apache.org/jira/browse/VELOCITY-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12705598#action_12705598
]
Nathan Bubna commented on VELOCITY-714:
---------------------------------------
Still, it might be worth considering for the 2.0 branch, where BC is not an
issue.
> Change ResourceLoader API to return Reader instances instead of InputStreams
> ----------------------------------------------------------------------------
>
> Key: VELOCITY-714
> URL: https://issues.apache.org/jira/browse/VELOCITY-714
> Project: Velocity
> Issue Type: Improvement
> Components: Engine
> Reporter: Jarkko Viinamäki
>
> Abstract class org.apache.velocity.runtime.resource.loader.ResourceLoader
> contains method
> public abstract InputStream getResourceStream( String source )
> throws ResourceNotFoundException;
> However, in org.apache.velocity.Template.process() there is code
> (abbreviated):
> try
> {
> is = resourceLoader.getResourceStream(name);
> }
> catch( ResourceNotFoundException rnfe )
> {
> errorCondition = rnfe;
> throw rnfe;
> }
> if (is != null)
> {
> try
> {
> BufferedReader br = new BufferedReader( new
> InputStreamReader( is, encoding ) );
> data = rsvc.parse( br, name);
> ...
> This seems a bit silly. ResourceLoaders should obviously return Reader
> instances since those would allow loaders to take content encoding into
> account. Currently this is problematic especially with
> DataSourceResourceLoader (VELOCITY-599). If we want to support UTF-8 in
> DataSourceResourceLoader, with current API we would first have to use
> ResultSet.getCharacterStream to get a Reader, then read all stuff into a
> String, then convert it into UTF-8 encoding with getBytes call but then in
> the Template the whole stuff is then converted back to a Reader. That's a lot
> of waste.
> I think it would make more sense if the ResourceLoader API contained a method:
> public abstract Reader getResource( String source )
> throws ResourceNotFoundException;
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]