Source:
<code>public <Q, I, U> Registration subscriptionQuery(SubscriptionQueryMessage<Q, I, U> query, UpdateHandler<I, U> updateHandler) { MessageMonitor.MonitorCallback monitorCallback = messageMonitor.onMessageIngested(query); SubscriptionQueryMessage<Q, I, U> interceptedQuery = intercept(query); List<QuerySubscription> subs = subscriptions .computeIfAbsent(interceptedQuery.getQueryName(), k -> new CopyOnWriteArrayList<>()) .stream() .filter(subscription -> interceptedQuery.getResponseType().matches(subscription.getResponseType())) .collect(Collectors.toList()); Registration registration = () -> true; try { if (subs.isEmpty()) { throw new NoHandlerForQueryException( format("No handler found for %s with response type %s and update type %s", interceptedQuery.getQueryName(), interceptedQuery.getResponseType(), interceptedQuery.getUpdateResponseType())); } Iterator<QuerySubscription> subsIterator = subs.iterator(); boolean invocationSuccess = false; while (!invocationSuccess && subsIterator.hasNext()) { try { QuerySubscription subscription = subsIterator.next(); DefaultUnitOfWork<QueryMessage<Q, I>> uow = DefaultUnitOfWork.startAndGet(interceptedQuery); <START> if (subscription instanceof SubscribableQuerySubscription) { <END> if (interceptedQuery.getUpdateResponseType() .matches(((SubscribableQuerySubscription) subscription).getUpdateType())) { registration = invokeSubscriptionQueryHandler(uow, ((SubscribableQuerySubscription) subscription) .getSubscriptionQueryHandler(), updateHandler); invocationSuccess = true; } } else { invokeRegularQueryHandler(uow, subscription.getQueryHandler(), updateHandler); invocationSuccess = true; } } catch (NoHandlerForQueryException e) { } } if (!invocationSuccess) { throw new NoHandlerForQueryException( format("No suitable handler was found for %s with response type %s and update type %s", interceptedQuery.getQueryName(), interceptedQuery.getResponseType(), interceptedQuery.getUpdateResponseType())); } } catch (Exception e) { monitorCallback.reportFailure(e); updateHandler.onError(e); } return registration; }</code><technical_language>merge if statements sense</technical_language>

Target:
public <Q, I, U> Registration subscriptionQuery(SubscriptionQueryMessage<Q, I, U> query, UpdateHandler<I, U> updateHandler) { MessageMonitor.MonitorCallback monitorCallback = messageMonitor.onMessageIngested(query); SubscriptionQueryMessage<Q, I, U> interceptedQuery = intercept(query); List<QuerySubscription> subs = subscriptions .computeIfAbsent(interceptedQuery.getQueryName(), k -> new CopyOnWriteArrayList<>()) .stream() .filter(subscription -> interceptedQuery.getResponseType().matches(subscription.getResponseType())) .collect(Collectors.toList()); Registration registration = () -> false; try { if (subs.isEmpty()) { throw new NoHandlerForQueryException( format("No handler found for %s with response type %s and update type %s", interceptedQuery.getQueryName(), interceptedQuery.getResponseType(), interceptedQuery.getUpdateResponseType())); } Iterator<QuerySubscription> subsIterator = subs.iterator(); boolean invocationSuccess = false; while (!invocationSuccess && subsIterator.hasNext()) { try { QuerySubscription subscription = subsIterator.next(); DefaultUnitOfWork<QueryMessage<Q, I>> uow = DefaultUnitOfWork.startAndGet(interceptedQuery); if (subscription instanceof SubscribableQuerySubscription) { if (interceptedQuery.getUpdateResponseType() .matches(((SubscribableQuerySubscription) subscription).getUpdateType())) { registration = invokeSubscriptionQueryHandler(uow, ((SubscribableQuerySubscription) subscription) .getSubscriptionQueryHandler(), updateHandler); invocationSuccess = true; } } else { invokeRegularQueryHandler(uow, subscription.getQueryHandler(), updateHandler); invocationSuccess = true; } } catch (NoHandlerForQueryException e) { } } if (!invocationSuccess) { throw new NoHandlerForQueryException( format("No suitable handler was found for %s with response type %s and update type %s", interceptedQuery.getQueryName(), interceptedQuery.getResponseType(), interceptedQuery.getUpdateResponseType())); } monitorCallback.reportSuccess(); } catch (Exception e) { monitorCallback.reportFailure(e); updateHandler.onError(e); } return registration; }