As discussed in this topic, I want to add attribute-related methods to the
Block interface, a public API. I need this API to fix a security vulnerability and thus this needs to be backported to the LTS branch 14.10.x. The new methods are the same as for parameters, just with
Map<String, Object> getAttributes(); Object getAttribute(String name); void setAttribute(String name, Object value); void setAttributes(Map<String, Object> attributes);
It is not possible to provide sensible default implementations for these methods as this would require a map to store the attributes. There are two options:
- Provide a default implementation that emulates an empty, read-only attribute map, i.e., throw
UnsupportedOperationExceptionfor the set-methods and return
null/an empty map for the get-methods. You can see this currently in the pull request.
- Make this a real API breakage.
Note that in any case, the actual implementation is provided in
AbstractBlock which is the base class of all existing implementations of
Block, I would expect that any extension that adds its own
Block implementation also inherits from it.
AbstractBlock is also a public API and its documentation explicitly says “All blocks should extend this class.”. Therefore, regardless of the chosen solution, there should be no breakage in practice.
As the default voting period of 72 hours would end during the weekend, I’m extending the vote to February 6, included.
As this is an API breakage, anyways, here is my +0 for option 1 and +1 for option 2.