Skip to content

Commit 7633f49

Browse files
committed
migrate to java 17
changes: - update maven-compiler-plugin to latest 3.14.1 - update maven-javadoc-plugin to latest 3.12.0 - update jacoco-maven-plugin to latest 0.8.14 - set maven.compiler.release to 17 - set source to 17 and update link to javadoc for maven-javadoc-plugin configuration - set java-version to 17 in github workflows - set java version to 17 in swagger-gradle-plugin - replace String.format with "str".formatted - replace casts with pattern variables - add @serial to serialVersionUID fields - replace regular string literals with text blocks in tests - replace Paths.get with Path.of - replace new Integer with Integer.valueOf
1 parent b313104 commit 7633f49

120 files changed

Lines changed: 11764 additions & 11225 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Set up Java
3838
uses: actions/setup-java@v1
3939
with:
40-
java-version: 11
40+
java-version: 17
4141
# Initializes the CodeQL tools for scanning.
4242
- name: Initialize CodeQL
4343
uses: github/codeql-action/init@v3

.github/workflows/prepare-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
uses: actions/setup-python@v4
2121
with:
2222
python-version: '3.10'
23-
- name: Set up Java 11
23+
- name: Set up Java 17
2424
uses: actions/setup-java@v4
2525
with:
26-
java-version: 11
26+
java-version: 17
2727
distribution: temurin
2828
server-id: central
2929
server-username: MAVEN_USERNAME

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
uses: actions/setup-python@v4
2121
with:
2222
python-version: '3.10'
23-
- name: Set up Java 11
23+
- name: Set up Java 17
2424
uses: actions/setup-java@v4
2525
with:
26-
java-version: 11
26+
java-version: 17
2727
distribution: temurin
2828
server-id: central
2929
server-username: MAVEN_USERNAME

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ If you're interested in the change history of swagger and the Swagger Core frame
129129
### Prerequisites
130130
You need the following installed and available in your $PATH:
131131

132-
* Java 11
132+
* Java 17
133133
* Apache maven 3.0.4 or greater
134134
* Jackson 2.4.5 or greater
135135

modules/swagger-core/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
<dependency>
5656
<groupId>jakarta.xml.bind</groupId>
5757
<artifactId>jakarta.xml.bind-api</artifactId>
58-
<version>2.3.3</version>
5958
</dependency>
6059
<dependency>
6160
<groupId>org.apache.commons</groupId>
@@ -121,6 +120,12 @@
121120
<artifactId>logback-core</artifactId>
122121
<scope>provided</scope>
123122
</dependency>
123+
<dependency>
124+
<groupId>jakarta.annotation</groupId>
125+
<artifactId>jakarta.annotation-api</artifactId>
126+
<version>1.3.5</version>
127+
<scope>provided</scope>
128+
</dependency>
124129
<dependency>
125130
<groupId>jakarta.validation</groupId>
126131
<artifactId>jakarta.validation-api</artifactId>

