Skip to content

MBeanServerConnectionFactoryBean.destroy() should not attempt to close a lazy connector that has not been used yet [SPR-1733] #6430

@spring-projects-issues

Description

@spring-projects-issues

Renaud Bruyeron opened SPR-1733 and commented

MBeanServerConnectionFactoryBean.destroy() throws an exception in the following case:

  • the connectOnStartup is set to false
  • the MBeanServerConnection has not been used yet
  • the remote MBeanServer is not available

The reason is that connector.close() will cause the JMXConnectorLazyInitTargetSource to attempt a connection, which might fail.

The fix for this particular case is trivial: add an instance boolean field to keep track of the connection state, and set it to true only during connect() or in the JMXConnectorLazyInitTargetSource. Then change the destroy() method to do this:
if ( connected )
this.connector.close();

The larger question is wether destroy() should throw any JMX exception at all, since this might prevent the BeanFactory from shutting down completely.


Affects: 1.2.6

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions