Skip to content

Commit

Permalink
Apply Jackson workaround for issue #1964
Browse files Browse the repository at this point in the history
Jackson versions newer than 2.9.2 and older than 2.9.6 have problems
with serializing static types:

  FasterXML/jackson-databind#1964

Until v2.9.6 become available we have to live with this workaround
described here

  https://github.com/FasterXML/jackson-
databind/issues/1964#issuecomment-382877148
  • Loading branch information
ridoo committed May 30, 2018
1 parent 116f4b1 commit 93e3f12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spi/src/main/java/org/n52/io/response/dataset/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

public class Data<T extends AbstractValue<?>> implements Serializable {

Expand All @@ -58,6 +59,9 @@ public void setValues(T[] values) {
/**
* @return a sorted list of quantity values.
*/
// TODO @JsonSerialize may not be needed anymore from jackson 2.9.6
// https://github.com/FasterXML/jackson-databind/issues/1964#issuecomment-382877148
@JsonSerialize(typing = JsonSerialize.Typing.STATIC)
public List<T> getValues() {
return Collections.unmodifiableList(this.values);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.n52.io.response.ParameterOutput;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

public class DatasetOutput<V extends AbstractValue< ? >> extends ParameterOutput {

Expand Down Expand Up @@ -117,6 +118,9 @@ public DatasetOutput<V> setUom(OptionalOutput<String> uom) {
return this;
}

// TODO @JsonSerialize may not be needed anymore from jackson 2.9.6
// https://github.com/FasterXML/jackson-databind/issues/1964#issuecomment-382877148
@JsonSerialize(typing = JsonSerialize.Typing.STATIC)
public V getFirstValue() {
return getIfSerialized(firstValue);
}
Expand All @@ -126,6 +130,9 @@ public DatasetOutput<V> setFirstValue(OptionalOutput<V> firstValue) {
return this;
}

// TODO @JsonSerialize may not be needed anymore from jackson 2.9.6
// https://github.com/FasterXML/jackson-databind/issues/1964#issuecomment-382877148
@JsonSerialize(typing = JsonSerialize.Typing.STATIC)
public V getLastValue() {
return getIfSerialized(lastValue);
}
Expand Down

0 comments on commit 93e3f12

Please sign in to comment.