fix(content-type): prevent ClassCastException on empty binary field in related contentlet (#35188)#35283
Open
fix(content-type): prevent ClassCastException on empty binary field in related contentlet (#35188)#35283
Conversation
…n related contentlet (#35188) Skip writing emptyMap() into the contentlet map when binary metadata is null (BinaryViewStrategy), and add a defensive instanceof guard in Contentlet.getBinary() to prevent ClassCastException from any future map poisoning. Adds unit tests covering both fixes. Refs: #35188 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
Contributor
|
Claude finished @dsilvam's task in 2m 1s —— View job Claude finished @dsilvam's task in 2m 26s —— View job dotCMS Backend Review
All four review domains came back clean — no security, database, Java standards, or REST API issues found. |
Contributor
Contributor
|
✅ dotCMS Backend Review: no issues found. |
dsolistorres
approved these changes
Apr 10, 2026
gortiz-dotcms
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
depth≥1,BinaryViewStrategyunconditionally wroteemptyMap()into the contentlet's backing map under the bare field variable key (whenAVOID_MAP_SUFFIX_FOR_VIEWSis set). A subsequentDefaultTransformStrategy.addBinariescall then invokedContentlet.getBinary(), which tried to castemptyMap()toFile, throwing aClassCastExceptionwrapped asDotDataException: null.BinaryViewStrategynow skips themap.putwhentransform(field, contentlet)returns an empty map — nothing is written for fields with no uploaded file.Contentlet.getBinary()now uses aninstanceof Fileguard before casting, so any future map poisoning cannot cause aClassCastException.BinaryViewStrategyTest(2 cases) and a new case inContentletTest— covering both fixes. All 5 tests pass.Test plan
ContentletTransformerTest(27 tests) — all passBinaryViewStrategyTest— 2 tests passContentletTest#testGetBinary_whenMapContainsNonFileValue_returnsNullWithoutException— passesGET /api/v1/page/json/{page}?depth=1with a related contentlet that has an empty binary field — noClassCastException/DotDataException: nullin logsCloses #35188
🤖 Generated with Claude Code