Skip to content

Commit 85c9f36

Browse files
arjvikjansupol
authored andcommitted
FIX #3849: Add vnd.api+json to LoggingFeature (#3887)
* FIX #3849: Add vnd.api+json to the media types logged by PAYLOAD_TEXT Verbosity Signed-off-by: Arjun Vikram <[email protected]>
1 parent ba65703 commit 85c9f36

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

core-common/src/main/java/org/glassfish/jersey/logging/LoggingInterceptor.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,16 @@ abstract class LoggingInterceptor implements WriterInterceptor {
7070
private static final String NOTIFICATION_PREFIX = "* ";
7171
private static final MediaType TEXT_MEDIA_TYPE = new MediaType("text", "*");
7272

73+
/**
74+
* application/vnd.api+json (documented here: http://jsonapi.org/)
75+
* is a modified form of JSON, which is not present in the JAX-RS
76+
* MediaType class as a static constant. Requested in Issue #3849
77+
*/
78+
private static final MediaType APPLICATION_VND_API_JSON = new MediaType("application", "vnd.api+json");
79+
7380
private static final Set<MediaType> READABLE_APP_MEDIA_TYPES = new HashSet<MediaType>() {{
7481
add(TEXT_MEDIA_TYPE);
82+
add(APPLICATION_VND_API_JSON);
7583
add(MediaType.APPLICATION_ATOM_XML_TYPE);
7684
add(MediaType.APPLICATION_FORM_URLENCODED_TYPE);
7785
add(MediaType.APPLICATION_JSON_TYPE);

core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public void testReadableTypeAppSubJson() {
5252
assertTrue(LoggingInterceptor.isReadable(new MediaType("application", "json")));
5353
}
5454

55+
@Test
56+
public void testReadableTypeApplicationSubVndApiJson() {
57+
assertTrue(LoggingInterceptor.isReadable(new MediaType("application", "vnd.api+json")));
58+
}
59+
5560
@Test
5661
public void testReadableTypeAppSubBinary() {
5762
assertFalse(LoggingInterceptor.isReadable(new MediaType("application", "octet-stream")));

0 commit comments

Comments
 (0)