-
Notifications
You must be signed in to change notification settings - Fork 424
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
Fix for static logger member in abstract class 'SQLServerClobBase' #537
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,6 @@ | |
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 | ||
* | ||
|
@@ -50,19 +47,19 @@ public class SQLServerClob extends SQLServerClobBase implements Clob { | |
@Deprecated | ||
public SQLServerClob(SQLServerConnection connection, | ||
String data) { | ||
super(connection, data, (null == connection) ? null : connection.getDatabaseCollation(), logger, null); | ||
super(connection, data, (null == connection) ? null : connection.getDatabaseCollation(), null); | ||
|
||
if (null == data) | ||
throw new NullPointerException(SQLServerException.getErrString("R_cantSetNull")); | ||
} | ||
|
||
SQLServerClob(SQLServerConnection connection) { | ||
super(connection, "", connection.getDatabaseCollation(), logger, null); | ||
super(connection, "", connection.getDatabaseCollation(), null); | ||
} | ||
|
||
SQLServerClob(BaseInputStream stream, | ||
TypeInfo typeInfo) throws SQLServerException, UnsupportedEncodingException { | ||
super(null, stream, typeInfo.getSQLCollation(), logger , typeInfo); | ||
super(null, stream, typeInfo.getSQLCollation(), typeInfo); | ||
} | ||
|
||
final JDBCType getJdbcType() { | ||
|
@@ -91,7 +88,9 @@ abstract class SQLServerClobBase implements Serializable { | |
private ArrayList<Closeable> activeStreams = new ArrayList<>(1); | ||
|
||
transient SQLServerConnection con; | ||
private static Logger logger; | ||
|
||
private final Logger logger = Logger.getLogger(getClass().getName()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is now a logger lookup whenever an instance of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @marschall Thanks for replying back! We could go for either solution, but I removed the loggers from sub classes as:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not the class lookup that I was concerned about, it's get logger lookup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please explain what you mean by Logger lookup and how will it be different in the other case - maybe I am not able to understand your point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With a non-static logger in Logger.getLogger(getClass().getName()) If we ignore
If you make the loggers in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @marschall I understand the concern for non-static logger here. Made changes in the new PR #563 as discussed above. Request you to review the PR so we can get it working. |
||
|
||
final private String traceID = getClass().getName().substring(1 + getClass().getName().lastIndexOf('.')) + ":" + nextInstanceID(); | ||
|
||
final public String toString() { | ||
|
@@ -129,7 +128,6 @@ private String getDisplayClassName() { | |
SQLServerClobBase(SQLServerConnection connection, | ||
Object data, | ||
SQLCollation collation, | ||
Logger logger, | ||
TypeInfo typeInfo) { | ||
this.con = connection; | ||
if (data instanceof BaseInputStream) { | ||
|
@@ -140,7 +138,6 @@ private String getDisplayClassName() { | |
} | ||
this.sqlCollation = collation; | ||
this.typeInfo = typeInfo; | ||
SQLServerClobBase.logger = logger; | ||
|
||
if (logger.isLoggable(Level.FINE)) { | ||
String loggingInfo = (null != connection) ? connection.toString() : "null connection"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this comment that got deleted?
// Loggers should be class static to avoid lock contention with multiple threads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well - its because this logger object won't be static in this case.