You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/12/28 01:17:38 UTC

[commons-codec] branch master updated: Change AssertionError to IllegalStateException

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git


The following commit(s) were added to refs/heads/master by this push:
     new 1cf4d19  Change AssertionError to IllegalStateException
1cf4d19 is described below

commit 1cf4d19069c64d0493f8b92178ffdb728c0c0ac2
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Sat Dec 28 01:17:17 2019 +0000

    Change AssertionError to IllegalStateException
---
 src/main/java/org/apache/commons/codec/digest/MurmurHash3.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
index d4a95ea..5d9aa9d 100644
--- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
+++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
@@ -1054,7 +1054,7 @@ public final class MurmurHash3 {
                     k = orBytes(unprocessed[0], unprocessed[1], unprocessed[2], data[offset]);
                     break;
                 default:
-                    throw new AssertionError("Unprocessed length should be 1, 2, or 3: " + unprocessedLength);
+                    throw new IllegalStateException("Unprocessed length should be 1, 2, or 3: " + unprocessedLength);
                 }
                 hash = mix32(k, hash);
                 // Update the offset and length


Re: [commons-codec] branch master updated: Change AssertionError to IllegalStateException

Posted by Claude Warren <cl...@xenei.com>.
Wherever the note is found the javadoc should include

     * <p>This implementation contains a sign-extension bug in the seed
initialization.
     * This manifests if the seed is negative.<p>

On Sat, Dec 28, 2019 at 1:45 AM Gary Gregory <ga...@gmail.com> wrote:

