NETCONF-509: no-input RPCs should use RestconfDocumentedException 71/68271/1
authorEvan Zeller <evanrzeller@gmail.com>
Wed, 14 Feb 2018 23:15:41 +0000 (15:15 -0800)
committerEvan Zeller <evanrzeller@gmail.com>
Wed, 14 Feb 2018 23:22:44 +0000 (15:22 -0800)
When invoked with an "input" value currently the implementation throws
IllegalStateException up to the servlet container which results in the
ugly jetty default error page and reveals stack trace information.
Provide a clear message that the invoked RPC should not take any input values.

Change-Id: Id13499b80bed9a2ea7666a3aa6d775da341055ab
Signed-off-by: Evan Zeller <evanrzeller@gmail.com>
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java

index 715d66c9552ceb43b6aa0b4c5e61c5bff89f5735..4dc8702f497c570d8530592ada6b9169f31fd141 100644 (file)
@@ -525,8 +525,8 @@ public final class RestconfImpl implements RestconfService {
 
         if (!rpc.getInput().getChildNodes().isEmpty()) {
             LOG.debug("RPC " + rpc + " does not need input value.");
-            // FIXME : find a correct Error from specification
-            throw new IllegalStateException("RPC " + rpc + " does'n need input value!");
+            throw new RestconfDocumentedException("RPC " + rpc + " does not take any input value.",
+                    ErrorType.RPC, ErrorTag.INVALID_VALUE);
         }
 
         final CheckedFuture<DOMRpcResult, DOMRpcException> response;