@Test public void keepHeaderUnchangedIfContextAbsent() throws IOException { when(request.getHeaders()).thenReturn(new HttpHeaders()); when(execution.execute(request, null)).thenReturn(response); clientHttpRequestInterceptor.intercept(request, null, execution); assertThat(request.getHeaders().isEmpty(), is(true)); }
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (omegaContext != null && omegaContext.globalTxId() != null) { request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId()); request.getHeaders().add(GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId(), GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); } return execution.execute(request, body); }
TransactionClientHttpRequestInterceptor implements ClientHttpRequestInterceptor { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (omegaContext != null && omegaContext.globalTxId() != null) { request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId()); request.getHeaders().add(GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId(), GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); } return execution.execute(request, body); } }
TransactionClientHttpRequestInterceptor implements ClientHttpRequestInterceptor { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (omegaContext != null && omegaContext.globalTxId() != null) { request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId()); request.getHeaders().add(GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId(), GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); } return execution.execute(request, body); } TransactionClientHttpRequestInterceptor(OmegaContext omegaContext); }
TransactionClientHttpRequestInterceptor implements ClientHttpRequestInterceptor { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (omegaContext != null && omegaContext.globalTxId() != null) { request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId()); request.getHeaders().add(GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId(), GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); } return execution.execute(request, body); } TransactionClientHttpRequestInterceptor(OmegaContext omegaContext); @Override ClientHttpResponse intercept(HttpRequest request, byte[] body,
      ClientHttpRequestExecution execution); }
TransactionClientHttpRequestInterceptor implements ClientHttpRequestInterceptor { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (omegaContext != null && omegaContext.globalTxId() != null) { request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId()); request.getHeaders().add(GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId(), GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); } return execution.execute(request, body); } TransactionClientHttpRequestInterceptor(OmegaContext omegaContext); @Override ClientHttpResponse intercept(HttpRequest request, byte[] body,
      ClientHttpRequestExecution execution);  }