Skip to content

Commit ccc3b47

Browse files
committed
- Made JacksonJSonParser extend ObjectMapper instead of using it.
- Made response from server on errors be displayed under debug log instead of info.
1 parent 0dd9ac8 commit ccc3b47

File tree

8 files changed

+22
-18
lines changed

8 files changed

+22
-18
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Java Client Library (beta)
22

3-
### Latest released version v0.7.0
3+
### Latest released version v0.7.1
4+
### Latest snapshot version v0.7.2-SNAPSHOT
45

56
## Introduction
67
Welcome my friends! This is the Poly API Java client GitHub page. If you are here, then it means you're familiar with what we do at Poly. If you aren't, you can always check [here](https://github.com/polyapi/poly-alpha).
@@ -54,7 +55,7 @@ Nice to have some customers looking around here! So, you'll need to run the foll
5455
2. **Update the project.** Add the following to your project's `pom.xml`:
5556
```xml
5657
<properties>
57-
<poly.version>0.7.0</poly.version>
58+
<poly.version>0.7.1</poly.version>
5859
</properties>
5960
<dependencies>
6061
<dependency>
@@ -314,6 +315,9 @@ Comparing to its Typescript counterpart, the Java library is still missing the f
314315
These features will be added in the future releases.
315316

316317
## Changelog
318+
### v0.7.2
319+
- Made JacksonJSonParser extend ObjectMapper instead of using it.
320+
- Made response from server on errors be displayed under debug log instead of info.
317321
### v0.7.1
318322
- Fixed bug about having duplicate schema types with the same name.
319323
- Improved minor code issues.

commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.8.0-SNAPSHOT</version>
7+
<version>0.7.2-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010

commons/src/main/java/io/polyapi/commons/internal/json/JacksonJsonParser.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
* Wrapper class around the Jackson mapping library to handle all the errors it can throw and unify all the configuration for it.
2626
*/
2727
@Slf4j
28-
public class JacksonJsonParser implements JsonParser {
29-
private final ObjectMapper objectMapper;
28+
public class JacksonJsonParser extends ObjectMapper implements JsonParser {
3029
private final JsonSchemaGenerator jsonSchemaGenerator;
3130

3231
/**
3332
* Utility constructor that uses a standard {@link ObjectMapper} instance.
3433
*/
3534
public JacksonJsonParser() {
36-
this(new ObjectMapper().configure(FAIL_ON_UNKNOWN_PROPERTIES, false));
35+
configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
36+
this.jsonSchemaGenerator = new JsonSchemaGenerator(this);
3737
}
3838

3939
/**
@@ -42,7 +42,7 @@ public JacksonJsonParser() {
4242
* @param objectMapper The object mapper.
4343
*/
4444
public JacksonJsonParser(ObjectMapper objectMapper) {
45-
this.objectMapper = objectMapper;
45+
super(objectMapper);
4646
this.jsonSchemaGenerator = new JsonSchemaGenerator(objectMapper);
4747
}
4848

@@ -53,7 +53,7 @@ public JacksonJsonParser(ObjectMapper objectMapper) {
5353
public String toJsonString(Object object) {
5454
try {
5555
log.debug("Parsing object of type {} to String.", object.getClass().getSimpleName());
56-
String result = objectMapper.writeValueAsString(object);
56+
String result = writeValueAsString(object);
5757
log.debug("Object to String parsing successful.");
5858
if (log.isTraceEnabled()) {
5959
log.trace("Parsed result is:\n{}", result);
@@ -71,7 +71,7 @@ public String toJsonString(Object object) {
7171
public InputStream toJsonInputStream(Object object) {
7272
try {
7373
log.debug("Parsing object of type {} to InputStream.", Optional.ofNullable(object).map(Object::getClass).map(Class::getName).orElse("null"));
74-
InputStream result = new ByteArrayInputStream(object == null ? new byte[]{} : objectMapper.writeValueAsBytes(object));
74+
InputStream result = new ByteArrayInputStream(object == null ? new byte[]{} : writeValueAsBytes(object));
7575
log.debug("String to object parsing successful.");
7676
if (log.isTraceEnabled()) {
7777
log.trace("Parsed result is:\n{}", IOUtils.toString(result, defaultCharset()));
@@ -95,7 +95,7 @@ public <O> O parseString(String json, Type expectedResponseType) {
9595
log.trace("Input to parse is:\n{}", json);
9696
}
9797
log.debug("Parsing JSon String to object of type {}.", expectedResponseType.getTypeName());
98-
O result = objectMapper.readValue(json, defaultInstance().constructType(expectedResponseType));
98+
O result = readValue(json, defaultInstance().constructType(expectedResponseType));
9999
log.debug("Parsing successful.");
100100
return result;
101101
} catch (IOException e) {
@@ -124,7 +124,7 @@ public <O> O parseInputStream(InputStream json, Type expectedResponseType) {
124124
if (expectedResponseType == String.class) {
125125
result = (O) IOUtils.toString(json, Charset.defaultCharset());
126126
} else {
127-
result = objectMapper.readValue(json, defaultInstance().constructType(expectedResponseType));
127+
result = readValue(json, defaultInstance().constructType(expectedResponseType));
128128
}
129129

130130
log.debug("Parsing successful.");

library/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.8.0-SNAPSHOT</version>
7+
<version>0.7.2-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010
<artifactId>library</artifactId>

parent-pom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.polyapi</groupId>
55
<artifactId>parent-pom</artifactId>
6-
<version>0.8.0-SNAPSHOT</version>
6+
<version>0.7.2-SNAPSHOT</version>
77
<packaging>pom</packaging>
88
<name>Poly API Java parent POM</name>
99
<url>https://polyapi.io</url>

polyapi-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.8.0-SNAPSHOT</version>
7+
<version>0.7.2-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010
<artifactId>polyapi-maven-plugin</artifactId>

polyapi-maven-plugin/src/main/java/io/polyapi/plugin/mojo/PolyApiMojo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7070
throw new MojoFailureException(e);
7171
} catch (UnexpectedHttpResponseException e) {
7272
log.error("An unexpected HTTP response code {} was returned from the server.", e.getResponse().statusCode());
73-
//if (log.isTraceEnabled()) {
73+
if (log.isDebugEnabled()) {
7474
try {
75-
log.info("Response from server is: {}", IOUtils.toString(e.getResponse().body(), defaultCharset()));
75+
log.debug("Response from server is: {}", IOUtils.toString(e.getResponse().body(), defaultCharset()));
7676
} catch (IOException ex) {
7777
throw new MojoExecutionException(ex);
7878
}
79-
//}
79+
}
8080
throw new MojoFailureException(e);
8181
} catch (RuntimeException e) {
8282
log.error("An unexpected exception occurred during the plugin execution.", e);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.polyapi</groupId>
55
<artifactId>polyapi-java</artifactId>
6-
<version>0.8.0-SNAPSHOT</version>
6+
<version>0.7.2-SNAPSHOT</version>
77
<packaging>pom</packaging>
88
<modules>
99
<module>parent-pom</module>

0 commit comments

Comments
 (0)