Skip to content

Commit 26c17c5

Browse files
wing328jonfreedman
andauthored
[Java] remove deprecated jackson classes (#7304)
* [java/resttemplate] Generate valid code if no Authentication implementations present Take the logic used to decide which instances to add to the authentications map and re-use to not import classes or offer non-functional util methods * parameterize formParams fixes #5782 * replace use of ISO8601DateFormat and ISO8601Utils with StdDateFormat fixes #5779 * add constructor to intialise calendar * Revert "[java/resttemplate] Generate valid code if no Authentication implementations present" This reverts commit 6e45090. * Revert "parameterize formParams" This reverts commit 7a26ce5. * also override single arg parse method to avoid throwing exception * also override single arg parse method to avoid throwing exception * update samples * update samples * fix jersey1 tests * fix jersey2 test * update resteasy dependencies * fix java jersey2 oas3 tests * use java8 in springboot-beanvalidation Co-authored-by: Jon Freedman <[email protected]>
1 parent 892836f commit 26c17c5

File tree

81 files changed

+1564
-1446
lines changed

Some content is hidden

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

81 files changed

+1564
-1446
lines changed

bin/configs/spring-boot-beanvalidation.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ library: spring-boot
44
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
55
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
66
additionalProperties:
7-
java8: "false"
7+
java8: true
88
useBeanValidation: true
99
artifactId: spring-boot-beanvalidation
1010
hideGenerationTimestamp: "true"
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,44 @@
11
{{>licenseInfo}}
22
package {{invokerPackage}};
33

4-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
5-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
4+
import com.fasterxml.jackson.databind.util.StdDateFormat;
65

6+
import java.text.DateFormat;
77
import java.text.FieldPosition;
8+
import java.text.ParsePosition;
89
import java.util.Date;
10+
import java.util.GregorianCalendar;
11+
import java.util.TimeZone;
912

13+
public class RFC3339DateFormat extends DateFormat {
14+
private static final long serialVersionUID = 1L;
15+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1016
11-
public class RFC3339DateFormat extends ISO8601DateFormat {
17+
private final StdDateFormat fmt = new StdDateFormat()
18+
.withTimeZone(TIMEZONE_Z)
19+
.withColonInTimeZone(true);
20+
21+
public RFC3339DateFormat() {
22+
this.calendar = new GregorianCalendar();
23+
}
24+
25+
@Override
26+
public Date parse(String source) {
27+
return parse(source, new ParsePosition(0));
28+
}
29+
30+
@Override
31+
public Date parse(String source, ParsePosition pos) {
32+
return fmt.parse(source, pos);
33+
}
1234

13-
// Same as ISO8601DateFormat but serializing milliseconds.
1435
@Override
1536
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
16-
String value = ISO8601Utils.format(date, true);
17-
toAppendTo.append(value);
18-
return toAppendTo;
37+
return fmt.format(date, toAppendTo, fieldPosition);
1938
}
2039

40+
@Override
41+
public Object clone() {
42+
return this;
43+
}
2144
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
11
package {{apiPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.GregorianCalendar;
10+
import java.util.TimeZone;
811

9-
public class RFC3339DateFormat extends ISO8601DateFormat {
12+
public class RFC3339DateFormat extends DateFormat {
13+
private static final long serialVersionUID = 1L;
14+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1015
11-
// Same as ISO8601DateFormat but serializing milliseconds.
12-
@Override
13-
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14-
String value = ISO8601Utils.format(date, true);
15-
toAppendTo.append(value);
16-
return toAppendTo;
17-
}
16+
private final StdDateFormat fmt = new StdDateFormat()
17+
.withTimeZone(TIMEZONE_Z)
18+
.withColonInTimeZone(true);
1819
20+
public RFC3339DateFormat() {
21+
this.calendar = new GregorianCalendar();
22+
}
23+
24+
@Override
25+
public Date parse(String source, ParsePosition pos) {
26+
return fmt.parse(source, pos);
27+
}
28+
29+
@Override
30+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31+
return fmt.format(date, toAppendTo, fieldPosition);
32+
}
33+
34+
@Override
35+
public Object clone() {
36+
return this;
37+
}
1938
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
11
package {{invokerPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.GregorianCalendar;
10+
import java.util.TimeZone;
811

9-
public class RFC3339DateFormat extends ISO8601DateFormat {
12+
public class RFC3339DateFormat extends DateFormat {
13+
private static final long serialVersionUID = 1L;
14+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1015
11-
// Same as ISO8601DateFormat but serializing milliseconds.
12-
@Override
13-
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14-
String value = ISO8601Utils.format(date, true);
15-
toAppendTo.append(value);
16-
return toAppendTo;
17-
}
16+
private final StdDateFormat fmt = new StdDateFormat()
17+
.withTimeZone(TIMEZONE_Z)
18+
.withColonInTimeZone(true);
1819
20+
public RFC3339DateFormat() {
21+
this.calendar = new GregorianCalendar();
22+
}
23+
24+
@Override
25+
public Date parse(String source, ParsePosition pos) {
26+
return fmt.parse(source, pos);
27+
}
28+
29+
@Override
30+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31+
return fmt.format(date, toAppendTo, fieldPosition);
32+
}
33+
34+
@Override
35+
public Object clone() {
36+
return this;
37+
}
1938
}

modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/pom.mustache

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@
9898
<dependency>
9999
<groupId>org.jboss.resteasy</groupId>
100100
<artifactId>jaxrs-api</artifactId>
101-
<version>${resteasy-version}</version>
101+
<version>3.0.12.Final</version>
102102
<scope>provided</scope>
103103
</dependency>
104104
<dependency>
105105
<groupId>org.jboss.resteasy</groupId>
106106
<artifactId>resteasy-validator-provider-11</artifactId>
107-
<version>${resteasy-version}</version>
107+
<version>3.6.3.SP1</version>
108108
<scope>provided</scope>
109109
</dependency>
110110
<dependency>
@@ -129,7 +129,7 @@
129129
<dependency>
130130
<groupId>com.fasterxml.jackson.datatype</groupId>
131131
<artifactId>jackson-datatype-joda</artifactId>
132-
<version>2.9.9</version>
132+
<version>2.11.2</version>
133133
</dependency>
134134
<dependency>
135135
<groupId>joda-time</groupId>
@@ -190,7 +190,7 @@
190190
<properties>
191191
<swagger-core-version>1.5.22</swagger-core-version>
192192
<jetty-version>9.2.9.v20150224</jetty-version>
193-
<resteasy-version>3.0.11.Final</resteasy-version>
193+
<resteasy-version>3.13.0.Final</resteasy-version>
194194
<slf4j-version>1.6.3</slf4j-version>
195195
<junit-version>4.8.1</junit-version>
196196
<servlet-api-version>2.5</servlet-api-version>
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
package {{basePackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.GregorianCalendar;
10+
import java.util.TimeZone;
811

12+
public class RFC3339DateFormat extends DateFormat {
13+
private static final long serialVersionUID = 1L;
14+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
915
10-
public class RFC3339DateFormat extends ISO8601DateFormat {
16+
private final StdDateFormat fmt = new StdDateFormat()
17+
.withTimeZone(TIMEZONE_Z)
18+
.withColonInTimeZone(true);
1119
12-
private static final long serialVersionUID = 1L;
20+
public RFC3339DateFormat() {
21+
this.calendar = new GregorianCalendar();
22+
}
23+
24+
@Override
25+
public Date parse(String source, ParsePosition pos) {
26+
return fmt.parse(source, pos);
27+
}
1328

14-
// Same as ISO8601DateFormat but serializing milliseconds.
1529
@Override
1630
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
17-
String value = ISO8601Utils.format(date, true);
18-
toAppendTo.append(value);
19-
return toAppendTo;
31+
return fmt.format(date, toAppendTo, fieldPosition);
2032
}
2133

34+
@Override
35+
public Object clone() {
36+
return this;
37+
}
2238
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
package {{configPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.GregorianCalendar;
10+
import java.util.TimeZone;
811

12+
public class RFC3339DateFormat extends DateFormat {
13+
private static final long serialVersionUID = 1L;
14+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
915
10-
public class RFC3339DateFormat extends ISO8601DateFormat {
16+
private final StdDateFormat fmt = new StdDateFormat()
17+
.withTimeZone(TIMEZONE_Z)
18+
.withColonInTimeZone(true);
1119
12-
private static final long serialVersionUID = 1L;
20+
public RFC3339DateFormat() {
21+
this.calendar = new GregorianCalendar();
22+
}
23+
24+
@Override
25+
public Date parse(String source, ParsePosition pos) {
26+
return fmt.parse(source, pos);
27+
}
1328

14-
// Same as ISO8601DateFormat but serializing milliseconds.
1529
@Override
1630
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
17-
String value = ISO8601Utils.format(date, true);
18-
toAppendTo.append(value);
19-
return toAppendTo;
31+
return fmt.format(date, toAppendTo, fieldPosition);
2032
}
2133

34+
@Override
35+
public Object clone() {
36+
return this;
37+
}
2238
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
11
package {{apiPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.GregorianCalendar;
10+
import java.util.TimeZone;
811

9-
public class RFC3339DateFormat extends ISO8601DateFormat {
12+
public class RFC3339DateFormat extends DateFormat {
13+
private static final long serialVersionUID = 1L;
14+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1015
11-
// Same as ISO8601DateFormat but serializing milliseconds.
12-
@Override
13-
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14-
String value = ISO8601Utils.format(date, true);
15-
toAppendTo.append(value);
16-
return toAppendTo;
17-
}
16+
private final StdDateFormat fmt = new StdDateFormat()
17+
.withTimeZone(TIMEZONE_Z)
18+
.withColonInTimeZone(true);
1819
20+
public RFC3339DateFormat() {
21+
this.calendar = new GregorianCalendar();
22+
}
23+
24+
@Override
25+
public Date parse(String source, ParsePosition pos) {
26+
return fmt.parse(source, pos);
27+
}
28+
29+
@Override
30+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31+
return fmt.format(date, toAppendTo, fieldPosition);
32+
}
33+
34+
@Override
35+
public Object clone() {
36+
return this;
37+
}
1938
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
package {{basePackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.GregorianCalendar;
10+
import java.util.TimeZone;
811

12+
public class RFC3339DateFormat extends DateFormat {
13+
private static final long serialVersionUID = 1L;
14+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
915
10-
public class RFC3339DateFormat extends ISO8601DateFormat {
16+
private final StdDateFormat fmt = new StdDateFormat()
17+
.withTimeZone(TIMEZONE_Z)
18+
.withColonInTimeZone(true);
19+
20+
public RFC3339DateFormat() {
21+
this.calendar = new GregorianCalendar();
22+
}
23+
24+
@Override
25+
public Date parse(String source, ParsePosition pos) {
26+
return fmt.parse(source, pos);
27+
}
1128

12-
// Same as ISO8601DateFormat but serializing milliseconds.
1329
@Override
1430
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
15-
String value = ISO8601Utils.format(date, true);
16-
toAppendTo.append(value);
17-
return toAppendTo;
31+
return fmt.format(date, toAppendTo, fieldPosition);
1832
}
1933

34+
@Override
35+
public Object clone() {
36+
return this;
37+
}
2038
}

0 commit comments

Comments
 (0)