SOLR-13545: Fix for Java 8 (no var)

This commit is contained in:
David Smiley 2019-06-21 18:12:21 -04:00
parent df4ebaf030
commit 2d60b69636
2 changed files with 8 additions and 5 deletions

View File

@ -18,6 +18,7 @@ package org.apache.solr.client.solrj.request;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
@ -61,7 +62,7 @@ public class ContentStreamUpdateRequest extends AbstractUpdateRequest {
return new RequestWriter.ContentWriter() {
@Override
public void write(OutputStream os) throws IOException {
try(var inStream = stream.getStream()) {
try(InputStream inStream = stream.getStream()) {
IOUtils.copy(inStream, os);
}
}

View File

@ -22,6 +22,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.StringContains.containsString;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -72,6 +73,7 @@ import org.apache.solr.common.params.AnalysisParams;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.Pair;
@ -714,15 +716,15 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
Assert.assertEquals(0, rsp.getResults().getNumFound());
ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
var file = getFile("solrj/books.csv");
File file = getFile("solrj/books.csv");
final int opened[] = new int[] {0};
final int closed[] = new int[] {0};
var assertClosed = random().nextBoolean();
boolean assertClosed = random().nextBoolean();
if (assertClosed) {
var allBytes = Files.readAllBytes(file.toPath());
byte[] allBytes = Files.readAllBytes(file.toPath());
var contentStreamMock = new ContentStreamBase.ByteArrayStream(allBytes, "solrj/books.csv", "application/csv") {
ContentStream contentStreamMock = new ContentStreamBase.ByteArrayStream(allBytes, "solrj/books.csv", "application/csv") {
@Override
public InputStream getStream() throws IOException {
opened [0]++;