Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.