Skip to content

Commit

Permalink
Add diagnostics to null value serialization issue
Browse files Browse the repository at this point in the history
The message "Neither real nor raw value present in ..." that
occurs e.g. when dumping traces is hard to diagnose. This
experimental code dumps a bit of context to help with that.
  • Loading branch information
mederly committed Aug 31, 2021
1 parent c2f36b2 commit c37ee21
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.evolveum.midpoint.util.JAXBUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;
Expand Down Expand Up @@ -491,10 +492,32 @@ private <T> XNodeImpl serializePropertyRawValue(PrismPropertyValue<T> value) {
if (realValue != null) {
return createPrimitiveXNode(realValue, null);
} else {
LOGGER.error("Serialization error: neither real nor raw value present in {}", value);
dumpValuePath(value, 10);
throw new IllegalStateException("Neither real nor raw value present in " + value);
}
}

private <T> void dumpValuePath(PrismValue value, int levelsToDumpFully) {
if (levelsToDumpFully < 0) {
return;
}

LOGGER.error(" - #{}: {}: {}", levelsToDumpFully, value.getPath(), value);
Itemable parent = value.getParent();
if (!(parent instanceof PrismContainer<?>)) {
LOGGER.error(" --> parent is {}", parent);
return;
}

PrismContainerValue<?> grandparent = ((PrismContainer<?>) parent).getParent();
if (grandparent != null) {
dumpValuePath(grandparent, levelsToDumpFully - 1);
} else {
LOGGER.error(" --> grandparent is null");
}
}

private PrimitiveXNodeImpl<String> createPrimitiveXNodeStringAttr(String val) {
return createPrimitiveXNodeAttr(val, DOMUtil.XSD_STRING);
}
Expand Down

0 comments on commit c37ee21

Please sign in to comment.