You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2013/07/10 17:07:24 UTC
svn commit: r1501782 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/
solr/core/src/test/org/apache/solr/store/blockcache/BlockDirectoryTest.java
Author: markrmiller
Date: Wed Jul 10 15:07:24 2013
New Revision: 1501782
URL: http://svn.apache.org/r1501782
Log:
SOLR-5026: org.apache.solr.store.blockcache.BlockDirectoryTest.testRandomAccessWrites would pass a 0 to random#next on 0 file size
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/store/blockcache/BlockDirectoryTest.java
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/store/blockcache/BlockDirectoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/store/blockcache/BlockDirectoryTest.java?rev=1501782&r1=1501781&r2=1501782&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/store/blockcache/BlockDirectoryTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/store/blockcache/BlockDirectoryTest.java Wed Jul 10 15:07:24 2013
@@ -179,11 +179,25 @@ public class BlockDirectoryTest extends
assertEquals(fsInput.length(), hdfsInput.length());
int fileLength = (int) fsInput.length();
for (int i = 0; i < reads; i++) {
- byte[] fsBuf = new byte[random.nextInt(Math.min(MAX_BUFFER_SIZE - MIN_BUFFER_SIZE, fileLength)) + MIN_BUFFER_SIZE];
+ int rnd;
+ if (fileLength == 0) {
+ rnd = 0;
+ } else {
+ rnd = random.nextInt(Math.min(MAX_BUFFER_SIZE - MIN_BUFFER_SIZE, fileLength));
+ }
+
+ byte[] fsBuf = new byte[rnd + MIN_BUFFER_SIZE];
byte[] hdfsBuf = new byte[fsBuf.length];
int offset = random.nextInt(fsBuf.length);
int length = random.nextInt(fsBuf.length - offset);
- int pos = random.nextInt(fileLength - length);
+
+ int pos;
+ if (fileLength == 0) {
+ pos = 0;
+ } else {
+ pos = random.nextInt(fileLength - length);
+ }
+
fsInput.seek(pos);
fsInput.readBytes(fsBuf, offset, length);
hdfsInput.seek(pos);