You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Matthew F. Dennis (JIRA)" <ji...@apache.org> on 2011/02/04 01:15:28 UTC

[jira] Created: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

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
            Reporter: Matthew F. Dennis
            Assignee: Matthew F. Dennis
            Priority: Minor


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

        

[jira] Updated: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Jonathan Ellis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Ellis updated CASSANDRA-2107:
--------------------------------------

    Remaining Estimate: 4h
     Original Estimate: 4h

> 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.3
>
>         Attachments: 2107-cassandra-0.7.txt
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> 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

        

[jira] Commented: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12996631#comment-12996631 ] 

Hudson commented on CASSANDRA-2107:
-----------------------------------

Integrated in Cassandra-0.7 #296 (See [https://hudson.apache.org/hudson/job/Cassandra-0.7/296/])
    centralize MessageDigest creation and use threadlocals for MD5s
patch by mdennis; reviewed by jbellis for CASSANDRA-2107


> 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.3
>
>         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

        

[jira] Updated: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Matthew F. Dennis (JIRA)" <ji...@apache.org>.
     [ 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

        

[jira] Commented: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Jonathan Ellis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12990911#comment-12990911 ] 

Jonathan Ellis commented on CASSANDRA-2107:
-------------------------------------------

bq. It doesn't look like MessageDigestAlgorithm (or any equivalent) exists in Guava

Bummer.

FBUtilities is fine, but let's refactor to use the threadlocal instead of going back to using the synchronized md5 directly.

> 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

        

[jira] Commented: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Matthew F. Dennis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12990889#comment-12990889 ] 

Matthew F. Dennis commented on CASSANDRA-2107:
----------------------------------------------

The above link is from SVN revision 2 on Sep 15, 2009 "initial code dump".  It doesn't look like MessageDigestAlgorithm (or any equivalent) exists in Guava (even in r2 despite the fact that it has javadoc for it).

> 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

        

[jira] Updated: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Matthew F. Dennis (JIRA)" <ji...@apache.org>.
     [ 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

attached patch puts all MessageDigest creation into util class.

> 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

        

[jira] Updated: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Matthew F. Dennis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Attachment:     (was: 2107-cassandra-0.7.txt)

> 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

        

[jira] Commented: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Jonathan Ellis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12990423#comment-12990423 ] 

Jonathan Ellis commented on CASSANDRA-2107:
-------------------------------------------

Let's use http://guava-libraries.googlecode.com/svn-history/r2/trunk/javadoc/com/google/common/io/MessageDigestAlgorithm.html

> 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

        

[jira] Updated: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Brandon Williams (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brandon Williams updated CASSANDRA-2107:
----------------------------------------

    Fix Version/s:     (was: 0.7.2)
                   0.7.3

> 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.3
>
>         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

        

[jira] Updated: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Matthew F. Dennis (JIRA)" <ji...@apache.org>.
     [ 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

rebased

> 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

        

[jira] Updated: (CASSANDRA-2107) MessageDigests are created in several places, centralize the creation and error handling

Posted by "Matthew F. Dennis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CASSANDRA-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Attachment:     (was: 2107-cassandra-0.7.txt)

> 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