question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SpringRestPactRunner doesn't appear to call destroyMethod on Spring beans

See original GitHub issue

I have a Pact test using SpringRestPactRunner that passes when I run it standalone. Elsewhere in my app I have a @Bean annotation with a destroyMethod parameter to control my HazelcastInstance.

    @Bean(destroyMethod= "shutdown")
    public HazelcastInstance hazelcastInstance() {
        LOGGER.info("Starting Hazelcast");
        return Hazelcast.newHazelcastInstance(config());
    }

In my other functional tests I can see in the logs that Hazelcast starts and stops correctly.

However, in my pact test Hazelcast is never shut down - this causes my Maven build to fail as the next test tries to start Hazelcast and the application fails with an exception at that point as it’s already running.

My thinking is that when I use the SpringRestPactRunner it’s not calling the destroyMethod from the @Bean annotation.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
uglyogcommented, Jul 1, 2018

3.5.19 has been released with this fix

0reactions
darrengreavescommented, Jul 4, 2018

Thanks, this has fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SpringRestPactRunner doesn't appear to call destroyMethod ...
My thinking is that when I use the SpringRestPactRunner it's not calling the destroyMethod from the @Bean annotation. The text was updated ...
Read more >
Destroy method is not working in spring framework [duplicate]
Destroy method is not called for beans of scope prototype. This is because the context doesn't keep track of the prototype scope objects...
Read more >
3.6 Customizing the nature of a bean - Spring
When you write initialization and destroy method callbacks that do not use the Spring-specific InitializingBean and DisposableBean callback interfaces, ...
Read more >
Bean life cycle in Java Spring - GeeksforGeeks
Here, we will use init() method to execute all its code as the spring container starts up and the bean is instantiated, and...
Read more >
Spring - Bean Life Cycle - Tutorialspoint
Similarly, destroymethod specifies a method that is called just before a bean is removed from the container. Initialization callbacks. The org.springframework.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found