Skip to content

Commit 27a690e

Browse files
committed
JDK 11+ - update dependencies
1 parent cc337d1 commit 27a690e

File tree

21 files changed

+205
-231
lines changed

21 files changed

+205
-231
lines changed

.github/workflows/maven-pulls.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
java: [ 8, 11, 14 ]
13+
java: [ 11, 14, 17 ]
1414

1515
steps:
1616
- uses: actions/checkout@v2

.github/workflows/maven.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
java: [ 8, 11, 14 ]
13+
java: [ 11, 14, 17 ]
1414

1515
steps:
1616
- uses: actions/checkout@v2
@@ -38,7 +38,7 @@ jobs:
3838
mvn --no-transfer-progress -B install --file pom.xml
3939
export MY_JAVA_VERSION=`java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1`
4040
echo "JAVA VERSION" ${MY_JAVA_VERSION}
41-
if [[ ${MY_JAVA_VERSION} == "8" ]];
41+
if [[ ${MY_JAVA_VERSION} == "11" ]];
4242
then
4343
export MY_POM_VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
4444
echo "POM VERSION" ${MY_POM_VERSION}

.github/workflows/next-snapshot.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
uses: actions/setup-python@v2
2121
with:
2222
python-version: 2.7
23-
- name: Set up Java 8
23+
- name: Set up Java 11
2424
uses: actions/setup-java@v2
2525
with:
26-
java-version: 8
26+
java-version: 11
2727
distribution: 'zulu'
2828
server-id: ossrh
2929
server-username: MAVEN_USERNAME

.github/workflows/prepare-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
uses: actions/setup-python@v2
2121
with:
2222
python-version: 2.7
23-
- name: Set up Java 8
23+
- name: Set up Java 11
2424
uses: actions/setup-java@v2
2525
with:
26-
java-version: 8
26+
java-version: 11
2727
distribution: 'zulu'
2828
server-id: ossrh
2929
server-username: MAVEN_USERNAME

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
uses: actions/setup-python@v2
2121
with:
2222
python-version: 2.7
23-
- name: Set up Java 8
23+
- name: Set up Java 11
2424
uses: actions/setup-java@v2
2525
with:
26-
java-version: 8
26+
java-version: 11
2727
distribution: 'zulu'
2828
server-id: ossrh
2929
server-username: MAVEN_USERNAME

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**NOTE:** Since version 2.1.0 Swagger Parser supports OpenAPI 3.1; see [this page](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---OpenAPI-3.1) for details
66

