NETCONF-509: no-input RPCs should use RestconfDocumentedException 25/68325/2
authorEvan Zeller <evanrzeller@gmail.com>
Wed, 14 Feb 2018 23:15:41 +0000 (15:15 -0800)
committerEvan Zeller <evanrzeller@gmail.com>
Fri, 23 Feb 2018 23:06:39 +0000 (23:06 +0000)
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>
(cherry picked from commit 914a50cc793909ffa813e60f9ac6c73b0cfbb5bc)

restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java

index ab8eb3b389e034e921e94309c4f299caf4ef72a0..ad9c9a4dc3b6fca5cb7c346be96faee761cccc08 100644 (file)
@@ -531,8 +531,8 @@ public 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;