Skip to content

Commit ca17b58

Browse files
author
Stephen Powis
committed
Resolve type safety warning
1 parent d813924 commit ca17b58

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/java/org/sourcelab/kafka/connect/apiclient/request/JacksonFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import com.fasterxml.jackson.databind.DeserializationFeature;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
23+
import com.fasterxml.jackson.databind.type.MapType;
24+
25+
import java.util.Map;
2326

2427
/**
2528
* Creates properly configured Jackson XML Mapper instances.
@@ -32,6 +35,12 @@ public final class JacksonFactory {
3235
*/
3336
private static final ObjectMapper mapper = new ObjectMapper();
3437

38+
/**
39+
* Defines a "type safe" Map[String, String] deserialization type for Jackson.
40+
*/
41+
public static final MapType mapTypeStringString = mapper.getTypeFactory()
42+
.constructMapType(Map.class, String.class, String.class);
43+
3544
/*
3645
* Statically configure the instance.
3746
*/

src/main/java/org/sourcelab/kafka/connect/apiclient/request/get/GetConnectorConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public Object getRequestBody() {
5353

5454
@Override
5555
public Map<String, String> parseResponse(final String responseStr) throws IOException {
56-
return JacksonFactory.newInstance().readValue(responseStr, Map.class);
56+
return JacksonFactory.newInstance().readValue(responseStr, JacksonFactory.mapTypeStringString);
5757
}
5858
}

0 commit comments

Comments
 (0)