[#3704] Emit warning on conflict between <customType/> and type rewriting when <forcedType/> name is Boolean

This commit is contained in:
lukaseder 2017-07-21 12:58:23 +02:00
parent d78bb37e26
commit 247c3bc771
2 changed files with 10 additions and 5 deletions

View File

@ -996,8 +996,8 @@ public abstract class AbstractDatabase implements Database {
return null;
}
@SuppressWarnings({ "unchecked" })
static final String toString(ForcedType type) {
@SuppressWarnings({ "unchecked", "rawtypes" })
static final String toString(Object object) {
StringWriter writer = new StringWriter();
try {
@ -1165,10 +1165,10 @@ public abstract class AbstractDatabase implements Database {
}
};
JAXBContext ctx = JAXBContext.newInstance(ForcedType.class);
Class<ForcedType> clazz = (Class<ForcedType>) type.getClass();
Class<?> clazz = object.getClass();
JAXBContext ctx = JAXBContext.newInstance(clazz);
XmlRootElement r = clazz.getAnnotation(XmlRootElement.class);
Object o = r != null ? type : new JAXBElement<ForcedType>(new QName(Introspector.decapitalize(clazz.getSimpleName())), clazz, type);
Object o = r != null ? object : new JAXBElement(new QName(Introspector.decapitalize(clazz.getSimpleName())), clazz, object);
Marshaller m = ctx.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

View File

@ -200,6 +200,11 @@ abstract class AbstractTypedElementDefinition<T extends Definition>
// [#677] SQLDataType matches are actual type-rewrites
if (forcedDataType != null) {
// [#3704] When <forcedType/> matches a custom type AND a data type rewrite, the rewrite was usually accidental.
if (customType != null)
log.warn("Custom type conflict", child + " has custom type " + AbstractDatabase.toString(customType) + " forced by " + AbstractDatabase.toString(forcedType) + " but a data type rewrite applies");
result = new DefaultDataTypeDefinition(db, child.getSchema(), uType, l, p, s, n, d, (Name) null, converter, binding);
}