Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve bug no tratamento de validação quando processa um Proxy Bean #114

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -26,8 +28,6 @@
import org.demoiselle.jee.rest.message.DemoiselleRESTMessage;

import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* Default implementation of All Exception Treatments in Demoiselle Framework.
Expand Down Expand Up @@ -87,7 +87,13 @@ public Response getFormatedError(Throwable exception, HttpServletRequest request
ConstraintViolationException c = (ConstraintViolationException) exception;

c.getConstraintViolations().stream().forEach((violation) -> {
String objectType = violation.getLeafBean().getClass().getSimpleName();
Object bean = violation.getLeafBean();
String objectType = bean.getClass().getSimpleName();
boolean isProxy = objectType.contains("$Proxy$");
// if it's a wrapped proxy object, get the original bean class that is the superclass
if(isProxy) {
objectType = bean.getClass().getSuperclass().getSimpleName();
}

// This is fixed because REST beans validations only accept ONE
// parameter
Expand Down