Skip to content

Commit 8a20b4f

Browse files
committed
HV-1598 Fix the behavior of XML default-validated-executable-types
If NONE is present, it should be removed from the Set, rather than considering the Set as empty.
1 parent 1f34de5 commit 8a20b4f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

engine/src/main/java/org/hibernate/validator/internal/xml/config/BootstrapConfigurationImpl.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import javax.validation.BootstrapConfiguration;
1717
import javax.validation.executable.ExecutableType;
1818

19+
import org.hibernate.validator.internal.util.CollectionHelper;
1920
import org.hibernate.validator.internal.util.stereotypes.Immutable;
2021

2122
/**
@@ -109,15 +110,23 @@ private Set<ExecutableType> prepareValidatedExecutableTypes(EnumSet<ExecutableTy
109110
if ( validatedExecutableTypes == null ) {
110111
return DEFAULT_VALIDATED_EXECUTABLE_TYPES;
111112
}
113+
112114
if ( validatedExecutableTypes.contains( ExecutableType.ALL ) ) {
113115
return ALL_VALIDATED_EXECUTABLE_TYPES;
114116
}
115-
else if ( validatedExecutableTypes.contains( ExecutableType.NONE ) ) {
116-
return EnumSet.noneOf( ExecutableType.class );
117-
}
118-
else {
119-
return validatedExecutableTypes;
117+
118+
if ( validatedExecutableTypes.contains( ExecutableType.NONE ) ) {
119+
if ( validatedExecutableTypes.size() == 1 ) {
120+
return Collections.emptySet();
121+
}
122+
else {
123+
EnumSet<ExecutableType> preparedValidatedExecutableTypes = EnumSet.copyOf( validatedExecutableTypes );
124+
preparedValidatedExecutableTypes.remove( ExecutableType.NONE );
125+
return CollectionHelper.toImmutableSet( preparedValidatedExecutableTypes );
126+
}
120127
}
128+
129+
return CollectionHelper.toImmutableSet( validatedExecutableTypes );
121130
}
122131

123132
@Override

0 commit comments

Comments
 (0)