Skip to content

System.Data.SqlClient.SqlCommand.Prepare() calls SqlStatistics.StopTimer() outside finally block #16131

@Dmitry-Me

Description

@Dmitry-Me

All methods of System.Data.SqlClient.SqlCommand which call SqlStatistics.StartTimer() go like this:

SqlStatistics statistics = null;
try {
    statistics = SqlStatistics.StartTimer(Statistics);
    doSomethingUseful();
 } finally {
     SqlStatistics.StopTimer(statistics);
 }

but SqlCommand.Prepare() does not follow that pattern - it contains StopTimer() call outside finally so StopTimer() is not guaranteed to run should useful code throw an exception.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions