Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-3698

Memory leak in HttpRequestExecutingMessageHandler

    XMLWordPrintable

    Details

      Description

      I have many spring contexts, one parent and this has many child contexts. I use the outbound-gateway in the child contexts.

      The HttpRequestExecutingMessageHandler creates and adds two converters to the conversionService in the doInit method:

      	protected void doInit() {
      		this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
      
      		ConversionService conversionService = this.getConversionService();
      		if (conversionService == null){
      			conversionService = new GenericConversionService();
      		}
      		if (conversionService instanceof ConverterRegistry){
      			ConverterRegistry converterRegistry =
      					(ConverterRegistry) conversionService;
      
      			converterRegistry.addConverter(new ClassToStringConverter());
      			converterRegistry.addConverter(new ObjectToStringConverter());
      
      			this.evaluationContext.setTypeConverter(new StandardTypeConverter(conversionService));
      		}
      		else {
      			logger.warn("ConversionService is not an instance of ConverterRegistry therefore" +
      					"ClassToStringConverter and ObjectToStringConverter will not be registered");
      		}
      	}
      

      These two classes is are inner classes, not statics.

      If I have an integration bean in any of my parent processes, the getConversionService method returns the same conversionService for all of my child contexts from that parent context. This results if I close my child context, the instance of HttpRequestExecutingMessageHandler remains in the heap because the converter classes are not statics but inner classes.

      It would be good if these two classes be statics, not inner classes. In this case after the context close, the HttpRequestExecutingMessageHandler would release from the memory.

      The other idea that it would be good in the doInit method if the converter registration placed after a condition:

      if (!conversionService.canConvert(Class.class, String.class)) {
          converterRegistry.addConverter(new ClassToStringConverter());
      }
      if (!conversionService.canConvert(Object.class, String.class)) {
          converterRegistry.addConverter(new ObjectToStringConverter());
      }
      

        Attachments

          Activity

            People

            Assignee:
            abilan Artem Bilan
            Reporter:
            csupi Roland Csupor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: