dgs-framework icon indicating copy to clipboard operation
dgs-framework copied to clipboard

bug: WebSocketHandler produce in junit tests a memory leak

Open TheMeinerLP opened this issue 4 years ago • 3 comments

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)
    }
}

https://github.com/Netflix/dgs-framework/blob/master/graphql-dgs-subscriptions-websockets/src/main/kotlin/com/netflix/graphql/dgs/subscriptions/websockets/DgsWebSocketHandler.kt#L42

TheMeinerLP avatar Oct 05 '21 11:10 TheMeinerLP

image image

TheMeinerLP avatar Oct 05 '21 11:10 TheMeinerLP

Do you have a follow up for this?

Georgian avatar Jan 28 '22 21:01 Georgian

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: @.***>

srinivasankavitha avatar Jan 28 '22 21:01 srinivasankavitha