Skip to content

Commit

Permalink
Merge pull request #563 from cheenamalhotra/staticLogger
Browse files Browse the repository at this point in the history
Adding static loggers back to sub classes for avoiding logger lookup
  • Loading branch information
cheenamalhotra authored Dec 5, 2017
2 parents a8ed6f6 + 3a60d34 commit 9fe90f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

public class SQLServerClob extends SQLServerClobBase implements Clob {
private static final long serialVersionUID = 2872035282200133865L;

// Loggers should be class static to avoid lock contention with multiple threads
private static final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerClob");

/**
* Create a new CLOB
Expand All @@ -47,19 +50,19 @@ public class SQLServerClob extends SQLServerClobBase implements Clob {
@Deprecated
public SQLServerClob(SQLServerConnection connection,
String data) {
super(connection, data, (null == connection) ? null : connection.getDatabaseCollation(), null);
super(connection, data, (null == connection) ? null : connection.getDatabaseCollation(), logger, null);

if (null == data)
throw new NullPointerException(SQLServerException.getErrString("R_cantSetNull"));
}

SQLServerClob(SQLServerConnection connection) {
super(connection, "", connection.getDatabaseCollation(), null);
super(connection, "", connection.getDatabaseCollation(), logger, null);
}

SQLServerClob(BaseInputStream stream,
TypeInfo typeInfo) throws SQLServerException, UnsupportedEncodingException {
super(null, stream, typeInfo.getSQLCollation(), typeInfo);
super(null, stream, typeInfo.getSQLCollation(), logger, typeInfo);
}

final JDBCType getJdbcType() {
Expand Down Expand Up @@ -89,7 +92,7 @@ abstract class SQLServerClobBase implements Serializable {

transient SQLServerConnection con;

private final Logger logger = Logger.getLogger(getClass().getName());
private final Logger logger;

final private String traceID = getClass().getName().substring(1 + getClass().getName().lastIndexOf('.')) + ":" + nextInstanceID();

Expand Down Expand Up @@ -128,6 +131,7 @@ private String getDisplayClassName() {
SQLServerClobBase(SQLServerConnection connection,
Object data,
SQLCollation collation,
Logger logger,
TypeInfo typeInfo) {
this.con = connection;
if (data instanceof BaseInputStream) {
Expand All @@ -137,8 +141,8 @@ private String getDisplayClassName() {
this.value = (String) data;
}
this.sqlCollation = collation;
this.logger = logger;
this.typeInfo = typeInfo;

if (logger.isLoggable(Level.FINE)) {
String loggingInfo = (null != connection) ? connection.toString() : "null connection";
logger.fine(toString() + " created by (" + loggingInfo + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.UnsupportedEncodingException;
import java.sql.NClob;
import java.util.logging.Logger;

/**
* SQLServerNClob represents a National Character Set LOB object and implements java.sql.NClob.
Expand All @@ -19,13 +20,16 @@ public final class SQLServerNClob extends SQLServerClobBase implements NClob {

private static final long serialVersionUID = 1L;

// Loggers should be class static to avoid lock contention with multiple threads
private static final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerNClob");

SQLServerNClob(SQLServerConnection connection) {
super(connection, "", connection.getDatabaseCollation(), null);
super(connection, "", connection.getDatabaseCollation(), logger, null);
}

SQLServerNClob(BaseInputStream stream,
TypeInfo typeInfo) throws SQLServerException, UnsupportedEncodingException {
super(null, stream, typeInfo.getSQLCollation(), typeInfo);
super(null, stream, typeInfo.getSQLCollation(), logger, typeInfo);
}

final JDBCType getJdbcType() {
Expand Down

0 comments on commit 9fe90f7

Please sign in to comment.