Skip to content

Commit 063a780

Browse files
authored
Removed unnecessary cast to HttpClientErrorException as both classes in the catch extend HttpStatusCodeException (#22849)
1 parent b443080 commit 063a780

File tree

9 files changed

+9
-27
lines changed
  • modules/openapi-generator/src/main/resources/Java/libraries/resttemplate
  • samples/client
    • echo_api/java/resttemplate/src/main/java/org/openapitools/client
    • others/java
      • resttemplate-list-schema-validation/src/main/java/org/openapitools/client
      • resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client
    • petstore/java
      • resttemplate-jakarta/src/main/java/org/openapitools/client
      • resttemplate-swagger1/src/main/java/org/openapitools/client
      • resttemplate-swagger2/src/main/java/org/openapitools/client
      • resttemplate-withXml/src/main/java/org/openapitools/client
      • resttemplate/src/main/java/org/openapitools/client

9 files changed

+9
-27
lines changed

modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
784784
break;
785785
} catch (HttpServerErrorException | HttpClientErrorException ex) {
786786
if (ex instanceof HttpServerErrorException
787-
|| ((HttpClientErrorException) ex)
788-
.getStatusCode()
789-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
787+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
790788
attempts++;
791789
if (attempts < maxAttemptsForRetry) {
792790
try {

samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
701701
break;
702702
} catch (HttpServerErrorException | HttpClientErrorException ex) {
703703
if (ex instanceof HttpServerErrorException
704-
|| ((HttpClientErrorException) ex)
705-
.getStatusCode()
706-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
704+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
707705
attempts++;
708706
if (attempts < maxAttemptsForRetry) {
709707
try {

samples/client/others/java/resttemplate-list-schema-validation/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
644644
break;
645645
} catch (HttpServerErrorException | HttpClientErrorException ex) {
646646
if (ex instanceof HttpServerErrorException
647-
|| ((HttpClientErrorException) ex)
648-
.getStatusCode()
649-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
647+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
650648
attempts++;
651649
if (attempts < maxAttemptsForRetry) {
652650
try {

samples/client/others/java/resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
644644
break;
645645
} catch (HttpServerErrorException | HttpClientErrorException ex) {
646646
if (ex instanceof HttpServerErrorException
647-
|| ((HttpClientErrorException) ex)
648-
.getStatusCode()
649-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
647+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
650648
attempts++;
651649
if (attempts < maxAttemptsForRetry) {
652650
try {

samples/client/petstore/java/resttemplate-jakarta/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
702702
break;
703703
} catch (HttpServerErrorException | HttpClientErrorException ex) {
704704
if (ex instanceof HttpServerErrorException
705-
|| ((HttpClientErrorException) ex)
706-
.getStatusCode()
707-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
705+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
708706
attempts++;
709707
if (attempts < maxAttemptsForRetry) {
710708
try {

samples/client/petstore/java/resttemplate-swagger1/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
702702
break;
703703
} catch (HttpServerErrorException | HttpClientErrorException ex) {
704704
if (ex instanceof HttpServerErrorException
705-
|| ((HttpClientErrorException) ex)
706-
.getStatusCode()
707-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
705+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
708706
attempts++;
709707
if (attempts < maxAttemptsForRetry) {
710708
try {

samples/client/petstore/java/resttemplate-swagger2/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
702702
break;
703703
} catch (HttpServerErrorException | HttpClientErrorException ex) {
704704
if (ex instanceof HttpServerErrorException
705-
|| ((HttpClientErrorException) ex)
706-
.getStatusCode()
707-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
705+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
708706
attempts++;
709707
if (attempts < maxAttemptsForRetry) {
710708
try {

samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
765765
break;
766766
} catch (HttpServerErrorException | HttpClientErrorException ex) {
767767
if (ex instanceof HttpServerErrorException
768-
|| ((HttpClientErrorException) ex)
769-
.getStatusCode()
770-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
768+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
771769
attempts++;
772770
if (attempts < maxAttemptsForRetry) {
773771
try {

samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,7 @@ public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<Strin
760760
break;
761761
} catch (HttpServerErrorException | HttpClientErrorException ex) {
762762
if (ex instanceof HttpServerErrorException
763-
|| ((HttpClientErrorException) ex)
764-
.getStatusCode()
765-
.equals(HttpStatus.TOO_MANY_REQUESTS)) {
763+
|| ex.getStatusCode().equals(HttpStatus.TOO_MANY_REQUESTS)) {
766764
attempts++;
767765
if (attempts < maxAttemptsForRetry) {
768766
try {

0 commit comments

Comments
 (0)