Skip to content

How to unmap a previously mapped OData service route completely #2773

Open
@RainerAtSiemens

Description

@RainerAtSiemens

Issue

In out product we are using the method Microsoft.AspNet.OData.Extensions.HttpConfigurationExtensions.MapODataServiceRoute(this HttpConfiguration configuration, string routeName, string routePrefix, Action configureAction) to map our OData service routes.

We have some static routes and some dynamic ones. For the dynamic ones, we need to be able to "unmap" a route which was previously added. My question is how can I do that unmapping in a clean way without having any memory leak.

Assemblies affected

Microsoft.AspNet.OData.dll v7.5.12

Reproduce steps

  1. Check entries of HttpConfiguration.Routes and HttpConfiguration.Properties
  2. Map a odata route using Microsoft.AspNet.OData.Extensions.HttpConfigurationExtensions.MapODataServiceRoute(this HttpConfiguration configuration, string routeName, string routePrefix, Action configureAction)
  3. Check entries of HttpConfiguration.Routes and HttpConfiguration.Properties -> should have some added entries
  4. Unmap the OData route. Not sure what is the best way to do. Currently we just do HttpConfiguration.Routes.Remove(routName) but that does not unmap everything so some references are still there, e.g. to the created ODataRootContainer.
  5. Check entries of HttpConfiguration.Routes and HttpConfiguration.Properties -> should have some entries like in 1., i.e. no memory leak

Expected result

When a route is mapped and unmapped, there should not be a increase in memory.

Actual result

When there is no way to unmap a route completley, there is a memory leak.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions