identityref types are required to be normalized as a QName, but we
have a legacy fallback to using .toString(). Issue an explicit
warning when this happens.
JIRA: YANGTOOLS-1110
Change-Id: Ia9cfc824e03d7641c7081f479f7a4d6c7c98062c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
package org.opendaylight.yangtools.yang.data.codec.xml;
import com.google.common.annotations.VisibleForTesting;
package org.opendaylight.yangtools.yang.data.codec.xml;
import com.google.common.annotations.VisibleForTesting;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import javax.xml.stream.XMLStreamException;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
import javax.xml.stream.XMLStreamException;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
*/
abstract class XMLStreamWriterUtils {
private static final Logger LOG = LoggerFactory.getLogger(XMLStreamWriterUtils.class);
*/
abstract class XMLStreamWriterUtils {
private static final Logger LOG = LoggerFactory.getLogger(XMLStreamWriterUtils.class);
+ /**
+ * Warn-once set of identityref nodes which were found to be normalized to a different object than a QName.
+ */
+ private static final Set<QName> IDENTITYREF_WARNED = ConcurrentHashMap.newKeySet();
/**
* Encode a value into a String in the context of a XML stream writer. This method assumes the start and end of
/**
* Encode a value into a String in the context of a XML stream writer. This method assumes the start and end of
}
final QName qname = type.getQName();
}
final QName qname = type.getQName();
- LOG.debug("Value of {}:{} is not a QName but {}", qname.getNamespace(), qname.getLocalName(), value.getClass());
+ if (IDENTITYREF_WARNED.add(qname)) {
+ LOG.warn("Value of {}:{} is not a QName but {}. Please the source of this data", qname.getNamespace(),
+ qname.getLocalName(), value.getClass(), new Throwable());
+ }
return value.toString();
}
return value.toString();
}