modules/swagger-core/src/main/java/io/swagger/v3/core/converter/ModelConverterContextImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void defineModel(String name, Schema model, Type type, String prevName) {
5555
@Override
5656
public void defineModel(String name, Schema model, AnnotatedType type, String prevName) {
5757
if (LOGGER.isTraceEnabled()) {
58-
LOGGER.trace(String.format("defineModel %s %s", name, model));
58+
LOGGER.trace("defineModel %s %s".formatted(name, model));
5959
}
6060
modelByName.put(name, model);
6161

@@ -87,7 +87,7 @@ public Schema resolve(AnnotatedType type) {
8787
processedTypes.add(type);
8888
}
8989
if (LOGGER.isDebugEnabled()) {
90-
LOGGER.debug(String.format("resolve %s", type.getType()));
90+
LOGGER.debug("resolve %s".formatted(type.getType()));
9191
}
9292
Iterator<ModelConverter> converters = this.getConverters();
9393
Schema resolved = null;

modules/swagger-core/src/main/java/io/swagger/v3/core/filter/SpecFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ private void addSchemaRef(Schema schema, Set<String> referencedDefinitions) {
330330
}
331331
}
332332

333-
if (schema instanceof ArraySchema &&
334-
((ArraySchema) schema).getItems() != null) {
335-
addSchemaRef(((ArraySchema) schema).getItems(), referencedDefinitions);
333+
if (schema instanceof ArraySchema arraySchema &&
334+
arraySchema.getItems() != null) {
335+
addSchemaRef(arraySchema.getItems(), referencedDefinitions);
336336
} else if (schema.getTypes() != null && schema.getTypes().contains("array") && schema.getItems() != null) {
337337
addSchemaRef(schema.getItems(), referencedDefinitions);
338338
} else {

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ExampleSerializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public ExampleSerializer(JsonSerializer<Object> serializer) {
1919

2020
@Override
2121
public void resolve(SerializerProvider serializerProvider) throws JsonMappingException {
22-
if (defaultSerializer instanceof ResolvableSerializer) {
23-
((ResolvableSerializer) defaultSerializer).resolve(serializerProvider);
22+
if (defaultSerializer instanceof ResolvableSerializer serializer) {
23+
serializer.resolve(serializerProvider);
2424
}
2525
}
2626

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/MediaTypeSerializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public MediaTypeSerializer(JsonSerializer<Object> serializer) {
1919

2020
@Override
2121
public void resolve(SerializerProvider serializerProvider) throws JsonMappingException {
22-
if (defaultSerializer instanceof ResolvableSerializer) {
23-
((ResolvableSerializer) defaultSerializer).resolve(serializerProvider);
22+
if (defaultSerializer instanceof ResolvableSerializer serializer) {
23+
serializer.resolve(serializerProvider);
2424
}
2525
}
2626

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
179179
final io.swagger.v3.oas.annotations.media.Schema resolvedSchemaAnnotation =
180180
resolvedSchemaOrArrayAnnotation == null ?
181181
null :
182-
resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema ?
183-
((io.swagger.v3.oas.annotations.media.ArraySchema) resolvedSchemaOrArrayAnnotation).schema() :
182+
resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema as1 ?
183+
as1.schema() :
184184
(io.swagger.v3.oas.annotations.media.Schema) resolvedSchemaOrArrayAnnotation;
185185

186186
final io.swagger.v3.oas.annotations.media.ArraySchema resolvedArrayAnnotation =
187187
resolvedSchemaOrArrayAnnotation == null ?
188188
null :
189-
resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema ?
190-
(io.swagger.v3.oas.annotations.media.ArraySchema) resolvedSchemaOrArrayAnnotation :
189+
resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema as1 ?
190+
as1 :
191191
null;
192192

193193
final BeanDescription beanDesc;
@@ -551,8 +551,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
551551
if (annotatedType.isSchemaProperty() && annotatedType.getCtxAnnotations() != null && annotatedType.getCtxAnnotations().length > 0) {
552552
if (!"object".equals(items.getType())) {
553553
for (Annotation annotation : annotatedType.getCtxAnnotations()) {
554-
if (annotation instanceof XmlElement) {
555-
XmlElement xmlElement = (XmlElement) annotation;
554+
if (annotation instanceof XmlElement xmlElement) {
556555
if (xmlElement != null && xmlElement.name() != null && !"".equals(xmlElement.name()) && !JAXB_DEFAULT.equals(xmlElement.name())) {
557556
XML xml = items.getXml() != null ? items.getXml() : new XML();
558557
xml.setName(xmlElement.name());
@@ -714,8 +713,8 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
714713

715714
JavaType propType = member.getType();
716715
if (propType != null && "void".equals(propType.getRawClass().getName())) {
717-
if (member instanceof AnnotatedMethod) {
718-
propType = ((AnnotatedMethod) member).getParameterType(0);
716+
if (member instanceof AnnotatedMethod method) {
717+
propType = method.getParameterType(0);
719718
}
720719

721720
}
@@ -744,8 +743,8 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
744743
final io.swagger.v3.oas.annotations.media.Schema propResolvedSchemaAnnotation =
745744
propSchemaOrArray == null ?
746745
null :
747-
propSchemaOrArray instanceof io.swagger.v3.oas.annotations.media.ArraySchema ?
748-
((io.swagger.v3.oas.annotations.media.ArraySchema) propSchemaOrArray).arraySchema() :
746+
propSchemaOrArray instanceof io.swagger.v3.oas.annotations.media.ArraySchema as1 ?
747+
as1.arraySchema() :
749748
(io.swagger.v3.oas.annotations.media.Schema) propSchemaOrArray;
750749

751750
io.swagger.v3.oas.annotations.media.Schema.AccessMode accessMode = resolveAccessMode(propDef, type, propResolvedSchemaAnnotation);
@@ -2423,8 +2422,8 @@ protected Object resolveDefaultValue(Annotated a, Annotation[] annotations, io.s
24232422
if (elem == null) {
24242423
if (annotations != null) {
24252424
for (Annotation ann : annotations) {
2426-
if (ann instanceof XmlElement) {
2427-
elem = (XmlElement) ann;
2425+
if (ann instanceof XmlElement element) {
2426+
elem = element;
24282427
break;
24292428
}
24302429
}
@@ -2476,8 +2475,8 @@ protected io.swagger.v3.oas.annotations.media.Schema.AccessMode resolveAccessMod
24762475
return null;
24772476
}
24782477
JsonProperty.Access access = null;
2479-
if (propDef instanceof POJOPropertyBuilder) {
2480-
access = ((POJOPropertyBuilder) propDef).findAccess();
2478+
if (propDef instanceof POJOPropertyBuilder builder) {
2479+
access = builder.findAccess();
24812480
}
24822481
boolean hasGetter = propDef.hasGetter();
24832482
boolean hasSetter = propDef.hasSetter();
@@ -2489,8 +2488,8 @@ protected io.swagger.v3.oas.annotations.media.Schema.AccessMode resolveAccessMod
24892488
List<BeanPropertyDefinition> properties = beanDesc.findProperties();
24902489
for (BeanPropertyDefinition prop : properties) {
24912490
if (StringUtils.isNotBlank(prop.getInternalName()) && prop.getInternalName().equals(propDef.getInternalName())) {
2492-
if (prop instanceof POJOPropertyBuilder) {
2493-
access = ((POJOPropertyBuilder) prop).findAccess();
2491+
if (prop instanceof POJOPropertyBuilder builder) {
2492+
access = builder.findAccess();
24942493
}
24952494
hasGetter = hasGetter || prop.hasGetter();
24962495
hasSetter = hasSetter || prop.hasSetter();
@@ -2803,8 +2802,8 @@ protected XML resolveXml(Annotated a, Annotation[] annotations, io.swagger.v3.oa
28032802
if (rootAnnotation == null) {
28042803
if (annotations != null) {
28052804
for (Annotation ann : annotations) {
2806-
if (ann instanceof XmlRootElement) {
2807-
rootAnnotation = (XmlRootElement) ann;
2805+
if (ann instanceof XmlRootElement element) {
2806+
rootAnnotation = element;
28082807
break;
28092808
}
28102809
}
@@ -2847,9 +2846,9 @@ protected Set<String> resolveIgnoredProperties(Annotation[] annotations) {
28472846
Set<String> propertiesToIgnore = new HashSet<>();
28482847
if (annotations != null) {
28492848
for (Annotation annotation : annotations) {
2850-
if (annotation instanceof JsonIgnoreProperties) {
2851-
if (!((JsonIgnoreProperties) annotation).allowGetters()) {
2852-
propertiesToIgnore.addAll(Arrays.asList(((JsonIgnoreProperties) annotation).value()));
2849+
if (annotation instanceof JsonIgnoreProperties properties) {
2850+
if (!properties.allowGetters()) {
2851+
propertiesToIgnore.addAll(Arrays.asList(properties.value()));
28532852
break;
28542853
}
28552854
}
@@ -3118,8 +3117,8 @@ protected void resolveSchemaMembers(Schema schema, AnnotatedType annotatedType,
31183117
final io.swagger.v3.oas.annotations.media.Schema schemaAnnotation =
31193118
resolvedSchemaOrArrayAnnotation == null ?
31203119
null :
3121-
resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema ?
3122-
((io.swagger.v3.oas.annotations.media.ArraySchema) resolvedSchemaOrArrayAnnotation).schema() :
3120+
resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema as1 ?
3121+
as1.schema() :
31233122
(io.swagger.v3.oas.annotations.media.Schema) resolvedSchemaOrArrayAnnotation;
31243123

31253124
final BeanDescription beanDesc = _mapper.getSerializationConfig().introspect(type);
@@ -3388,14 +3387,12 @@ protected boolean updateRequiredItem(Schema model, String propName) {
33883387
}
33893388

33903389
protected boolean shouldIgnoreClass(Type type) {
3391-
if (type instanceof Class) {
3392-
Class<?> cls = (Class<?>) type;
3390+
if (type instanceof Class<?> cls) {
33933391
if (cls.getName().equals("javax.ws.rs.Response")) {
33943392
return true;
33953393
}
33963394
} else {
3397-
if (type instanceof com.fasterxml.jackson.core.type.ResolvedType) {
3398-
com.fasterxml.jackson.core.type.ResolvedType rt = (com.fasterxml.jackson.core.type.ResolvedType) type;
3395+
if (type instanceof com.fasterxml.jackson.core.type.ResolvedType rt) {
33993396
LOGGER.trace("Can't check class {}, {}", type, rt.getRawClass().getName());
34003397
if (rt.getRawClass().equals(Class.class)) {
34013398
return true;
@@ -3445,9 +3442,9 @@ protected boolean hiddenByJsonView(Annotation[] annotations,
34453442
Class<?>[] filters = jsonView.value();
34463443
boolean containsJsonViewAnnotation = !type.isIncludePropertiesWithoutJSONView();
34473444
for (Annotation ant : annotations) {
3448-
if (ant instanceof JsonView) {
3445+
if (ant instanceof JsonView view) {
34493446
containsJsonViewAnnotation = true;
3450-
Class<?>[] views = ((JsonView) ant).value();
3447+
Class<?>[] views = view.value();
34513448
for (Class<?> f : filters) {
34523449
for (Class<?> v : views) {
34533450
if (v == f || v.isAssignableFrom(f)) {

0 commit comments

Comments
 (0)