Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not auto-expose properties absent from @JsonIgnoreProperties #2068

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public boolean configuresVisibility(AnnotationTarget reference) {
private Visibility declaringClassIgnore(String propertyName, AnnotationTarget target) {
AnnotationInstance declaringClassJIP = context.annotations().getAnnotation(TypeUtil.getDeclaringClass(target),
getNames());
return shouldIgnoreTarget(declaringClassJIP, propertyName);
return shouldIgnoreTarget(declaringClassJIP, propertyName, Visibility.EXPOSED);
}

/**
Expand Down Expand Up @@ -244,18 +244,19 @@ private Visibility nestingPropertyIgnore(AnnotationTarget nesting, String proper
return Visibility.UNSET;
}
AnnotationInstance nestedTypeJIP = context.annotations().getAnnotation(nesting, getNames());
return shouldIgnoreTarget(nestedTypeJIP, propertyName);
return shouldIgnoreTarget(nestedTypeJIP, propertyName, Visibility.UNSET);
}

private Visibility shouldIgnoreTarget(AnnotationInstance jipAnnotation, String targetName) {
private Visibility shouldIgnoreTarget(AnnotationInstance jipAnnotation, String targetName,
Visibility unlistedVisibility) {
if (jipAnnotation == null || jipAnnotation.value() == null) {
return Visibility.UNSET;
}

if (Arrays.asList(jipAnnotation.value().asStringArray()).contains(targetName)) {
return Visibility.IGNORED;
} else {
return Visibility.EXPOSED;
return unlistedVisibility;
}
}

Expand All @@ -268,7 +269,7 @@ public List<DotName> getNames() {
public Visibility getDescendantVisibility(String propertyName, List<ClassInfo> descendants) {
for (ClassInfo descendant : descendants) {
AnnotationInstance declaringClassJIP = context.annotations().getAnnotation(descendant, getNames());
Visibility visibility = shouldIgnoreTarget(declaringClassJIP, propertyName);
Visibility visibility = shouldIgnoreTarget(declaringClassJIP, propertyName, Visibility.EXPOSED);

if (visibility != Visibility.UNSET) {
return visibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jboss.jandex.Index;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonView;

Expand Down Expand Up @@ -132,6 +133,9 @@ class Abridged {

@Schema(name = "Role")
class Role {
@JsonIgnore
protected java.util.logging.Logger logger;

@JsonView(Views.Full.class)
private UUID id;
@JsonView(Views.Ingest.class)
Expand Down