Skip to content

Commit

Permalink
Fix resolving of transient properties in new Spring Framework version
Browse files Browse the repository at this point in the history
  • Loading branch information
agrancaric committed May 6, 2024
1 parent 89ba993 commit a648571
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ public void initBinder(WebDataBinder binder) {
}

if (ignoreTransientFields) {
Object target = binder.getTarget();
Class<?> targetType = null;
if (binder.getTarget() != null) {
targetType = binder.getTarget().getClass();
}
else if (binder.getTargetType() != null) {
targetType = binder.getTargetType().resolve();
}

if (target == null) {
if (targetType == null) {
return;
}

List<String> transientPropertyList = transientPropertyResolverService.resolveTransientPropertyList(target.getClass());
List<String> transientPropertyList = transientPropertyResolverService.resolveTransientPropertyList(targetType);

binder.setDisallowedFields(transientPropertyList.toArray(new String[0]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void shouldConvertEmptyStringsToNull() throws Exception {
void shouldNotBindTransientFields() throws Exception {
// given
String requestUrl = fullUrl("transient-properties-serialization");
String value = "value";
Map<String, String> request = createMap("transientProperty", "transient", "property", "nonTransient");

// when
Expand Down

0 comments on commit a648571

Please sign in to comment.