Buuhuu commented on a change in pull request #9:
URL:
https://github.com/apache/sling-org-apache-sling-scripting-sightly-runtime/pull/9#discussion_r678282735
##########
File path:
src/main/java/org/apache/sling/scripting/sightly/render/ObjectModel.java
##########
@@ -308,12 +306,7 @@ public static String toString(Object object) {
Iterable<Object> iterable = (Iterable<Object>) object;
return fromIterator(iterable.iterator());
}
- if (object instanceof String || object instanceof Number) {
- Collection<Object> list = new ArrayList<>();
- list.add(object);
- return list;
- }
- return Collections.emptyList();
+ return Collections.singletonList(object);
Review comment:
While I agree with the change, I think it comes with a certain risk as
it changes the returned collection from a modifiable to an unmodifiable one.
Should we make that somehow clear to the consumers?
In general I think we should return unmodifiable collections. Can you change
`fromIterator()` accordingly as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]