From: <tho...@us...> - 2010-08-17 23:18:31
|
Revision: 3445 http://bigdata.svn.sourceforge.net/bigdata/?rev=3445&view=rev Author: thompsonbry Date: 2010-08-17 23:18:24 +0000 (Tue, 17 Aug 2010) Log Message: ----------- Fixes to several minor RingBuffer issues: https://sourceforge.net/apps/trac/bigdata/ticket/102 (RingBuffer::add/offer should throw NPE for a null arg) https://sourceforge.net/apps/trac/bigdata/ticket/103 (RingBuffer::scanHead/scanTail should treat a null nscan arg the same way) https://sourceforge.net/apps/trac/bigdata/ticket/104 (RingBuffer::contains should check for null arg) Modified Paths: -------------- trunk/bigdata/src/java/com/bigdata/cache/RingBuffer.java trunk/bigdata/src/test/com/bigdata/cache/TestRingBuffer.java Modified: trunk/bigdata/src/java/com/bigdata/cache/RingBuffer.java =================================================================== --- trunk/bigdata/src/java/com/bigdata/cache/RingBuffer.java 2010-08-13 12:13:42 UTC (rev 3444) +++ trunk/bigdata/src/java/com/bigdata/cache/RingBuffer.java 2010-08-17 23:18:24 UTC (rev 3445) @@ -154,7 +154,7 @@ public boolean add(final T ref) throws IllegalStateException { if (ref == null) - throw new IllegalArgumentException(); + throw new NullPointerException(); beforeOffer( ref ); @@ -178,7 +178,7 @@ public boolean offer(final T ref) { if (ref == null) - throw new IllegalArgumentException(); + throw new NullPointerException(); beforeOffer( ref ); @@ -491,10 +491,9 @@ */ final public boolean scanHead(final int nscan, final T ref) { - assert nscan > 0; -// if (nscan <= 0) -// throw new IllegalArgumentException(); -// + if (nscan <= 0) + throw new IllegalArgumentException(); + if (ref == null) throw new IllegalArgumentException(); Modified: trunk/bigdata/src/test/com/bigdata/cache/TestRingBuffer.java =================================================================== --- trunk/bigdata/src/test/com/bigdata/cache/TestRingBuffer.java 2010-08-13 12:13:42 UTC (rev 3444) +++ trunk/bigdata/src/test/com/bigdata/cache/TestRingBuffer.java 2010-08-17 23:18:24 UTC (rev 3445) @@ -425,8 +425,8 @@ try { buffer.add(null); - fail("Expecting: " + IllegalArgumentException.class); - } catch (IllegalArgumentException ex) { + fail("Expecting: " + NullPointerException.class); + } catch (NullPointerException ex) { if (log.isInfoEnabled()) log.info("Ignoring expected exception: " + ex); } @@ -438,8 +438,8 @@ try { buffer.offer(null); - fail("Expecting: " + IllegalArgumentException.class); - } catch (IllegalArgumentException ex) { + fail("Expecting: " + NullPointerException.class); + } catch (NullPointerException ex) { if (log.isInfoEnabled()) log.info("Ignoring expected exception: " + ex); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |