[#5561] Log warnings when users misconfigure forceType / customType elements
This commit is contained in:
parent
666b8cb2ea
commit
ee07ae3a85
@ -893,23 +893,33 @@ public abstract class AbstractDatabase implements Database {
|
||||
|
||||
if (StringUtils.isBlank(type.getName())) {
|
||||
if (StringUtils.isBlank(type.getUserType())) {
|
||||
StringWriter writer = new StringWriter();
|
||||
JAXB.marshal(type, writer);
|
||||
log.warn("Bad configuration for <forcedType/>. Either <name/> or <userType/> is required: " + writer.toString());
|
||||
log.warn("Bad configuration for <forcedType/>. Either <name/> or <userType/> is required: " + toString(type));
|
||||
|
||||
it2.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(type.getBinding()) && StringUtils.isBlank(type.getConverter())) {
|
||||
StringWriter writer = new StringWriter();
|
||||
JAXB.marshal(type, writer);
|
||||
log.warn("Bad configuration for <forcedType/>. Either <binding/> or <converter/> is required: " + writer);
|
||||
log.warn("Bad configuration for <forcedType/>. Either <binding/> or <converter/> is required: " + toString(type));
|
||||
|
||||
it2.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!StringUtils.isBlank(type.getUserType())) {
|
||||
log.warn("Bad configuration for <forcedType/>. <userType/> is not allowed when <name/> is provided: " + toString(type));
|
||||
type.setUserType(null);
|
||||
}
|
||||
if (!StringUtils.isBlank(type.getBinding())) {
|
||||
log.warn("Bad configuration for <forcedType/>. <binding/> is not allowed when <name/> is provided: " + toString(type));
|
||||
type.setBinding(null);
|
||||
}
|
||||
if (!StringUtils.isBlank(type.getConverter())) {
|
||||
log.warn("Bad configuration for <forcedType/>. <converter/> is not allowed when <name/> is provided: " + toString(type));
|
||||
type.setConverter(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (type.getUserType() != null && StringUtils.equals(type.getUserType(), typeName)) {
|
||||
return customType(this, type);
|
||||
@ -919,6 +929,12 @@ public abstract class AbstractDatabase implements Database {
|
||||
return null;
|
||||
}
|
||||
|
||||
private final String toString(ForcedType type) {
|
||||
StringWriter writer = new StringWriter();
|
||||
JAXB.marshal(type, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setConfiguredForcedTypes(List<ForcedType> configuredForcedTypes) {
|
||||
this.configuredForcedTypes = configuredForcedTypes;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user