7-
![Build Master - Java 8, 11, and 14](https://github.com/swagger-api/swagger-parser/workflows/Build%20Test%20Deploy%20master/badge.svg?branch=master)
7+
![Build Master - Java 11, 14 and 17](https://github.com/swagger-api/swagger-parser/workflows/Build%20Test%20Deploy%20master/badge.svg?branch=master)
88

99
# Table of contents
1010

@@ -121,7 +121,7 @@ You can include this library from Sonatype OSS for SNAPSHOTS, or Maven central f
121121
#### Prerequisites
122122
You need the following installed and available in your $PATH:
123123

124-
* [Java 1.8](http://java.oracle.com)
124+
* Java 11
125125
* [Apache maven 3.x](http://maven.apache.org/)
126126

127127
After cloning the project, you can build it from source with this command:

modules/swagger-parser-cli/pom.xml

+36-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,28 @@
2626
</resource>
2727
</resources>
2828
<plugins>
29+
<plugin>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-surefire-plugin</artifactId>
32+
<version>${surefire-version}</version>
33+
<configuration>
34+
<testNGArtifactName>none:none</testNGArtifactName>
35+
<argLine>-javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit-version}/jmockit-${jmockit-version}.jar --add-opens java.base/java.lang=ALL-UNNAMED -Djdk.attach.allowAttachSelf</argLine>
36+
</configuration>
37+
<executions>
38+
<execution>
39+
<id>test-testng</id>
40+
<phase>test</phase>
41+
<goals>
42+
<goal>test</goal>
43+
</goals>
44+
<configuration>
45+
<junitArtifactName>none:none</junitArtifactName>
46+
<testNGArtifactName>org.testng:testng</testNGArtifactName>
47+
</configuration>
48+
</execution>
49+
</executions>
50+
</plugin>
2951
<plugin>
3052
<groupId>org.apache.maven.plugins</groupId>
3153
<artifactId>maven-jar-plugin</artifactId>
@@ -40,7 +62,7 @@
4062
<plugin>
4163
<groupId>org.apache.maven.plugins</groupId>
4264
<artifactId>maven-shade-plugin</artifactId>
43-
<version>2.3</version>
65+
<version>3.3.0</version>
4466
<executions>
4567
<execution>
4668
<id>process-resources</id>
@@ -73,8 +95,10 @@
7395
<scope>compile</scope>
7496
</dependency>
7597
<dependency>
76-
<groupId>org.testng</groupId>
77-
<artifactId>testng</artifactId>
98+
<groupId>junit</groupId>
99+
<artifactId>junit</artifactId>
100+
<version>${junit-version}</version>
101+
<scope>test</scope>
78102
</dependency>
79103
<dependency>
80104
<groupId>net.sourceforge.argparse4j</groupId>
@@ -84,13 +108,16 @@
84108
<dependency>
85109
<groupId>org.slf4j</groupId>
86110
<artifactId>slf4j-simple</artifactId>
87-
<version>2.0.0</version>
111+
<version>${slf4j-version}</version>
112+
<scope>test</scope>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.testng</groupId>
116+
<artifactId>testng</artifactId>
117+
<version>${testng-version}</version>
118+
<scope>test</scope>
88119
</dependency>
89120
</dependencies>
90121

91-
<properties>
92-
<maven.compiler.source>8</maven.compiler.source>
93-
<maven.compiler.target>8</maven.compiler.target>
94-
</properties>
95122

96-
</project>
123+
</project>

modules/swagger-parser-v2-converter/pom.xml

+33-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,32 @@
1010
<artifactId>swagger-parser-v2-converter</artifactId>
1111
<packaging>jar</packaging>
1212
<name>swagger-parser-v2-converter</name>
13-
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<groupId>org.apache.maven.plugins</groupId>
17+
<artifactId>maven-surefire-plugin</artifactId>
18+
<version>${surefire-version}</version>
19+
<configuration>
20+
<testNGArtifactName>none:none</testNGArtifactName>
21+
<argLine>-javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit-version}/jmockit-${jmockit-version}.jar --add-opens java.base/java.lang=ALL-UNNAMED -Djdk.attach.allowAttachSelf</argLine>
22+
</configuration>
23+
<executions>
24+
<execution>
25+
<id>test-testng</id>
26+
<phase>test</phase>
27+
<goals>
28+
<goal>test</goal>
29+
</goals>
30+
<configuration>
31+
<junitArtifactName>none:none</junitArtifactName>
32+
<testNGArtifactName>org.testng:testng</testNGArtifactName>
33+
</configuration>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
</plugins>
38+
</build>
1439
<dependencies>
1540
<dependency>
1641
<groupId>io.swagger</groupId>
@@ -75,7 +100,13 @@
75100
<dependency>
76101
<groupId>org.testng</groupId>
77102
<artifactId>testng</artifactId>
78-
<version>6.9.10</version>
103+
<version>${testng-version}</version>
104+
<scope>test</scope>
105+
</dependency>
106+
<dependency>
107+
<groupId>junit</groupId>
108+
<artifactId>junit</artifactId>
109+
<version>${junit-version}</version>
79110
<scope>test</scope>
80111
</dependency>
81112
</dependencies>

modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.swagger.parser.test;
22

3-
import io.swagger.util.Yaml;
43
import io.swagger.v3.core.util.Json;
54
import io.swagger.v3.oas.models.OpenAPI;
65
import io.swagger.v3.oas.models.Operation;

modules/swagger-parser-v3/pom.xml

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<artifactId>swagger-parser-v3</artifactId>
1111
<packaging>jar</packaging>
1212
<name>swagger-parser-v3</name>
13-
<build>
14-
</build>
1513
<dependencies>
1614
<dependency>
1715
<groupId>io.swagger.core.v3</groupId>
@@ -61,7 +59,7 @@
6159
<dependency>
6260
<groupId>org.testng</groupId>
6361
<artifactId>testng</artifactId>
64-
<version>6.9.10</version>
62+
<version>${testng-version}</version>
6563
<scope>test</scope>
6664
</dependency>
6765
<dependency>
@@ -73,10 +71,9 @@
7371
<dependency>
7472
<groupId>com.github.tomakehurst</groupId>
7573
<artifactId>wiremock</artifactId>
76-
<version>1.57</version>
74+
<version>${wiremock-version}</version>
7775
<scope>test</scope>
7876

79-
<classifier>standalone</classifier>
8077
<exclusions>
8178
<exclusion>
8279
<groupId>*</groupId>
@@ -87,6 +84,8 @@
8784
<dependency>
8885
<groupId>junit</groupId>
8986
<artifactId>junit</artifactId>
87+
<version>${junit-version}</version>
88+
<scope>test</scope>
9089
</dependency>
9190
</dependencies>
9291
</project>

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/DeserializationUtils.java

+24-15
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,34 @@ public static boolean isJson(String contents) {
194194
return contents.toString().trim().startsWith("{");
195195
}
196196

197+
public static LoaderOptions buildLoaderOptions() {
198+
LoaderOptions loaderOptions = new LoaderOptions();
199+
try {
200+
Method method = LoaderOptions.class.getMethod("setMaxAliasesForCollections", int.class);
201+
method.invoke(loaderOptions, options.getMaxYamlAliasesForCollections());
202+
method = LoaderOptions.class.getMethod("setAllowRecursiveKeys", boolean.class);
203+
method.invoke(loaderOptions, options.isYamlAllowRecursiveKeys());
204+
} catch (ReflectiveOperationException e) {
205+
LOGGER.debug("using snakeyaml < 1.25, not setting YAML Billion Laughs Attack snakeyaml level protection");
206+
}
207+
return loaderOptions;
208+
}
209+
197210
public static JsonNode readYamlTree(String contents) {
198211
return readYamlTree(contents, null, new SwaggerParseResult());
199212
}
200213
public static JsonNode readYamlTree(String contents, ParseOptions parseOptions, SwaggerParseResult deserializationUtilsResult) {
201214

202215
if (parseOptions != null && parseOptions.isLegacyYamlDeserialization()) {
203-
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
216+
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor(buildLoaderOptions()));
204217
return Json.mapper().convertValue(yaml.load(contents), JsonNode.class);
205218
}
206219
try {
207220
org.yaml.snakeyaml.Yaml yaml = null;
208221
if (options.isValidateYamlInput()) {
209222
yaml = buildSnakeYaml(new CustomSnakeYamlConstructor());
210223
} else {
211-
yaml = buildSnakeYaml(new SafeConstructor());
224+
yaml = buildSnakeYaml(new SafeConstructor(buildLoaderOptions()));
212225
}
213226
Object o = yaml.load(contents);
214227
if (options.isValidateYamlInput()) {
@@ -244,7 +257,7 @@ public static <T> T readYamlValue(String contents, Class<T> expectedType) {
244257
return readYamlValue(contents, expectedType, false);
245258
}
246259
public static <T> T readYamlValue(String contents, Class<T> expectedType, boolean openapi31) {
247-
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
260+
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor(buildLoaderOptions()));
248261
ObjectMapper jsonMapper = openapi31 ? Json31.mapper() : Json.mapper();
249262
return jsonMapper.convertValue(yaml.load(contents), expectedType);
250263
}
@@ -256,20 +269,12 @@ public static org.yaml.snakeyaml.Yaml buildSnakeYaml(BaseConstructor constructor
256269
return new org.yaml.snakeyaml.Yaml(constructor);
257270
}
258271
try {
259-
LoaderOptions loaderOptions = new LoaderOptions();
260-
Method method = LoaderOptions.class.getMethod("setMaxAliasesForCollections", int.class);
261-
method.invoke(loaderOptions, options.getMaxYamlAliasesForCollections());
262-
method = LoaderOptions.class.getMethod("setAllowRecursiveKeys", boolean.class);
263-
method.invoke(loaderOptions, options.isYamlAllowRecursiveKeys());
264-
method = LoaderOptions.class.getMethod("setAllowDuplicateKeys", boolean.class);
265-
method.invoke(loaderOptions, false);
266-
method = LoaderOptions.class.getMethod("setCodePointLimit", int.class);
267-
method.invoke(loaderOptions, options.getMaxYamlCodePoints());
268-
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(constructor, new Representer(), new DumperOptions(), loaderOptions, new CustomResolver());
272+
LoaderOptions loaderOptions = buildLoaderOptions();
273+
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(constructor, new Representer(new DumperOptions()), new DumperOptions(), loaderOptions, new CustomResolver());
269274
return yaml;
270-
} catch (ReflectiveOperationException e) {
275+
} catch (Exception e) {
271276
//
272-
LOGGER.debug("using snakeyaml < 1.25, not setting YAML Billion Laughs Attack snakeyaml level protection");
277+
LOGGER.error("error building snakeYaml", e);
273278
}
274279
return new org.yaml.snakeyaml.Yaml(constructor);
275280
}
@@ -396,6 +401,10 @@ public SnakeException(String message, Throwable cause) {
396401

397402
static class CustomSnakeYamlConstructor extends SafeConstructor {
398403

404+
public CustomSnakeYamlConstructor() {
405+
super(buildLoaderOptions());
406+
}
407+
399408
private boolean checkNode(MappingNode node, Integer depth) {
400409
if (node.getValue() == null) return true;
401410
if (depth > options.getMaxYamlDepth()) return false;

0 commit comments

Comments
 (0)