Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12740

Olingo4Component creates and ignores HttpAsyncClientBuilder

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      The Olingo4Component will create an instance of HttpAsyncClientBuilder is the provided Olingo4Configuration does not contain one. The new instance of HttpAsyncClientBuilder will be configured with timeout settings, proxy and SSL, but will never be used.

      Extract from Olingo4Component.createOlingo4App:

      Object clientBuilder = configuration.getHttpAsyncClientBuilder();
      if (clientBuilder == null) {
          HttpAsyncClientBuilder asyncClientBuilder = HttpAsyncClientBuilder.create();
          Builder requestConfigBuilder = RequestConfig.custom();
          requestConfigBuilder.setConnectTimeout(configuration.getConnectTimeout());
          requestConfigBuilder.setSocketTimeout(configuration.getSocketTimeout());
          HttpHost proxy = configuration.getProxy();
          if (proxy != null) {
              requestConfigBuilder.setProxy(proxy);
          }
      
          asyncClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
          SSLContextParameters sslContextParameters = configuration.getSslContextParameters();
          if (sslContextParameters == null) {
              sslContextParameters = this.retrieveGlobalSslContextParameters();
          }
      
          if (sslContextParameters == null) {
              sslContextParameters = new SSLContextParameters();
          }
      
          try {
              asyncClientBuilder.setSSLContext(sslContextParameters.createSSLContext(this.getCamelContext()));
          } catch (GeneralSecurityException var8) {
              throw ObjectHelper.wrapRuntimeCamelException(var8);
          } catch (IOException var9) {
              throw ObjectHelper.wrapRuntimeCamelException(var9);
          }
      }
      
      Olingo4AppImpl olingo4App;
      if (clientBuilder != null && !(clientBuilder instanceof HttpAsyncClientBuilder)) {
          olingo4App = new Olingo4AppImpl(configuration.getServiceUri(), (HttpClientBuilder)clientBuilder);
      } else {
          olingo4App = new Olingo4AppImpl(configuration.getServiceUri(), (HttpAsyncClientBuilder)clientBuilder);
      }
      

      The class Olingo4AppImpl gets a null clientBuilder reference and then instantiates its own:

      public Olingo4AppImpl(String serviceUri, HttpAsyncClientBuilder builder) {
          this.odataClient = ODataClientFactory.getClient();
          this.odataReader = this.odataClient.getReader();
          this.odataWriter = this.odataClient.getWriter();
          this.setServiceUri(serviceUri);
          CloseableHttpAsyncClient asyncClient;
          if (builder == null) {
              asyncClient = HttpAsyncClients.createDefault();
          } else {
              asyncClient = builder.build();
          }
      
          asyncClient.start();
          this.client = asyncClient;
          this.contentType = DEFAULT_CONTENT_TYPE;
      }
      

      Because of this, none of the Olingo4Configuration settings are used and for example connect and socket timeout defaults to -1.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            ninckblokje Jeroen NB
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: