Skip to content

Commit a377bb4

Browse files
authored
⬆️ various dependency updates (#315)
1 parent a7c17f0 commit a377bb4

7 files changed

Lines changed: 67 additions & 86 deletions

File tree

.mvn/jvm.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

pom.xml

Lines changed: 44 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,20 @@
9090
<version>${org.projectlombok.lombok-mapstruct-binding.version}</version>
9191
</path>
9292
</annotationProcessorPaths>
93-
<source>11</source>
94-
<target>11</target>
93+
<release>${compiler.release}</release>
94+
</configuration>
95+
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-pmd-plugin</artifactId>
99+
<version>3.23.0</version>
100+
<configuration>
101+
<linkXRef>false</linkXRef>
102+
<printFailingErrors>true</printFailingErrors>
103+
<failurePriority>3</failurePriority>
104+
<targetJdk>${compiler.release}</targetJdk>
95105
</configuration>
96106
</plugin>
97-
<plugin>
98-
<groupId>org.apache.maven.plugins</groupId>
99-
<artifactId>maven-pmd-plugin</artifactId>
100-
<version>3.23.0</version>
101-
<configuration>
102-
<linkXRef>false</linkXRef>
103-
<printFailingErrors>true</printFailingErrors>
104-
<failurePriority>3</failurePriority>
105-
<targetJdk>11</targetJdk>
106-
</configuration>
107-
</plugin>
108107
<plugin>
109108
<groupId>com.diffplug.spotless</groupId>
110109
<artifactId>spotless-maven-plugin</artifactId>
@@ -129,8 +128,7 @@
129128
<groupId>org.apache.maven.plugins</groupId>
130129
<artifactId>maven-compiler-plugin</artifactId>
131130
<configuration>
132-
<source>11</source>
133-
<target>11</target>
131+
<release>${compiler.release}</release>
134132
</configuration>
135133
</plugin>
136134
<plugin>
@@ -150,7 +148,7 @@
150148
<plugin>
151149
<groupId>org.sonatype.central</groupId>
152150
<artifactId>central-publishing-maven-plugin</artifactId>
153-
<version>0.8.0</version>
151+
<version>0.9.0</version>
154152
<extensions>true</extensions>
155153
<configuration>
156154
<publishingServerId>central</publishingServerId>
@@ -162,22 +160,6 @@
162160
</build>
163161

164162
<profiles>
165-
<profile>
166-
<id>jdk-9-plus</id>
167-
<activation>
168-
<jdk>[9,)</jdk>
169-
</activation>
170-
<properties>
171-
<surefire.addOpens>
172-
--add-opens java.base/java.lang=ALL-UNNAMED
173-
--add-opens java.base/java.util=ALL-UNNAMED
174-
--add-opens java.base/java.net=ALL-UNNAMED
175-
--add-opens java.base/sun.net.www.protocol.https=ALL-UNNAMED
176-
--add-opens java.base/java.io=ALL-UNNAMED
177-
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
178-
</surefire.addOpens>
179-
</properties>
180-
</profile>
181163
<profile>
182164
<id>release</id>
183165
<build>
@@ -356,12 +338,6 @@
356338
<scope>test</scope>
357339
<version>${org.junit.jupiter.version}</version>
358340
</dependency>
359-
<dependency>
360-
<artifactId>junit-platform-suite</artifactId>
361-
<groupId>org.junit.platform</groupId>
362-
<scope>test</scope>
363-
<version>${org.junit.platform.version}</version>
364-
</dependency>
365341
<dependency>
366342
<artifactId>junit-pioneer</artifactId>
367343
<groupId>org.junit-pioneer</groupId>
@@ -386,13 +362,6 @@
386362
<version>${wiremock.version}</version>
387363
<scope>test</scope>
388364
</dependency>
389-
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
390-
<dependency>
391-
<groupId>org.hamcrest</groupId>
392-
<artifactId>hamcrest</artifactId>
393-
<version>${org.hamcrest.version}</version>
394-
<scope>test</scope>
395-
</dependency>
396365
</dependencies>
397366

398367
<scm>
@@ -405,16 +374,37 @@
405374
<!-- MINDEE VERSION GOES HERE -->
406375
<revision>5.0.0-alpha1</revision>
407376

377+
<!-- Give special access when running tests -->
378+
<surefire.addOpens>
379+
--add-opens java.base/java.lang=ALL-UNNAMED
380+
--add-opens java.base/java.util=ALL-UNNAMED
381+
--add-opens java.base/java.net=ALL-UNNAMED
382+
--add-opens java.base/sun.net.www.protocol.https=ALL-UNNAMED
383+
--add-opens java.base/java.io=ALL-UNNAMED
384+
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
385+
</surefire.addOpens>
386+
387+
<!-- Minimum Java version -->
388+
<compiler.release>11</compiler.release>
389+
390+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
391+
392+
<!-- Code dependencies -->
408393
<tools.jackson.core.databind.version>3.1.1</tools.jackson.core.databind.version>
409394
<com.fasterxml.jackson.datatype.version>2.21.2</com.fasterxml.jackson.datatype.version>
410395
<com.squareup.okhttp3.version>4.12.0</com.squareup.okhttp3.version>
411-
<info.picocli.version>4.7.6</info.picocli.version>
412-
<maven.compiler.source>11</maven.compiler.source>
413-
<maven.compiler.target>11</maven.compiler.target>
396+
<info.picocli.version>4.7.7</info.picocli.version>
414397
<org.apache.commons.math3.version>3.6.1</org.apache.commons.math3.version>
415398
<org.apache.httpcomponents.client5.httpclient5.version>5.4.4</org.apache.httpcomponents.client5.httpclient5.version>
416-
<commons-codec.version>1.20.0</commons-codec.version>
417-
<org.apache.maven.clean.version>3.1.0</org.apache.maven.clean.version>
399+
<commons-codec.version>1.21.0</commons-codec.version>
400+
<org.apache.pdfbox.version>3.0.7</org.apache.pdfbox.version>
401+
<org.mapstruct.version>1.5.3.Final</org.mapstruct.version>
402+
<org.projectlombok.lombok-mapstruct-binding.version>0.2.0</org.projectlombok.lombok-mapstruct-binding.version>
403+
<org.projectlombok.version>1.18.40</org.projectlombok.version>
404+
<org.slf4j.version>2.0.17</org.slf4j.version>
405+
406+
<!-- Build/Test dependencies -->
407+
<org.apache.maven.clean.version>3.5.0</org.apache.maven.clean.version>
418408
<org.apache.maven.compiler.version>3.12.1</org.apache.maven.compiler.version>
419409
<org.apache.maven.failsafe.version>3.5.5</org.apache.maven.failsafe.version>
420410
<org.apache.maven.gpg.version>1.5</org.apache.maven.gpg.version>
@@ -424,18 +414,11 @@
424414
<org.apache.maven.resources.version>3.0.2</org.apache.maven.resources.version>
425415
<org.apache.maven.project.info.reports.version>3.0.0</org.apache.maven.project.info.reports.version>
426416
<org.apache.maven.site.version>3.7.1</org.apache.maven.site.version>
427-
<org.apache.maven.surfire.version>3.2.5</org.apache.maven.surfire.version>
428-
<org.apache.pdfbox.version>3.0.5</org.apache.pdfbox.version>
429-
<org.junit.jupiter.version>5.8.2</org.junit.jupiter.version>
430-
<org.junit.pioneer.version>1.9.1</org.junit.pioneer.version>
431-
<org.junit.platform.version>1.9.2</org.junit.platform.version>
432-
<org.hamcrest.version>2.2</org.hamcrest.version>
433-
<org.mapstruct.version>1.5.3.Final</org.mapstruct.version>
434-
<org.projectlombok.lombok-mapstruct-binding.version>0.2.0</org.projectlombok.lombok-mapstruct-binding.version>
435-
<org.projectlombok.version>1.18.38</org.projectlombok.version>
436-
<org.slf4j.version>2.0.17</org.slf4j.version>
437-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
417+
<org.apache.maven.surfire.version>3.5.5</org.apache.maven.surfire.version>
438418
<wiremock.version>3.13.2</wiremock.version>
419+
<!-- jupiter version 5.x is the last with JRE 11 support -->
420+
<org.junit.jupiter.version>5.11.4</org.junit.jupiter.version>
421+
<org.junit.pioneer.version>2.3.0</org.junit.pioneer.version>
439422
</properties>
440423

441424
</project>

src/main/java/com/mindee/v1/parsing/LocalResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private <P extends Inference, R> R deserialize(
6262
public <T extends Inference> AsyncPredictResponse<T> deserializeAsyncResponse(
6363
Class<T> productClass
6464
) throws IOException {
65+
@SuppressWarnings("unchecked")
6566
AsyncPredictResponse<T> response = deserialize(AsyncPredictResponse.class, productClass);
6667
response.setRawResponse(new String(this.file, StandardCharsets.UTF_8));
6768
return response;
@@ -78,6 +79,7 @@ public <T extends Inference> AsyncPredictResponse<T> deserializeAsyncResponse(
7879
public <T extends Inference> PredictResponse<T> deserializeSyncResponse(
7980
Class<T> productClass
8081
) throws IOException {
82+
@SuppressWarnings("unchecked")
8183
PredictResponse<T> response = deserialize(PredictResponse.class, productClass);
8284
response.setRawResponse(new String(this.file, StandardCharsets.UTF_8));
8385
return response;

src/main/java/com/mindee/v1/parsing/generated/GeneratedObject.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public StringField asStringField() {
3636
* @return An {@link AmountField} containing a double value.
3737
*/
3838
public AmountField asAmountField() {
39-
Double value;
39+
double value;
4040
Object rawValue = this.get("value");
4141
if (rawValue instanceof Integer) {
4242
value = ((Integer) rawValue).doubleValue();
@@ -109,13 +109,13 @@ public Polygon getAsPolygon(String key) {
109109
if (!this.containsKey(key)) {
110110
return null;
111111
}
112-
Object rawPolygon = this.get(key);
112+
var rawPolygon = this.get(key);
113113
// a valid polygon must have at least 4 points
114114
if (!(rawPolygon instanceof List && ((List<?>) rawPolygon).size() >= 4)) {
115115
return null;
116116
}
117117
// a valid point must have exactly 2 coordinates
118-
for (Object point : (List<?>) rawPolygon) {
118+
for (var point : (List<?>) rawPolygon) {
119119
if (!(point instanceof List) || ((List<?>) point).size() != 2) {
120120
return null;
121121
}
@@ -125,7 +125,9 @@ public Polygon getAsPolygon(String key) {
125125
}
126126
}
127127
}
128-
return new Polygon((List<List<Double>>) rawPolygon);
128+
@SuppressWarnings("unchecked")
129+
List<List<Double>> points = (List<List<Double>>) rawPolygon;
130+
return new Polygon(points);
129131
}
130132

131133
/**

src/main/java/com/mindee/v1/parsing/generated/GeneratedV1PredictionDeserializer.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package com.mindee.v1.parsing.generated;
22

33
import com.fasterxml.jackson.core.JsonParser;
4-
import com.fasterxml.jackson.core.type.TypeReference;
54
import com.fasterxml.jackson.databind.DeserializationContext;
65
import com.fasterxml.jackson.databind.JsonNode;
7-
import com.fasterxml.jackson.databind.ObjectMapper;
86
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
97
import com.fasterxml.jackson.databind.node.ObjectNode;
108
import com.mindee.v1.product.generated.GeneratedV1Document;
119
import java.io.IOException;
1210
import java.util.HashMap;
13-
import java.util.Iterator;
14-
import java.util.Map;
1511

1612
/**
1713
* JSON deserializer for generated documents v1.x.
@@ -22,8 +18,6 @@ public GeneratedV1PredictionDeserializer(Class<?> vc) {
2218
super(vc);
2319
}
2420

25-
private static final ObjectMapper mapper = new ObjectMapper();
26-
2721
public GeneratedV1PredictionDeserializer() {
2822
this(null);
2923
}
@@ -33,27 +27,24 @@ public GeneratedV1Document deserialize(
3327
JsonParser jsonParser,
3428
DeserializationContext deserializationContext
3529
) throws IOException {
36-
ObjectNode rootNode = jsonParser.getCodec().readTree(jsonParser);
37-
Map<String, GeneratedFeature> features = new HashMap<>();
30+
var mapper = jsonParser.getCodec();
31+
ObjectNode rootNode = mapper.readTree(jsonParser);
32+
var features = new HashMap<String, GeneratedFeature>();
3833

39-
for (Iterator<Map.Entry<String, JsonNode>> subNode = rootNode.fields(); subNode.hasNext();) {
40-
Map.Entry<String, JsonNode> featureNode = subNode.next();
34+
for (var featureNode : rootNode.properties()) {
4135
String featureName = featureNode.getKey();
4236

4337
GeneratedFeature feature;
44-
4538
if (featureNode.getValue().isArray()) {
4639
feature = new GeneratedFeature(true);
4740
for (JsonNode item : featureNode.getValue()) {
48-
GeneratedObject value = mapper.readerFor(new TypeReference<GeneratedObject>() {
49-
}).readValue(item);
41+
GeneratedObject value = mapper.treeToValue(item, GeneratedObject.class);
5042
feature.add(value);
5143
}
5244
features.put(featureName, feature);
5345
} else {
5446
feature = new GeneratedFeature(false);
55-
GeneratedObject value = mapper.readerFor(new TypeReference<GeneratedObject>() {
56-
}).readValue(featureNode.getValue());
47+
GeneratedObject value = mapper.treeToValue(featureNode.getValue(), GeneratedObject.class);
5748
feature.add(value);
5849
}
5950
features.put(featureName, feature);

src/main/java/com/mindee/v2/parsing/inference/field/DynamicField.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ public ObjectField getObjectField() throws IllegalStateException {
8282
*/
8383
public <T extends BaseField> T getField(Class<T> type) throws IllegalArgumentException {
8484
if (type == SimpleField.class) {
85-
return (T) this.getSimpleField();
85+
return type.cast(this.getSimpleField());
8686
}
8787
if (type == ListField.class) {
88-
return (T) this.getListField();
88+
return type.cast(this.getListField());
8989
}
9090
if (type == ObjectField.class) {
91-
return (T) this.getObjectField();
91+
return type.cast(this.getObjectField());
9292
}
9393
throw new IllegalArgumentException("Cannot cast to " + type.getSimpleName());
9494
}

src/test/java/com/mindee/v1/http/MindeeHttpApiV1Test.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
99
import static com.mindee.TestingUtilities.getV1ResourcePath;
1010
import static com.mindee.TestingUtilities.getV1ResourcePathString;
11-
import static org.hamcrest.MatcherAssert.assertThat;
1211

1312
import com.fasterxml.jackson.core.type.TypeReference;
1413
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -35,7 +34,6 @@
3534
import org.apache.hc.client5.http.impl.classic.HttpClients;
3635
import org.apache.hc.client5.http.impl.routing.DefaultProxyRoutePlanner;
3736
import org.apache.hc.core5.http.HttpHost;
38-
import org.hamcrest.collection.IsMapContaining;
3937
import org.junit.After;
4038
import org.junit.Assert;
4139
import org.junit.Before;
@@ -213,7 +211,7 @@ void givenParseParametersWithFileUrl_whenParsed_shouldBuildRequestCorrectly() th
213211
Map<String, String> requestMap = objectMapper
214212
.readValue(recordedRequest.getBody().readUtf8(), new TypeReference<Map<String, String>>() {
215213
});
216-
assertThat(requestMap, IsMapContaining.hasEntry("document", "https://thisfile.does.not.exist"));
214+
Assertions.assertEquals("https://thisfile.does.not.exist", requestMap.get("document"));
217215
}
218216

219217
@Test

0 commit comments

Comments
 (0)