Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The loggingClassName field is static, creates memory leak and logging inconsistency. #1649

Closed
imreh-zoltan opened this issue Aug 31, 2021 · 2 comments
Projects

Comments

@imreh-zoltan
Copy link

imreh-zoltan commented Aug 31, 2021

Driver version

9.2.1.jre8

SQL Server version

Microsoft SQL Server 2017 (RTM-CU24) (KB5001228) - 14.0.3391.2 (X64) Apr 28 2021 10:32:18 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)

Client Operating System

Windows Server 2016

JAVA/JVM version

OpenJDK 64-Bit Server VM, 1.8.0_232-b18

Table schema

Problem description

In com.microsoft.sqlserver.jdbc.SQLServerConnection the field loggingClassName is private static.

The class constructor bellow appends a new connection id to this static field every time a new instance is constructed. This used with the SQLServerConnectionPoolDataSource creates over time a huge string of few MBs and the logging is inconsistent, because the connection cannot be identified. Please make these fields none static in order to remove this issue.

private static String loggingClassName = "com.microsoft.sqlserver.jdbc.SQLServerConnection:";

SQLServerConnection(String parentInfo) throws SQLServerException {
int connectionID = nextConnectionID(); // sequential connection id
traceID = "ConnectionID:" + connectionID;
loggingClassName += connectionID;
if (connectionlogger.isLoggable(Level.FINE))
connectionlogger.fine(toString() + " created by (" + parentInfo + ")");
initResettableValues();

    // Caching turned on?
    if (!this.getDisableStatementPooling() && 0 < this.getStatementPoolingCacheSize()) {
        prepareCache();
    }
}

Consider doing this within the DataSource implementations as well, where there is no memory leak, put it is still inconsistent because of the static field.

Regards,
Zoltan Imreh

@imreh-zoltan imreh-zoltan changed the title Logging class name is static, creates memory leak and logging inconsistency. The loggingClassName field is static, creates memory leak and logging inconsistency. Aug 31, 2021
@lilgreenbird
Copy link
Member

hi @imreh-zoltan

this has been fixed in PR #1633, please upgrade to the latest 9.4.0 release.

@lilgreenbird
Copy link
Member

closing as this had been resolved. Please feel free to request re-opening if you have more questions.

@lilgreenbird lilgreenbird added this to Closed Issues in MSSQL JDBC Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed Issues
Development

No branches or pull requests

2 participants