mirror of https://github.com/apache/lucene.git
LUCENE-6752: Add Math#random() to forbiddenapis
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1697050 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
567de2a357
commit
7a93c3e6f1
|
@ -104,6 +104,11 @@ Build
|
|||
detect javadoc-style license headers. Use Groovy to implement the
|
||||
checks instead of plain Ant. (Uwe Schindler)
|
||||
|
||||
Tests
|
||||
|
||||
* LUCENE-6752: Add Math#random() to forbiddenapis. (Uwe Schindler,
|
||||
Mikhail Khludnev, Andrei Beliakov)
|
||||
|
||||
Changes in Backwards Compatibility Policy
|
||||
|
||||
* LUCENE-6742: The Lovins & Finnish implementation of SnowballFilter
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.lucene.index;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.lucene.analysis.*;
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
|
@ -73,12 +74,13 @@ public class TestTermVectorsReader extends LuceneTestCase {
|
|||
|
||||
Arrays.sort(testTerms);
|
||||
int tokenUpto = 0;
|
||||
Random rnd = random();
|
||||
for (int i = 0; i < testTerms.length; i++) {
|
||||
positions[i] = new int[TERM_FREQ];
|
||||
// first position must be 0
|
||||
for (int j = 0; j < TERM_FREQ; j++) {
|
||||
// positions are always sorted in increasing order
|
||||
positions[i][j] = (int) (j * 10 + Math.random() * 10);
|
||||
positions[i][j] = (int) (j * 10 + rnd.nextDouble() * 10);
|
||||
TestToken token = tokens[tokenUpto++] = new TestToken();
|
||||
token.text = testTerms[i];
|
||||
token.pos = positions[i][j];
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
|
@ -654,8 +655,9 @@ public abstract class BaseCompoundFormatTestCase extends BaseIndexFileFormatTest
|
|||
/** Creates a file of the specified size with random data. */
|
||||
protected static void createRandomFile(Directory dir, String name, int size) throws IOException {
|
||||
IndexOutput os = dir.createOutput(name, newIOContext(random()));
|
||||
Random rnd = random();
|
||||
for (int i=0; i<size; i++) {
|
||||
byte b = (byte) (Math.random() * 256);
|
||||
byte b = (byte) rnd.nextInt(256);
|
||||
os.writeByte(b);
|
||||
}
|
||||
os.close();
|
||||
|
|
|
@ -1114,9 +1114,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
|
|||
IndexOutput os = dir.createOutput("testBufferStart.txt", newIOContext(random()));
|
||||
|
||||
byte[] largeBuf = new byte[2048];
|
||||
for (int i=0; i<largeBuf.length; i++) {
|
||||
largeBuf[i] = (byte) (Math.random() * 256);
|
||||
}
|
||||
random().nextBytes(largeBuf);
|
||||
|
||||
long currentPos = os.getFilePointer();
|
||||
os.writeBytes(largeBuf, largeBuf.length);
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
|
||||
junit.framework.TestCase @ All classes should derive from LuceneTestCase
|
||||
|
||||
java.util.Random#<init>() @ Use RandomizedRunner's random instead
|
||||
java.util.Random#<init>() @ Use RandomizedRunner's random() instead
|
||||
java.lang.Math#random() @ Use RandomizedRunner's random().nextDouble() instead
|
||||
|
||||
# TODO: fix tests that do this!
|
||||
#java.lang.System#currentTimeMillis() @ Don't depend on wall clock times
|
||||
|
|
Loading…
Reference in New Issue