SOLR-12250: Create the temporary tlog file properly

This commit is contained in:
Cao Manh Dat 2018-06-06 15:50:19 +07:00
parent 2b406a57c4
commit 2f19ae1907
1 changed files with 7 additions and 3 deletions

View File

@ -17,8 +17,10 @@
package org.apache.solr.update;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Locale;
@ -29,9 +31,11 @@ import org.junit.Test;
public class TransactionLogTest extends LuceneTestCase {
@Test
public void testBigLastAddSize() throws IOException {
String tlogFileName = String.format(Locale.ROOT, UpdateLog.LOG_FILENAME_PATTERN, UpdateLog.TLOG_NAME, 0);
try (TransactionLog transactionLog = new TransactionLog(Files.createTempFile(tlogFileName, "").toFile(), new ArrayList<>())) {
public void testBigLastAddSize() {
String tlogFileName = String.format(Locale.ROOT, UpdateLog.LOG_FILENAME_PATTERN, UpdateLog.TLOG_NAME, Long.MAX_VALUE);
Path path = createTempDir();
File logFile = new File(path.toFile(), tlogFileName);
try (TransactionLog transactionLog = new TransactionLog(logFile, new ArrayList<>())) {
transactionLog.lastAddSize = 2000000000;
AddUpdateCommand updateCommand = new AddUpdateCommand(null);
updateCommand.solrDoc = new SolrInputDocument();