Created
February 20, 2014 17:29
-
-
Save arey/9119018 to your computer and use it in GitHub Desktop.
CXF interceptor fixing memory leak by removing attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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