cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ranadeep.sharma@gmail.com" <ranadeep.sha...@gmail.com>
Subject Re: Unwanted bunch of Bus Provider objects in HashMap occupying large volumes of heap memory
Date Mon, 20 Jun 2016 18:41:47 GMT
Yes Sergey. You are right. Client is created for every request. And this
being the case, a new marker entry (factory hashCoded) is added everytime,
although they are not used or, referred elsewhere. It looks like a CXF
defect.

Regarding the providers, we need the providers on both hosted services as
well as clients (i.e. shared). So, your suggestion of registering the
providers only for clients does not help.

If you feel the mentioned issue is a defect, could you suggest a work-around
solution for now?

Although I have tested a custom interceptor to do the clean-up of these
entries, I need your review to see if it would impact any part of the CXF
framework. Please find the source code below.

*Java code*

/public class PurgeFactoryHashcodeInterceptor extends
AbstractPhaseInterceptor<Message> {

    public PurgeFactoryHashcodeInterceptor() {

        super(Phase.PREPARE_SEND);
        addBefore(MessageSenderInterceptor.class.getName());
    }

    @Override
    public void handleMessage(Message message) throws Fault {

            cleanUpBusProperties();
    }

    @Override
    public void handleFault(Message message) throws Fault {

            cleanUpBusProperties();
    }

    private void cleanUpBusProperties() {

        Bus bus =
SpringContextProvider.getApplicationContext().getBean(Bus.class);
        Map<String,Object> origBusPropMap = bus.getProperties();
        
        for(Map.Entry<String,Object> busPropEntry :
origBusPropMap.entrySet()) {
            if(busPropEntry.getKey().startsWith("bus.providers.set.")) {
                origBusPropMap.remove(busPropEntry.getKey());
            }
        }
    }
}/

*Spring configuration*

/<bean id="purgeFtryHashcodeInterceptor"
class="com.mycompany.ws.interceptor.PurgeFactoryHashcodeInterceptor" />

<cxf:bus>
       <cxf:properties>
                     <entry key="org.apache.cxf.jaxrs.bus.providers">
                            <list>
                                   <ref bean="throwableExceptionMapper" />
                                   <ref bean="customFilter1" />
                            </list>
                     </entry>
       </cxf:properties>
       <cxf:outInterceptors>
                     <ref bean="purgeFtryHashcodeInterceptor" />
        </cxf:outInterceptors>
</cxf:bus>/



--
View this message in context: http://cxf.547215.n5.nabble.com/Unwanted-bunch-of-Bus-Provider-objects-in-HashMap-occupying-large-volumes-of-heap-memory-tp5769515p5769607.html
Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message