That’s a pretty good find! I’m digging in further, but the plot seems to thicken…
In the upcoming release, we’re updating libraries. That removes Jackson 1.9.2:
$ mvn dependency:tree -Dincludes=*:jackson*
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< org.igniterealtime.openfire.plugins:restAPI >-------------
[INFO] Building REST API Plugin 1.7.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ restAPI ---
[INFO] org.igniterealtime.openfire.plugins:restAPI:jar:1.7.0-SNAPSHOT
[INFO] +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.35:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.2:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.2:compile
[INFO] | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.12.2:compile
[INFO] \- io.swagger.core.v3:swagger-jaxrs2:jar:2.1.11:compile
[INFO] +- io.swagger.core.v3:swagger-integration:jar:2.1.11:compile
[INFO] | \- io.swagger.core.v3:swagger-core:jar:2.1.11:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.12.1:compile
[INFO] | \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.12.1:compile
[INFO] \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.12.1:compile
[INFO] \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.12.1:compile
Weirdly enough, I’m again getting the “old” behavior (that you’d associate with Jackson 1.9.2):
$ curl -v -X GET --header "Authorization: test" --header "Accept: application/json" http://localhost:9090/plugins/restapi/v1/users/john/roster
Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying 127.0.0.1:9090...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9090 (#0)
> GET /plugins/restapi/v1/users/john/roster HTTP/1.1
> Host: localhost:9090
> User-Agent: curl/7.68.0
> Authorization: test
> Accept: application/json
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Wed, 12 Jan 2022 18:37:39 GMT
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: JSESSIONID=node0k2k6iebnpb3m7g742fq7q9nz4.node0; Path=/; HttpOnly
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: origin, content-type, accept, authorization
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
< Content-Length: 93
<
* Connection #0 to host localhost left intact
{"rosterItem":[{"jid":"jane@example.org","nickname":"Jane","subscriptionType":3,"group":[]}]}
When I look at the endpoint definition, then it seems to return an instance of RosterEntities. This defines “roster” (instead of “rosterItems”) in two places: at the class level and as the name of the method that returns the collection of entries.
I wonder which of these two ends up in your output. I’m not sure why there is inconsistency in Jackson’s behavior here. Maybe we can make the JSON output more predictable, by doing either one of:
- adding
@JsonProperty
annotations to set the name, much like the pre-existing @XmlElement
annotations.
- renaming the method
org.jivesoftware.openfire.plugin.rest.entity.RosterEntities#getRoster
to getRosterItem
Thoughts?