Skip to content

Commit f94a51d

Browse files
committed
Changed the way sources of arrays are unmarshalled.
1 parent adaccdc commit f94a51d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/org/gitlab4j/api/utils/JacksonJson.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.TimeZone;
1313

1414
import javax.ws.rs.Produces;
15+
import javax.ws.rs.core.GenericType;
1516
import javax.ws.rs.core.MediaType;
1617
import javax.ws.rs.ext.ContextResolver;
1718
import javax.ws.rs.ext.Provider;
@@ -37,6 +38,7 @@
3738
import com.fasterxml.jackson.databind.SerializationFeature;
3839
import com.fasterxml.jackson.databind.SerializerProvider;
3940
import com.fasterxml.jackson.databind.module.SimpleModule;
41+
import com.fasterxml.jackson.databind.type.CollectionType;
4042
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
4143

4244
/**
@@ -132,7 +134,8 @@ public <T> T unmarshal(Class<T> returnType, String postData) throws JsonParseExc
132134
*/
133135
public <T> List<T> unmarshalList(Class<T> returnType, Reader reader) throws JsonParseException, JsonMappingException, IOException {
134136
ObjectMapper objectMapper = getContext(null);
135-
return (objectMapper.readValue(reader, new TypeReference<List<T>>() {}));
137+
CollectionType javaType = objectMapper.getTypeFactory().constructCollectionType(List.class, returnType);
138+
return (objectMapper.readValue(reader, javaType));
136139
}
137140

138141
/**
@@ -148,7 +151,8 @@ public <T> List<T> unmarshalList(Class<T> returnType, Reader reader) throws Json
148151
*/
149152
public <T> List<T> unmarshalList(Class<T> returnType, String postData) throws JsonParseException, JsonMappingException, IOException {
150153
ObjectMapper objectMapper = getContext(null);
151-
return objectMapper.readValue(postData, new TypeReference<List<T>>() {});
154+
CollectionType javaType = objectMapper.getTypeFactory().constructCollectionType(List.class, returnType);
155+
return (objectMapper.readValue(postData, javaType));
152156
}
153157

154158
/**

0 commit comments

Comments
 (0)