> On Fri, Dec 27, 2019 at 8:17 PM <ah...@apache.org> wrote:
>
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > aherbert pushed a commit to branch master
> > in repository https://gitbox.apache.org/repos/asf/commons-codec.git
> >
> >
> > The following commit(s) were added to refs/heads/master by this push:
> >      new 1cf4d19  Change AssertionError to IllegalStateException
> > 1cf4d19 is described below
> >
> > commit 1cf4d19069c64d0493f8b92178ffdb728c0c0ac2
> > Author: Alex Herbert <ah...@apache.org>
> > AuthorDate: Sat Dec 28 01:17:17 2019 +0000
> >
> >     Change AssertionError to IllegalStateException
> > ---
> >  src/main/java/org/apache/commons/codec/digest/MurmurHash3.java | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git
> > a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > index d4a95ea..5d9aa9d 100644
> > --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > @@ -1054,7 +1054,7 @@ public final class MurmurHash3 {
> >                      k = orBytes(unprocessed[0], unprocessed[1],
> > unprocessed[2], data[offset]);
> >                      break;
> >                  default:
> > -                    throw new AssertionError("Unprocessed length should
> > be 1, 2, or 3: " + unprocessedLength);
> > +                    throw new IllegalStateException("Unprocessed length
> > should be 1, 2, or 3: " + unprocessedLength);
> >                  }
> >                  hash = mix32(k, hash);
> >                  // Update the offset and length
> >
>
> That seems clearer, thanks.
>
> This seems like the kind of code we might want fuzz test. It seems
> quite unlikely otherwise we'd hit this case. I also wonder if
>
> Thoughts?
>
> I see in several places:
>
> // Note: This fails to apply masking using 0xffffffffL to the seed.
>
> Shouldn't this be in the Javadoc?
>
> Gary
>


-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Re: [commons-codec] branch master updated: Change AssertionError to IllegalStateException

Posted by Gary Gregory <ga...@gmail.com>.
You can recover from an exception, errors you are not supposed to...

Gary

On Sat, Dec 28, 2019, 13:53 Matt Sicker <bo...@gmail.com> wrote:

> Aren’t Errors supposed to be fatal exceptions that are generally only
> caught by exception handlers rather than by calling code? Think
> OutOfMemoryError or StackOverflowError.
>
> On Sat, Dec 28, 2019 at 11:35 Miguel Munoz <swingguy1024@yahoo.com
> .invalid>
> wrote:
>
> >  I can't look at the code right now, but I would use an
> > IllegalStateException if the problem is caused by a user error. I would
> use
> > an AssertionError if the problem is caused by a defect in the
> > implementation.
> >
> > -- Miguel Muñoz
> >      On Friday, December 27, 2019, 5:45:58 PM PST, Gary Gregory <
> > garydgregory@gmail.com> wrote:
> >
> >  On Fri, Dec 27, 2019 at 8:17 PM <ah...@apache.org> wrote:
> >
> > > This is an automated email from the ASF dual-hosted git repository.
> > >
> > > aherbert pushed a commit to branch master
> > > in repository https://gitbox.apache.org/repos/asf/commons-codec.git
> > >
> > >
> > > The following commit(s) were added to refs/heads/master by this push:
> > >      new 1cf4d19  Change AssertionError to IllegalStateException
> > > 1cf4d19 is described below
> > >
> > > commit 1cf4d19069c64d0493f8b92178ffdb728c0c0ac2
> > > Author: Alex Herbert <ah...@apache.org>
> > > AuthorDate: Sat Dec 28 01:17:17 2019 +0000
> > >
> > >    Change AssertionError to IllegalStateException
> > > ---
> > >  src/main/java/org/apache/commons/codec/digest/MurmurHash3.java | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git
> > > a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > > b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > > index d4a95ea..5d9aa9d 100644
> > > --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > > +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > > @@ -1054,7 +1054,7 @@ public final class MurmurHash3 {
> > >                      k = orBytes(unprocessed[0], unprocessed[1],
> > > unprocessed[2], data[offset]);
> > >                      break;
> > >                  default:
> > > -                    throw new AssertionError("Unprocessed length
> should
> > > be 1, 2, or 3: " + unprocessedLength);
> > > +                    throw new IllegalStateException("Unprocessed
> length
> > > should be 1, 2, or 3: " + unprocessedLength);
> > >                  }
> > >                  hash = mix32(k, hash);
> > >                  // Update the offset and length
> > >
> >
> > That seems clearer, thanks.
> >
> > This seems like the kind of code we might want fuzz test. It seems
> > quite unlikely otherwise we'd hit this case. I also wonder if
> >
> > Thoughts?
> >
> > I see in several places:
> >
> > // Note: This fails to apply masking using 0xffffffffL to the seed.
> >
> > Shouldn't this be in the Javadoc?
> >
> > Gary
> >
>
> --
> Matt Sicker <bo...@gmail.com>
>

Re: [commons-codec] branch master updated: Change AssertionError to IllegalStateException

Posted by Matt Sicker <bo...@gmail.com>.
Aren’t Errors supposed to be fatal exceptions that are generally only
caught by exception handlers rather than by calling code? Think
OutOfMemoryError or StackOverflowError.

On Sat, Dec 28, 2019 at 11:35 Miguel Munoz <sw...@yahoo.com.invalid>
wrote:

>  I can't look at the code right now, but I would use an
> IllegalStateException if the problem is caused by a user error. I would use
> an AssertionError if the problem is caused by a defect in the
> implementation.
>
> -- Miguel Muñoz
>      On Friday, December 27, 2019, 5:45:58 PM PST, Gary Gregory <
> garydgregory@gmail.com> wrote:
>
>  On Fri, Dec 27, 2019 at 8:17 PM <ah...@apache.org> wrote:
>
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > aherbert pushed a commit to branch master
> > in repository https://gitbox.apache.org/repos/asf/commons-codec.git
> >
> >
> > The following commit(s) were added to refs/heads/master by this push:
> >      new 1cf4d19  Change AssertionError to IllegalStateException
> > 1cf4d19 is described below
> >
> > commit 1cf4d19069c64d0493f8b92178ffdb728c0c0ac2
> > Author: Alex Herbert <ah...@apache.org>
> > AuthorDate: Sat Dec 28 01:17:17 2019 +0000
> >
> >    Change AssertionError to IllegalStateException
> > ---
> >  src/main/java/org/apache/commons/codec/digest/MurmurHash3.java | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git
> > a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > index d4a95ea..5d9aa9d 100644
> > --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> > @@ -1054,7 +1054,7 @@ public final class MurmurHash3 {
> >                      k = orBytes(unprocessed[0], unprocessed[1],
> > unprocessed[2], data[offset]);
> >                      break;
> >                  default:
> > -                    throw new AssertionError("Unprocessed length should
> > be 1, 2, or 3: " + unprocessedLength);
> > +                    throw new IllegalStateException("Unprocessed length
> > should be 1, 2, or 3: " + unprocessedLength);
> >                  }
> >                  hash = mix32(k, hash);
> >                  // Update the offset and length
> >
>
> That seems clearer, thanks.
>
> This seems like the kind of code we might want fuzz test. It seems
> quite unlikely otherwise we'd hit this case. I also wonder if
>
> Thoughts?
>
> I see in several places:
>
> // Note: This fails to apply masking using 0xffffffffL to the seed.
>
> Shouldn't this be in the Javadoc?
>
> Gary
>

-- 
Matt Sicker <bo...@gmail.com>

Re: [commons-codec] branch master updated: Change AssertionError to IllegalStateException

Posted by Miguel Munoz <sw...@yahoo.com.INVALID>.
 I can't look at the code right now, but I would use an IllegalStateException if the problem is caused by a user error. I would use an AssertionError if the problem is caused by a defect in the implementation. 

-- Miguel Muñoz
     On Friday, December 27, 2019, 5:45:58 PM PST, Gary Gregory <ga...@gmail.com> wrote:  
 
 On Fri, Dec 27, 2019 at 8:17 PM <ah...@apache.org> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> aherbert pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/commons-codec.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>      new 1cf4d19  Change AssertionError to IllegalStateException
> 1cf4d19 is described below
>
> commit 1cf4d19069c64d0493f8b92178ffdb728c0c0ac2
> Author: Alex Herbert <ah...@apache.org>
> AuthorDate: Sat Dec 28 01:17:17 2019 +0000
>
>    Change AssertionError to IllegalStateException
> ---
>  src/main/java/org/apache/commons/codec/digest/MurmurHash3.java | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git
> a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> index d4a95ea..5d9aa9d 100644
> --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> @@ -1054,7 +1054,7 @@ public final class MurmurHash3 {
>                      k = orBytes(unprocessed[0], unprocessed[1],
> unprocessed[2], data[offset]);
>                      break;
>                  default:
> -                    throw new AssertionError("Unprocessed length should
> be 1, 2, or 3: " + unprocessedLength);
> +                    throw new IllegalStateException("Unprocessed length
> should be 1, 2, or 3: " + unprocessedLength);
>                  }
>                  hash = mix32(k, hash);
>                  // Update the offset and length
>

That seems clearer, thanks.

This seems like the kind of code we might want fuzz test. It seems
quite unlikely otherwise we'd hit this case. I also wonder if

Thoughts?

I see in several places:

// Note: This fails to apply masking using 0xffffffffL to the seed.

Shouldn't this be in the Javadoc?

Gary
  

Re: [commons-codec] branch master updated: Change AssertionError to IllegalStateException

Posted by Gary Gregory <ga...@gmail.com>.
On Fri, Dec 27, 2019 at 8:17 PM <ah...@apache.org> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> aherbert pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/commons-codec.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>      new 1cf4d19  Change AssertionError to IllegalStateException
> 1cf4d19 is described below
>
> commit 1cf4d19069c64d0493f8b92178ffdb728c0c0ac2
> Author: Alex Herbert <ah...@apache.org>
> AuthorDate: Sat Dec 28 01:17:17 2019 +0000
>
>     Change AssertionError to IllegalStateException
> ---
>  src/main/java/org/apache/commons/codec/digest/MurmurHash3.java | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git
> a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> index d4a95ea..5d9aa9d 100644
> --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
> @@ -1054,7 +1054,7 @@ public final class MurmurHash3 {
>                      k = orBytes(unprocessed[0], unprocessed[1],
> unprocessed[2], data[offset]);
>                      break;
>                  default:
> -                    throw new AssertionError("Unprocessed length should
> be 1, 2, or 3: " + unprocessedLength);
> +                    throw new IllegalStateException("Unprocessed length
> should be 1, 2, or 3: " + unprocessedLength);
>                  }
>                  hash = mix32(k, hash);
>                  // Update the offset and length
>

That seems clearer, thanks.

This seems like the kind of code we might want fuzz test. It seems
quite unlikely otherwise we'd hit this case. I also wonder if

Thoughts?

I see in several places:

// Note: This fails to apply masking using 0xffffffffL to the seed.

Shouldn't this be in the Javadoc?

Gary