static void ensureIndexTemplate(HttpCall.Factory callFactory, String templateUrl,
      String indexTemplate) throws IOException {
    AggregatedHttpRequest getTemplate = AggregatedHttpRequest.of(HttpMethod.GET, templateUrl);
    try {
      callFactory.newCall(getTemplate, BodyConverters.NULL, "get-template").execute();
    } catch (FileNotFoundException e) { // TODO: handle 404 slightly more nicely
      AggregatedHttpRequest updateTemplate = AggregatedHttpRequest.of(
        RequestHeaders.of(
          HttpMethod.PUT, templateUrl, HttpHeaderNames.CONTENT_TYPE, MediaType.JSON_UTF_8),
        HttpData.ofUtf8(indexTemplate));
      callFactory.newCall(updateTemplate, BodyConverters.NULL, "update-template").execute();
    }
  }
This is a blocking call, used inside a lazy. That's because no writes should occur until the
template is available.
zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/EnsureIndexTemplate.java