Author: hardy.ferentschik
Date: 2009-10-29 04:52:03 -0400 (Thu, 29 Oct 2009)
New Revision: 17876
Added:
validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/empty-my-interface-mapping.xml
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java
Log:
HV-263 added additional null check
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java 2009-10-29
07:23:12 UTC (rev 17875)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java 2009-10-29
08:52:03 UTC (rev 17876)
@@ -286,7 +286,7 @@
BeanMetaDataImpl<?> cachedMetaData = beanMetaDataCache.getBeanMetaData( clazz
);
List<ConstraintDescriptorImpl<?>> fieldMetaData;
boolean cachedFieldIsCascaded = false;
- if ( cachedMetaData != null ) {
+ if ( cachedMetaData != null && cachedMetaData.getMetaConstraintsAsMap().get(
clazz ) != null ) {
fieldMetaData = new ArrayList<ConstraintDescriptorImpl<?>>();
cachedFieldIsCascaded = cachedMetaData.getCascadedMembers().contains( field );
for ( MetaConstraint<?, ?> metaConstraint :
cachedMetaData.getMetaConstraintsAsMap().get( clazz ) ) {
@@ -356,7 +356,7 @@
BeanMetaDataImpl<?> cachedMetaData = beanMetaDataCache.getBeanMetaData( clazz
);
List<ConstraintDescriptorImpl<?>> methodMetaData;
boolean cachedMethodIsCascaded = false;
- if ( cachedMetaData != null ) {
+ if ( cachedMetaData != null && cachedMetaData.getMetaConstraintsAsMap().get(
clazz ) != null ) {
cachedMethodIsCascaded = cachedMetaData.getCascadedMembers().contains( method );
methodMetaData = new ArrayList<ConstraintDescriptorImpl<?>>();
for ( MetaConstraint<?, ?> metaConstraint :
cachedMetaData.getMetaConstraintsAsMap().get( clazz ) ) {
@@ -412,7 +412,7 @@
// HV-262
BeanMetaDataImpl<?> cachedMetaData = beanMetaDataCache.getBeanMetaData( clazz );
List<ConstraintDescriptorImpl<?>> classMetaData;
- if ( cachedMetaData != null ) {
+ if ( cachedMetaData != null && cachedMetaData.getMetaConstraintsAsMap().get(
clazz ) != null ) {
classMetaData = new ArrayList<ConstraintDescriptorImpl<?>>();
for ( MetaConstraint<?, ?> metaConstraint :
cachedMetaData.getMetaConstraintsAsMap().get( clazz ) ) {
ConstraintDescriptorImpl<?> descriptor = metaConstraint.getDescriptor();
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java 2009-10-29
07:23:12 UTC (rev 17875)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java 2009-10-29
08:52:03 UTC (rev 17876)
@@ -107,4 +107,20 @@
assertEquals( violations.size(), 1);
}
+
+ @Test
+ /**
+ * HV-263
+ */
+ public void testEmptyInterfaceConfiguration() {
+
+ final Configuration<?> configuration =
Validation.byDefaultProvider().configure();
+ configuration.addMapping( XmlMappingTest.class.getResourceAsStream(
"empty-my-interface-mapping.xml" ) );
+
+ final ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
+ final Validator validator = validatorFactory.getValidator();
+ final Set<ConstraintViolation<MyInterfaceImpl>> violations =
validator.validate( new MyInterfaceImpl());
+
+ assertEquals( violations.size(), 0);
+ }
}
Added:
validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/empty-my-interface-mapping.xml
===================================================================
---
validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/empty-my-interface-mapping.xml
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/empty-my-interface-mapping.xml 2009-10-29
08:52:03 UTC (rev 17876)
@@ -0,0 +1,7 @@
+<constraint-mappings
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping
validation-mapping-1.0.xsd"
+
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+ <default-package>org.hibernate.validator.xml</default-package>
+ <bean class="MyInterface" ignore-annotations="true">
+ </bean>
+</constraint-mappings>
\ No newline at end of file