Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-983

ClientInterceptor's afterCompletion() is called twice.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3.1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      Relevant code section in WebServiceTemplate.java

      	protected Object handleError(WebServiceConnection connection, WebServiceMessage request) throws IOException {
      		if (logger.isDebugEnabled()) {
      			logger.debug("Received error for request [" + request + "]");
      		}
      		throw new WebServiceTransportException(connection.getErrorMessage());
      	}
      
      	protected <T> T doSendAndReceive(/* ... */) throws IOException {
      		try {
            // ...
      
      			if (!messageContext.hasResponse() && !intercepted) {
      				sendRequest(connection, messageContext.getRequest());
      				if (hasError(connection, messageContext.getRequest())) {
      					triggerAfterCompletion(interceptorIndex, messageContext, null);
      					return (T) handleError(connection, messageContext.getRequest());
      				}
      				WebServiceMessage response = connection.receive(getMessageFactory());
      				messageContext.setResponse(response);
      			}
      
            // ...
      		}
      		catch (TransformerException ex) {
      			triggerAfterCompletion(interceptorIndex, messageContext, ex);
      			throw new WebServiceTransformerException("Transformation error: " + ex.getMessage(), ex);
      		}
      		catch (RuntimeException ex) {
      			// Trigger after-completion for thrown exception.
      			triggerAfterCompletion(interceptorIndex, messageContext, ex);
      			throw ex;
      		}
      		catch (IOException ex) {
      			// Trigger after-completion for thrown exception.
      			triggerAfterCompletion(interceptorIndex, messageContext, ex);
      			throw ex;
      		}
      	}
      

      If after sendRequest(), hasError returns true then triggerAfterCompletion is fired and then handleError() is called which throws WebServiceTransportException.
      Latter exception is catched by catch (RuntimeException ex) block and then triggerAfterCompletion is called second time.

      I got into this situation when target WebService was returning 404 error.

      I have looked into the latest source code and seems that the bug remains.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            sarg Sergey Trofimov
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: