Mike Flynn
Mike Flynn

Reputation: 24325

Stack overflow: DynamicClass with Mapster and Regular Expression

I am not sure what exactly can be calling this but is there anything odd with my cleanText function that is run within a property. Every once in a while we get this stack overflow issue but not sure what text was sent.

Stack overflow: DynamicClass.(ArrayClosure, System.Collections.Generic.ICollection`1) [Stack Overflow]
First seen: 2/7/2024, 7:00:00 PM
Last seen: 2/7/2024, 7:21:47 PM
Crashes: 8
I am getting this Stack Overflow exception below very rarely but not sure how it is happening.

Stack Overflow

Recommendation
A developer should review the code in DynamicClass.(ArrayClosure, System.Collections.Generic.ICollection`1) to determine why it recursively invokes itself, and make sure that recursion is terminated correctly when a stop condition is reached, or that the depth is limited. If large depths are expected, "unroll" the code to a while loop instead.

Member.cs

public string MobilePhone
{
    get { return _mobilePhone; }
    set { _mobilePhone = Helper.CleanPhoneNumber(value); }
}

CleanText

public static string CleanPhoneNumber(string phoneNumber)
 {
     return CleanText(phoneNumber);
 }

    public static string CleanText(string text)
    {
        if (text == null)
            return null;

        return Regex.Replace(text, "[^a-zA-Z0-9]", "").Replace(" ", "").ToLower();
    }

Mapping Code

 config.NewConfig<Member, MemberModel>()
     .Map(d => d.Api, s => s.Api).PreserveReference(true);

Stack Trace

1. System.Text.RegularExpressions.Regex.ctor(...)
2. System.Text.RegularExpressions.Regex.Replace(...)
3. Tournaments.Common.Utility.Helper.CleanText(...)
4. Tournaments.Common.Utility.Helper.CleanPhoneNumber(...)
5. Tournaments.Data.Entities.Member.set_MobilePhone(...)
6. DynamicClass.(
7. DynamicClass.(

.
.
.
164. DynamicClass.(...)
165. DynamicClass.(
166. MapsterMapper.ServiceMapper.Map[[System.__Canon, mscorlib],[System.__Canon, mscorlib]](...)
167. Tournaments.Services.Organizations.OrganizationsService.GetForMember(...)

Upvotes: 0

Views: 67

Answers (0)

Related Questions