You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2013/04/23 12:47:16 UTC
[jira] [Commented] (DERBY-6196) ArrayIndexOutOfBoundsException in
SURQueryMixTest
[ https://issues.apache.org/jira/browse/DERBY-6196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13638943#comment-13638943 ]
Knut Anders Hatlen commented on DERBY-6196:
-------------------------------------------
This is the code that causes the exception:
// Replace a random value from the sample with the new value
int keyToReplace = Math.abs(r.nextInt())%k;
sampledKeys.set(keyToReplace, key);
Notice that the exception says the index is -3, whereas the code apparently ensures that the index is positive by calling Math.abs(int). However, Math.abs(int) may return a negative number if it is called on Integer.MIN_VALUE, since there is no positive integer that is large enough to hold it.
java.util.Random already has a method for drawing a random number in the interval [0,k). We should make the test use that method instead.
> ArrayIndexOutOfBoundsException in SURQueryMixTest
> -------------------------------------------------
>
> Key: DERBY-6196
> URL: https://issues.apache.org/jira/browse/DERBY-6196
> Project: Derby
> Issue Type: Bug
> Components: Test
> Affects Versions: 10.11.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Priority: Minor
>
> I got this failure when running suites.All on a patch for DERBY-6169 (although the part of the test that fails does not involve Derby, so I think it's not caused by the patch):
> java.lang.ArrayIndexOutOfBoundsException: -3
> at java.util.ArrayList.elementData(ArrayList.java:371)
> at java.util.ArrayList.set(ArrayList.java:399)
> at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURQueryMixTest.createRandomSample(SURQueryMixTest.java:211)
> at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURQueryMixTest.updateRandomSampleOfNRecords(SURQueryMixTest.java:268)
> at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURQueryMixTest.runTest(SURQueryMixTest.java:119)
> at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:117)
> at org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:442)
> at org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:459)
> at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
> at junit.extensions.TestSetup.run(TestSetup.java:27)
> at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
> at junit.extensions.TestSetup.run(TestSetup.java:27)
> at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
> at junit.extensions.TestSetup.run(TestSetup.java:27)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira