Skip to content

Instantly share code, notes, and snippets.

@arey
Created February 20, 2014 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arey/9119018 to your computer and use it in GitHub Desktop.
Save arey/9119018 to your computer and use it in GitHub Desktop.
CXF interceptor fixing memory leak by removing attachments
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.Phase;
/**
* Fix CXF memory leak by removing attachments once the SOAP message was sent.
*/
public class ClearAttachmentsOutInterceptor extends AbstractSoapInterceptor {
public ClearAttachmentsOutInterceptor() {
super(Phase.SETUP_ENDING);
}
@Override
public void handleMessage(SoapMessage message) throws Fault {
message.getExchange().getOutMessage().setContent(
org.apache.cxf.attachment.AttachmentSerializer.class, null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment