diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-07-19 15:43:14 +0200 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-07-19 16:06:09 +0200 |
commit | e867f496281145fe0d66c52dd4282e78efe34ede (patch) | |
tree | 98ba377c6e3fe6daa3738477f2638cc0f64180bf /documentapi/src | |
parent | 76e142fd3b7dd90e6ba0bc9cd85ee83c207aff43 (diff) |
Only implicitly override routes for Get operations if the non-Get route
is the default one. Otherwise we can't override the route used for Gets
with the current API functionality.
Diffstat (limited to 'documentapi/src')
-rw-r--r-- | documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java index a2bad9c84e1..33286d227bf 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java @@ -143,6 +143,14 @@ public class MessageBusAsyncSession implements MessageBusSession, AsyncSession { return send(msg); } + private boolean mayOverrideWithGetOnlyRoute(Message msg) { + // Only allow implicitly overriding the default Get route if the message is attempted sent + // with the default route originally. Otherwise it's reasonable to assume that the caller + // has some explicit idea of why the regular route is set to the value it is. + return ((msg.getType() == DocumentProtocol.MESSAGE_GETDOCUMENT) + && ("default".equals(route) || "route:default".equals(route))); + } + /** * A convenience method for assigning the internal trace level and route string to a message before sending it * through the internal mbus session object. @@ -155,7 +163,7 @@ public class MessageBusAsyncSession implements MessageBusSession, AsyncSession { long reqId = requestId.incrementAndGet(); msg.setContext(reqId); msg.getTrace().setLevel(traceLevel); - String toRoute = (msg.getType() == DocumentProtocol.MESSAGE_GETDOCUMENT ? routeForGet : route); + String toRoute = (mayOverrideWithGetOnlyRoute(msg) ? routeForGet : route); if (toRoute != null) { return toResult(reqId, session.send(msg, toRoute, true)); } else { |