Éamonn McManus created VELOCITY-963:
---------------------------------------

             Summary: Incompatible API changes in 2.x
                 Key: VELOCITY-963
                 URL: https://issues.apache.org/jira/browse/VELOCITY-963
             Project: Velocity
          Issue Type: Bug
          Components: Engine
    Affects Versions: 2.3, 2.2, 2.1, 2.0
            Reporter: Éamonn McManus


I recently tried porting a large amount of Velocity client code from 1.7 to 2.3 
and discovered a number of incompatible API changes. Some of these were 
probably unavoidable but at least one could be fixed to ease this kind of 
migration.
 * The three RuntimeInstance.parse methods from 1.7 were replaced by a single 
RuntimeInstance.parse(Reader, Template) method. I found that I could work 
around this by changing this:
SimpleNode node = runtimeInstance.parse(reader, resourceName);
to this:
Template template = new Template();
template.setName(resourceName);
SimpleNode node = runtimeInstance.parse(reader, template);
But it would be convenient for people migrating if the old overloads were 
restored. (This might not be the best way to parse a template, but it was 
certainly quite widely used in the code I was porting.)
 * VelocityContext(Map) becomes VelocityContext(Map<String, Object>). Some of 
the code was passing a Map<String, String> or a Map<String, ?>. That would work 
if the argument type were Map<String, ?>, but I don't think that would be 
correct since I believe the Map can be updated by #set directives. So perhaps 
document this more explicitly.
 * This abstract method in ResourceLoader
InputStream getResourceStream(String source)
becomes
Reader getResourceReader(String source, String encoding)
I'm not sure there would have been a good way to allow subclasses of 
ResourceLoader to continue to work without change, and this change _is_ 
documented in the [migration 
guide|https://velocity.apache.org/engine/2.0/upgrading.html#behavior-api-changes]
 so there's probably nothing further to do here.
 * Nearly all the methods in StringUtils have been deleted, and that's not 
mentioned in the migration guide.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to