@@ -122,37 +122,37 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
122122
123123 private Boolean isAzureDW = null ;
124124
125- static class Sha1HashKey implements java .io .Serializable {
125+ static class SQLServerHashKey implements java .io .Serializable {
126126
127127 /**
128128 * Always refresh SerialVersionUID when prompted
129129 */
130130 private static final long serialVersionUID = 166788428640603097L ;
131131 private byte [] bytes ;
132132
133- Sha1HashKey (String sql ,
133+ SQLServerHashKey (String sql ,
134134 String parametersDefinition ) {
135- this (String . format ( "%s%s" , sql , parametersDefinition ) );
135+ this (sql + parametersDefinition );
136136 }
137137
138- Sha1HashKey (String s ) {
139- bytes = getSha1Digest ().digest (s .getBytes ());
138+ SQLServerHashKey (String s ) {
139+ bytes = getSha256Digest ().digest (s .getBytes ());
140140 }
141141
142142 public boolean equals (Object obj ) {
143- if (!(obj instanceof Sha1HashKey ))
143+ if (!(obj instanceof SQLServerHashKey ))
144144 return false ;
145145
146- return java .util .Arrays .equals (bytes , ((Sha1HashKey ) obj ).bytes );
146+ return java .util .Arrays .equals (bytes , ((SQLServerHashKey ) obj ).bytes );
147147 }
148148
149149 public int hashCode () {
150150 return java .util .Arrays .hashCode (bytes );
151151 }
152152
153- private java .security .MessageDigest getSha1Digest () {
153+ private java .security .MessageDigest getSha256Digest () {
154154 try {
155- return java .security .MessageDigest .getInstance ("SHA-1 " );
155+ return java .security .MessageDigest .getInstance ("SHA-256 " );
156156 }
157157 catch (final java .security .NoSuchAlgorithmException e ) {
158158 // This is not theoretically possible, but we're forced to catch it anyway
@@ -170,9 +170,9 @@ class PreparedStatementHandle {
170170 private boolean isDirectSql ;
171171 private volatile boolean evictedFromCache ;
172172 private volatile boolean explicitlyDiscarded ;
173- private Sha1HashKey key ;
173+ private SQLServerHashKey key ;
174174
175- PreparedStatementHandle (Sha1HashKey key ,
175+ PreparedStatementHandle (SQLServerHashKey key ,
176176 int handle ,
177177 boolean isDirectSql ,
178178 boolean isEvictedFromCache ) {
@@ -211,7 +211,7 @@ int getHandle() {
211211 }
212212
213213 /** Get the cache key. */
214- Sha1HashKey getKey () {
214+ SQLServerHashKey getKey () {
215215 return key ;
216216 }
217217
@@ -258,19 +258,19 @@ void removeReference() {
258258 static final private int PARSED_SQL_CACHE_SIZE = 100 ;
259259
260260 /** Cache of parsed SQL meta data */
261- static private ConcurrentLinkedHashMap <Sha1HashKey , ParsedSQLCacheItem > parsedSQLCache ;
261+ static private ConcurrentLinkedHashMap <SQLServerHashKey , ParsedSQLCacheItem > parsedSQLCache ;
262262
263263 static {
264- parsedSQLCache = new Builder <Sha1HashKey , ParsedSQLCacheItem >().maximumWeightedCapacity (PARSED_SQL_CACHE_SIZE ).build ();
264+ parsedSQLCache = new Builder <SQLServerHashKey , ParsedSQLCacheItem >().maximumWeightedCapacity (PARSED_SQL_CACHE_SIZE ).build ();
265265 }
266266
267267 /** Get prepared statement cache entry if exists, if not parse and create a new one */
268- static ParsedSQLCacheItem getCachedParsedSQL (Sha1HashKey key ) {
268+ static ParsedSQLCacheItem getCachedParsedSQL (SQLServerHashKey key ) {
269269 return parsedSQLCache .get (key );
270270 }
271271
272272 /** Parse and create a information about parsed SQL text */
273- static ParsedSQLCacheItem parseAndCacheSQL (Sha1HashKey key ,
273+ static ParsedSQLCacheItem parseAndCacheSQL (SQLServerHashKey key ,
274274 String sql ) throws SQLServerException {
275275 JDBCSyntaxTranslator translator = new JDBCSyntaxTranslator ();
276276
@@ -291,9 +291,9 @@ static ParsedSQLCacheItem parseAndCacheSQL(Sha1HashKey key,
291291 private int statementPoolingCacheSize = DEFAULT_STATEMENT_POOLING_CACHE_SIZE ;
292292
293293 /** Cache of prepared statement handles */
294- private ConcurrentLinkedHashMap <Sha1HashKey , PreparedStatementHandle > preparedStatementHandleCache ;
294+ private ConcurrentLinkedHashMap <SQLServerHashKey , PreparedStatementHandle > preparedStatementHandleCache ;
295295 /** Cache of prepared statement parameter metadata */
296- private ConcurrentLinkedHashMap <Sha1HashKey , SQLServerParameterMetaData > parameterMetadataCache ;
296+ private ConcurrentLinkedHashMap <SQLServerHashKey , SQLServerParameterMetaData > parameterMetadataCache ;
297297 /**
298298 * Checks whether statement pooling is enabled or disabled. The default is set to true;
299299 */
@@ -5797,23 +5797,23 @@ public void setStatementPoolingCacheSize(int value) {
57975797 * @param value
57985798 */
57995799 private void prepareCache () {
5800- preparedStatementHandleCache = new Builder <Sha1HashKey , PreparedStatementHandle >().maximumWeightedCapacity (getStatementPoolingCacheSize ())
5800+ preparedStatementHandleCache = new Builder <SQLServerHashKey , PreparedStatementHandle >().maximumWeightedCapacity (getStatementPoolingCacheSize ())
58015801 .listener (new PreparedStatementCacheEvictionListener ()).build ();
58025802
5803- parameterMetadataCache = new Builder <Sha1HashKey , SQLServerParameterMetaData >().maximumWeightedCapacity (getStatementPoolingCacheSize ())
5803+ parameterMetadataCache = new Builder <SQLServerHashKey , SQLServerParameterMetaData >().maximumWeightedCapacity (getStatementPoolingCacheSize ())
58045804 .build ();
58055805 }
58065806
58075807 /** Get a parameter metadata cache entry if statement pooling is enabled */
5808- final SQLServerParameterMetaData getCachedParameterMetadata (Sha1HashKey key ) {
5808+ final SQLServerParameterMetaData getCachedParameterMetadata (SQLServerHashKey key ) {
58095809 if (!isStatementPoolingEnabled ())
58105810 return null ;
58115811
58125812 return parameterMetadataCache .get (key );
58135813 }
58145814
58155815 /** Register a parameter metadata cache entry if statement pooling is enabled */
5816- final void registerCachedParameterMetadata (Sha1HashKey key ,
5816+ final void registerCachedParameterMetadata (SQLServerHashKey key ,
58175817 SQLServerParameterMetaData pmd ) {
58185818 if (!isStatementPoolingEnabled () || null == pmd )
58195819 return ;
@@ -5822,15 +5822,15 @@ final void registerCachedParameterMetadata(Sha1HashKey key,
58225822 }
58235823
58245824 /** Get or create prepared statement handle cache entry if statement pooling is enabled */
5825- final PreparedStatementHandle getCachedPreparedStatementHandle (Sha1HashKey key ) {
5825+ final PreparedStatementHandle getCachedPreparedStatementHandle (SQLServerHashKey key ) {
58265826 if (!isStatementPoolingEnabled ())
58275827 return null ;
58285828
58295829 return preparedStatementHandleCache .get (key );
58305830 }
58315831
58325832 /** Get or create prepared statement handle cache entry if statement pooling is enabled */
5833- final PreparedStatementHandle registerCachedPreparedStatementHandle (Sha1HashKey key ,
5833+ final PreparedStatementHandle registerCachedPreparedStatementHandle (SQLServerHashKey key ,
58345834 int handle ,
58355835 boolean isDirectSql ) {
58365836 if (!isStatementPoolingEnabled () || null == key )
@@ -5858,8 +5858,8 @@ final void evictCachedPreparedStatementHandle(PreparedStatementHandle handle) {
58585858 }
58595859
58605860 // Handle closing handles when removed from cache.
5861- final class PreparedStatementCacheEvictionListener implements EvictionListener <Sha1HashKey , PreparedStatementHandle > {
5862- public void onEviction (Sha1HashKey key ,
5861+ final class PreparedStatementCacheEvictionListener implements EvictionListener <SQLServerHashKey , PreparedStatementHandle > {
5862+ public void onEviction (SQLServerHashKey key ,
58635863 PreparedStatementHandle handle ) {
58645864 if (null != handle ) {
58655865 handle .setIsEvictedFromCache (true ); // Mark as evicted from cache.
0 commit comments