Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit fe6e1e0

Browse files
Marek PotociarGerrit Code Review
authored andcommitted
Merge "ValidationResult test: removed unused utility method, fixed setter lookup (no need to do lookup in superclass since we do not deal with dynamic proxies any more)"
2 parents 3cefff8 + f9a7cd2 commit fe6e1e0

File tree

1 file changed

+3
-40
lines changed

1 file changed

+3
-40
lines changed

tests/integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/ValidationResultUtil.java

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -136,45 +136,8 @@ public static void updateValidationResultProperty(Object resource, Method getter
136136
}
137137
setViolations.invoke(obj, constraints);
138138

139-
final Method currentSetter = getValidationResultSetter(resource);
140-
final Method parentSetter = getValidationResultSetter(resource.getClass().getSuperclass());
141-
142-
final Method effectiveSetter = (parentSetter != null) ? parentSetter : currentSetter;
143-
144-
if (effectiveSetter != null) {
145-
effectiveSetter.invoke(resource, obj);
146-
}
147-
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
148-
// ignore for now
149-
}
150-
}
151-
152-
/**
153-
* Updates a {@code javax.mvc.validation.ValidationResult} property. In pseudo-code:
154-
* <p/>
155-
* obj = getter.invoke(resource);
156-
* obj.setViolations(constraints);
157-
* setter.invoke(resource, obj);
158-
*
159-
* @param beanManager bean manager.
160-
* @param resource resource instance.
161-
* @param getter getter to be used.
162-
* @param constraints new set of constraints.
163-
*/
164-
public static void updateValidationResultPropertyViaBeanManager(BeanManager beanManager,
165-
Object resource, Method getter,
166-
Set<ConstraintViolation<?>> constraints) {
167-
try {
168-
final Object obj = getter.invoke(resource);
169-
Method setViolations;
170-
try {
171-
setViolations = obj.getClass().getMethod("setViolations", Set.class);
172-
} catch (NoSuchMethodException e) {
173-
setViolations = obj.getClass().getSuperclass().getMethod("setViolations", Set.class);
174-
}
175-
setViolations.invoke(obj, constraints);
176-
177139
final Method setter = getValidationResultSetter(resource);
140+
178141
if (setter != null) {
179142
setter.invoke(resource, obj);
180143
}
@@ -259,7 +222,7 @@ private static Method getValidationResultSetter(final Class<?> resourceClass) {
259222
private static boolean isValidationResultSetter(Method m) {
260223
return m.getName().startsWith("set") && m.getParameterTypes().length == 1
261224
&& m.getParameterTypes()[0].getName().equals(VALIDATION_RESULT)
262-
&& m.getReturnType() == Void.TYPE && Modifier.isPublic(m.getModifiers());
263-
// && m.getAnnotation(Inject.class) != null;
225+
&& m.getReturnType() == Void.TYPE && Modifier.isPublic(m.getModifiers())
226+
&& m.getAnnotation(Inject.class) != null;
264227
}
265228
}

0 commit comments

Comments
 (0)