You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contentlet object's map should not be mutated. We accidently do this with Binary fields. Sometimes (most of the time) we expect file fields in our content object to be instances of java.io.File as we do here:
We need to pick one or the other and stick with it. The BinaryViewStrategy explicitly sets binaries to Strings in the content map - basically mutating the content's map. This should be a no-no.
To see this in action:
import the movies/studios/ratings bundle.
In the backend list movies and open a few
Then run this graphql query:
{
MovieCollection(sortBy: "movie.title desc", limit: 10) {
title
studio{
name
logo{
name
}
}
}
}
You will get null for the logos and a message
"message": "Internal Server Error(s) while executing query"
Logs:
09:57:33.618 ERROR error.DefaultGraphQLErrorHandler - Error executing query Exception while fetching data (/MovieCollection[9]/studio[0]/logo) : java.lang.String cannot be cast to java.io.File
java.lang.ClassCastException: java.lang.String cannot be cast to java.io.File
at com.dotmarketing.portlets.contentlet.model.Contentlet.getBinary(Contentlet.java:1182) ~[classes/:?]
at com.dotmarketing.portlets.contentlet.transform.strategy.BinaryViewStrategy.transform(BinaryViewStrategy.java:83) ~[classes/:?]
at com.dotmarketing.portlets.contentlet.transform.strategy.BinaryViewStrategy.transform(BinaryViewStrategy.java:60) ~[classes/:?]
at com.dotmarketing.portlets.contentlet.transform.strategy.AbstractTransformStrategy.apply(AbstractTransformStrategy.java:95) ~[classes/:?]
at com.dotmarketing.portlets.contentlet.transform.DotContentletTransformerImpl.lambda$3(DotContentletTransformerImpl.java:95) ~[classes/:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_162]
at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:1.8.0_162]
The text was updated successfully, but these errors were encountered:
Contentlet object's map should not be mutated. We accidently do this with Binary fields. Sometimes (most of the time) we expect file fields in our content object to be instances of
java.io.File
as we do here:https://github.com/dotCMS/core/blob/master/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/model/Contentlet.java#L1182
and sometimes we set them to be
String
s, like in theBinaryViewStrategy
class here:https://github.com/dotCMS/core/blob/master/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/BinaryViewStrategy.java#L65
We need to pick one or the other and stick with it. The
BinaryViewStrategy
explicitly sets binaries to Strings in the content map - basically mutating the content's map. This should be a no-no.To see this in action:
You will get
null
for the logos and a messageLogs:
The text was updated successfully, but these errors were encountered: