From 9ca5f797255ca6866128018c19d15a275f5de453 Mon Sep 17 00:00:00 2001 From: nscuro Date: Sat, 23 Sep 2023 12:17:50 +0200 Subject: [PATCH] Fix `@JsonIgnore` having no effect on `transient` fields A (more or less intentional) regression in Jackson 2.15 causes `@JsonIgnore` annotations on `transient` fields to be ignored. As a workaround, the annotation can be added to getters and setters instead (https://github.com/FasterXML/jackson-databind/issues/3909#issuecomment-1533857834). Signed-off-by: nscuro --- src/main/java/org/dependencytrack/model/Component.java | 6 ++---- src/main/java/org/dependencytrack/model/Project.java | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/dependencytrack/model/Component.java b/src/main/java/org/dependencytrack/model/Component.java index fff224fe35..2c3495ac67 100644 --- a/src/main/java/org/dependencytrack/model/Component.java +++ b/src/main/java/org/dependencytrack/model/Component.java @@ -357,12 +357,8 @@ public enum FetchGroup { private transient DependencyMetrics metrics; private transient RepositoryMetaComponent repositoryMeta; private transient int usedBy; - - @JsonIgnore private transient JsonObject cacheResult; - private transient Set dependencyGraph; - private transient boolean expandDependencyGraph; public long getId() { @@ -778,10 +774,12 @@ public void setUsedBy(int usedBy) { this.usedBy = usedBy; } + @JsonIgnore public JsonObject getCacheResult() { return cacheResult; } + @JsonIgnore public void setCacheResult(JsonObject cacheResult) { this.cacheResult = cacheResult; } diff --git a/src/main/java/org/dependencytrack/model/Project.java b/src/main/java/org/dependencytrack/model/Project.java index 68e9a84845..f52eb7301a 100644 --- a/src/main/java/org/dependencytrack/model/Project.java +++ b/src/main/java/org/dependencytrack/model/Project.java @@ -258,10 +258,7 @@ public enum FetchGroup { private List externalReferences; private transient ProjectMetrics metrics; - private transient List versions; - - @JsonIgnore private transient List dependencyGraph; public long getId() { @@ -484,10 +481,12 @@ public void addAccessTeam(Team accessTeam) { this.accessTeams.add(accessTeam); } + @JsonIgnore public List getDependencyGraph() { return dependencyGraph; } + @JsonIgnore public void setDependencyGraph(List dependencyGraph) { this.dependencyGraph = dependencyGraph; }