bug: WebSocketHandler produce in junit tests a memory leak
Expected behavior
After exiting the application that the threads are stopped in the class DgsWebSocketHandler
Actual behavior
TaskTimers are created but not stopped on each start but not on exit
Steps to reproduce
Create some unit tests with a abstract class system. Base Class:
@RunWith(SpringRunner::class)
@ActiveProfiles("test")
@SpringBootTest(classes = [ExampleAPI::class, SpringSecurityAuditorAware::class])
@AutoConfigureMockMvc
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)
@Suppress("UnnecessaryAbstractClass")
abstract class TestBase {
@Autowired
lateinit var context: ApplicationContext
@MockkBean
internal lateinit var userUtils: UserUtils
@Before
fun initializeContext() {
SpringContext.context = context
coEvery { userUtils.getCurrentUser() } returns
UserUser(
1,
"Test",
"Unit",
"",
eventStoreId = "test"
)
}
}
Each test:
class AddressAddressDatabaseHandlerTest : TestBase() {
@Test
fun create() = runBlocking {
val address = addressAddressDatabaseHandler.create(
AddressAddress(
street = "Musterstraße",
number = "1",
zip = "89073",
city = "Ulm",
country = "DE",
).toDto()
)
val addressAddress = addressAddressDatabaseHandler.getById(1)
Assert.assertEquals(address, addressAddress)
}
}

Do you have a follow up for this?
Thanks for reporting the issue. We will investigate and try to get a fix in the next release. In the meantime, if you are blocked, we do welcome PR contributions, so feel free to open a PR.
On Fri, Jan 28, 2022 at 1:22 PM Georgian @.***> wrote:
Do you have a follow up for this?
— Reply to this email directly, view it on GitHub https://github.com/Netflix/dgs-framework/issues/677#issuecomment-1024644920, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5JPXJBANNG2E7PNDDTVSTUYMCI7ANCNFSM5FLRCDUA . You are receiving this because you are subscribed to this thread.Message ID: @.***>