X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fimpl%2Fosgi%2FNetconfOperationRouterImpl.java;h=b1ab4b26de966af71f94fdeb8019d8eed1ebf04e;hb=a33c5a6dce59e7fde138a873500861b06116b3bc;hp=8a9acf07ee2fe98c406f857beb031a19090e5d56;hpb=cea637c7abbb8d132d8df30bc739ce041e0add8b;p=netconf.git
diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImpl.java b/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImpl.java
index 8a9acf07ee..b1ab4b26de 100644
--- a/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImpl.java
+++ b/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImpl.java
@@ -31,6 +31,8 @@ import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
import org.opendaylight.netconf.mapping.api.SessionAwareNetconfOperation;
import org.opendaylight.yangtools.yang.common.ErrorSeverity;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
+import org.opendaylight.yangtools.yang.common.ErrorType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -68,17 +70,31 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
final String messageAsString = XmlUtil.toString(message);
LOG.warn("Unable to handle rpc {} on session {}", messageAsString, session, e);
- final DocumentedException.ErrorTag tag;
- if (e instanceof IllegalArgumentException) {
- tag = DocumentedException.ErrorTag.OPERATION_NOT_SUPPORTED;
- } else {
- tag = DocumentedException.ErrorTag.OPERATION_FAILED;
- }
+ final ErrorTag tag = e instanceof IllegalArgumentException ? ErrorTag.OPERATION_NOT_SUPPORTED
+ : ErrorTag.OPERATION_FAILED;
throw new DocumentedException(
- String.format("Unable to handle rpc %s on session %s", messageAsString, session),
- e, DocumentedException.ErrorType.APPLICATION, tag, ErrorSeverity.ERROR,
- Map.of(tag.toString(), e.getMessage()));
+ String.format("Unable to handle rpc %s on session %s", messageAsString, session), e,
+ ErrorType.APPLICATION, tag, ErrorSeverity.ERROR,
+ // FIXME: i.e. in what namespace are we providing these tags? why is this not just:
+ //
+ //
+ // e.getMessage()
+ //
+ //
+ // for each place where we are mapping Exception.getMessage() ? We probably do not want to propagate
+ // stack traces out, but suppressed exceptions and causal list might be interesting:
+ //
+ //
+ // reported exception
+ //
+ //
+ // cause of reported exception
+ //
+ //
+ // cause of cause of reported exception
+ //
+ Map.of(tag.elementBody(), e.getMessage()));
} catch (final RuntimeException e) {
throw handleUnexpectedEx("sort", e);
}
@@ -98,10 +114,9 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
private static DocumentedException handleUnexpectedEx(final String op, final Exception exception) {
LOG.error("Unexpected exception during netconf operation {}", op, exception);
return new DocumentedException("Unexpected error",
- DocumentedException.ErrorType.APPLICATION,
- DocumentedException.ErrorTag.OPERATION_FAILED,
- ErrorSeverity.ERROR,
- Map.of(ErrorSeverity.ERROR.toString(), exception.toString()));
+ ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR,
+ // FIXME: i.e. exception.toString()? That looks wrong on a few levels.
+ Map.of(ErrorSeverity.ERROR.elementBody(), exception.toString()));
}
private static Document executeOperationWithHighestPriority(final Document message,
@@ -135,11 +150,11 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
for (final NetconfOperation netconfOperation : allNetconfOperations) {
final HandlingPriority handlingPriority = netconfOperation.canHandle(message);
- if (netconfOperation instanceof DefaultNetconfOperation) {
- ((DefaultNetconfOperation) netconfOperation).setNetconfSession(session);
+ if (netconfOperation instanceof DefaultNetconfOperation defaultOperation) {
+ defaultOperation.setNetconfSession(session);
}
- if (netconfOperation instanceof SessionAwareNetconfOperation) {
- ((SessionAwareNetconfOperation) netconfOperation).setSession(session);
+ if (netconfOperation instanceof SessionAwareNetconfOperation sessionAwareOperation) {
+ sessionAwareOperation.setSession(session);
}
if (!handlingPriority.equals(HandlingPriority.CANNOT_HANDLE)) {