Skip to content

Commit

Permalink
fix : downgrade version and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Nov 23, 2023
1 parent 242cced commit 015a1a7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;
import java.util.Objects;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ProblemDetail;
Expand All @@ -12,7 +14,8 @@
import org.springframework.web.bind.annotation.ResponseStatus;

@ControllerAdvice
public class ErrorDetailProblemHandlingControllerAdvice {
@Order(Ordered.HIGHEST_PRECEDENCE)
public class GlobalExceptionHandler {

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
Expand All @@ -37,6 +40,5 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid
return problemDetail;
}

static record ApiValidationError(
String object, String field, Object rejectedValue, String message) {}
record ApiValidationError(String object, String field, Object rejectedValue, String message) {}
}
2 changes: 1 addition & 1 deletion boot-opensearch-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.1.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.opensearch</groupId>
Expand Down
2 changes: 1 addition & 1 deletion boot-rest-docs-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.1.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.restdocs</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.web.bind.annotation.ResponseStatus;

@ControllerAdvice
public class ErrorDetailProblemHandlingControllerAdvice {
public class GlobalExceptionHandler {

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
Expand All @@ -40,6 +40,5 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid
return problemDetail;
}

static record ApiValidationError(
String object, String field, Object rejectedValue, String message) {}
record ApiValidationError(String object, String field, Object rejectedValue, String message) {}
}
2 changes: 1 addition & 1 deletion httpClients/boot-web-client-webflux/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.1.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.rest.webclient</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.example.custom.sequence.exception;

import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ProblemDetail;
Expand All @@ -13,8 +14,9 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

@Order(Ordered.HIGHEST_PRECEDENCE)
@ControllerAdvice
public class ErrorDetailProblemHandlingControllerAdvice {
public class GlobalExceptionHandler {

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
Expand All @@ -32,28 +34,14 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid
fieldError.getObjectName(),
fieldError.getField(),
fieldError.getRejectedValue(),
Objects.requireNonNull(fieldError.getDefaultMessage()));
Objects.requireNonNull(
fieldError.getDefaultMessage(), ""));
})
.sorted(Comparator.comparing(ApiValidationError::field))
.toList();
problemDetail.setProperty("violations", validationErrorsList);
return problemDetail;
}

@Data
@AllArgsConstructor
static class ApiValidationError {

private String object;

private String field;

private Object rejectedValue;

private String message;

ApiValidationError(String object, String message) {
this.object = object;
this.message = message;
}
}
record ApiValidationError(String object, String field, Object rejectedValue, String message) {}
}
2 changes: 1 addition & 1 deletion jpa/boot-data-keyset-pagination/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.1.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.keysetpagination</groupId>
Expand Down

0 comments on commit 015a1a7

Please sign in to comment.