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

Initialization code of camel-cxf is not thread safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.1.0
    • camel-cxf
    • None

    Description

      getCxfBinding is not thread safe in case multiple threads hit a CXF webserive at once and it hasnt been initialized before.

      Code like this

          public CxfBinding getCxfBinding() {
              if (cxfBinding == null) {
                  cxfBinding = new DefaultCxfBinding();   
                  if (LOG.isDebugEnabled()) {
                      LOG.debug("Create default CXF Binding " + cxfBinding);
                  }
              }
              
              if (!cxfBindingInitialized.getAndSet(true) 
                      && cxfBinding instanceof HeaderFilterStrategyAware) {
                  ((HeaderFilterStrategyAware)cxfBinding)
                      .setHeaderFilterStrategy(getHeaderFilterStrategy());
              }
              return cxfBinding;
          }
      

      Is a false sense as the getAndSet will let other threads pass it with a cxfBinding that still may not have been initialized.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            davsclaus Claus Ibsen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: