Skip to content

Commit

Permalink
[#3704] Emit warning on conflict between <customType/> and type rewri…
Browse files Browse the repository at this point in the history
…ting when <forcedType/> name is Boolean
  • Loading branch information
lukaseder committed Jul 21, 2017
1 parent d78bb37 commit 247c3bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions jOOQ-meta/src/main/java/org/jooq/util/AbstractDatabase.java
Expand Up @@ -996,8 +996,8 @@ public final CustomType getConfiguredCustomType(String typeName) {
return null;
}

@SuppressWarnings({ "unchecked" })
static final String toString(ForcedType type) {
@SuppressWarnings({ "unchecked", "rawtypes" })
static final String toString(Object object) {
StringWriter writer = new StringWriter();

try {
Expand Down Expand Up @@ -1165,10 +1165,10 @@ public Object getProperty(String name) throws IllegalArgumentException {
}
};

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);
Expand Down
Expand Up @@ -200,6 +200,11 @@ else if (!StringUtils.isBlank(customType.getConverter())) {

// [#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);
}

Expand Down

0 comments on commit 247c3bc

Please sign in to comment.