Throw and catch UnsupportedOperationException to fix XPathAttributeMapperTest

Closes #43262

Signed-off-by: rmartinc <rmartinc@redhat.com>
This commit is contained in:
rmartinc 2025-10-08 17:04:46 +02:00 committed by Marek Posolda
parent 0bfb9079f2
commit a19f4d00fc

View File

@ -65,10 +65,10 @@ public class XPathAttributeMapper extends AbstractIdentityProviderMapper impleme
private static final ThreadLocal<XPathFactory> XPATH_FACTORY = ThreadLocal.withInitial(() -> {
final XPathFactory xPathFactory = XPathFactory.newInstance();
xPathFactory.setXPathVariableResolver(variableName -> {
throw new RuntimeException("resolveVariable for variable " + variableName + " not supported");
throw new UnsupportedOperationException("resolveVariable for variable " + variableName + " not supported");
});
xPathFactory.setXPathFunctionResolver((functionName, arity) -> {
throw new RuntimeException("resolveFunction for function " + functionName + " not supported");
throw new UnsupportedOperationException("resolveFunction for function " + functionName + " not supported");
});
return xPathFactory;
});
@ -212,7 +212,7 @@ public class XPathAttributeMapper extends AbstractIdentityProviderMapper impleme
});
Document document = DocumentUtil.getDocument(new StringReader(xml));
return xPath.compile(attributeXPath).evaluate(document, XPathConstants.STRING);
} catch (XPathExpressionException e) {
} catch (XPathExpressionException|UnsupportedOperationException e) {
LOGGER.warn("Unparsable element will be ignored", e);
return "";
} catch (Exception e) {