[ 
https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Matthew F. Dennis updated CASSANDRA-2107:
-----------------------------------------

    Attachment: 2107-cassandra-0.7.txt

I thought about that, but couldn't convince myself that it was safe to do 
without looking at all the invocations closely.  In particular, if any thread 
inadvertently passed the result of the thread local to another thread (e.g. via 
putting it in a WrappedRunnable and passing it to another stage).  

The subtle difference between:

{code}
x = getThreadLocal(); 
stage.submit(new Runnable(){x.doSomething()});
{code}

and 

{code}
Runnable r = new Runnable(){getThreadLocal().doSomething()}
stage.submit(r);
{code}

worried me because there would be no exceptions or errors, just incorrect 
results.  I was also concerned that some implementations of digests might 
return the same underlying byte array (as opposed to a copy) it used to compute 
the hash when .digest() was called.

that being said, attached patch uses thread local instance.

> MessageDigests are created in several places, centralize the creation and 
> error handling
> ----------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-2107
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2107
>             Project: Cassandra
>          Issue Type: Improvement
>    Affects Versions: 0.7.0
>            Reporter: Matthew F. Dennis
>            Assignee: Matthew F. Dennis
>            Priority: Minor
>             Fix For: 0.7.2
>
>         Attachments: 2107-cassandra-0.7.txt
>
>
> MessageDigest.getInstance("SomeAlg") throws NoSuchAlgorithm exception (a 
> checked exception).  This is annoying as it causes everyone that uses 
> standard algs like MD5 to surround their code in try/catch.  We should 
> concentrate the creation in one method that doesn't raise an exception (i.e. 
> catches NoSuchAlgorithm and raises a RuntimeException) just to clean the code 
> up a little.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to