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

@Param fails on constructor if the bean has any validation constraints #372

Closed
NagyGa1 opened this Issue Apr 19, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@NagyGa1

NagyGa1 commented Apr 19, 2017

private static <V> Set<ConstraintViolation<?>> doBeanValidation(V paramValue, InjectionPoint injectionPoint) {

		Class<?> base = injectionPoint.getBean().getBeanClass();
		String property = injectionPoint.getMember().getName();
		Type type = injectionPoint.getType();

		// Check if the target property in which we are injecting in our special holder/wrapper type
		// ParamValue or not. If it's the latter, pre-wrap our value (otherwise types for bean validation
		// would not match)
		Object valueToValidate = paramValue;

		if (type instanceof ParameterizedType) {
			Type propertyRawType = ((ParameterizedType) type).getRawType();
			if (propertyRawType.equals(ParamValue.class)) {
				valueToValidate = new ParamValue<>(null, null, null, paramValue);
			}
		}

		return (Set) getBeanValidator().validateValue(base, property, valueToValidate);
	}

The problem is that the injectionPoint.getMember().getName() returns the bean's class name to the property instead of the parameter name, then getBeanValidator().validateValue(_) throws Invalid property path. There is no property com in entity com.cpox.view.product.ProductVersionBacking or the likes.

It does not happen if the bean does not have any properties annotated with validation constraints, because then validateValue(_) returns without doing anything.

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC May 20, 2017

Member

It's fixed for 2.6.3. You can try today's latest 2.6.3-SNAPSHOT.

Thank you for reporting!

Member

BalusC commented May 20, 2017

It's fixed for 2.6.3. You can try today's latest 2.6.3-SNAPSHOT.

Thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment