Skip to content

Commit

Permalink
Replace "UTF-8" with StandardCharsets.UTF_8
Browse files Browse the repository at this point in the history
  • Loading branch information
sabi0 committed Dec 25, 2023
1 parent 02722ee commit e41a526
Show file tree
Hide file tree
Showing 22 changed files with 312 additions and 594 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
package org.apache.lucene.backward_codecs.lucene40.blocktree;

import static java.nio.charset.StandardCharsets.UTF_8;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.Locale;
import org.apache.lucene.codecs.PostingsReaderBase;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;

/**
* BlockTree statistics for a single field returned by {@link FieldReader#getStats()}.
Expand Down Expand Up @@ -84,7 +84,7 @@ public class Stats {

/**
* Total number of bytes used to store term stats (not including what the {@link
* PostingsReaderBase} stores.
* PostingsReaderBase} stores).
*/
public long totalBlockStatsBytes;

Expand Down Expand Up @@ -179,12 +179,7 @@ void finish() {
@Override
public String toString() {
final ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
PrintStream out;
try {
out = new PrintStream(bos, false, IOUtils.UTF_8);
} catch (UnsupportedEncodingException bogus) {
throw new RuntimeException(bogus);
}
PrintStream out = new PrintStream(bos, false, UTF_8);

out.println(" index FST:");
out.println(" " + indexNumBytes + " bytes");
Expand Down Expand Up @@ -276,10 +271,6 @@ public String toString() {
assert totalBlockCount == total;
}

try {
return bos.toString(IOUtils.UTF_8);
} catch (UnsupportedEncodingException bogus) {
throw new RuntimeException(bogus);
}
return bos.toString(UTF_8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.InfoStream;
import org.apache.lucene.util.Version;
import org.junit.AfterClass;
Expand Down Expand Up @@ -946,7 +945,7 @@ public void testUnsupportedOldIndexes() throws Exception {

ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
CheckIndex checker = new CheckIndex(dir);
checker.setInfoStream(new PrintStream(bos, false, IOUtils.UTF_8));
checker.setInfoStream(new PrintStream(bos, false, UTF_8));
CheckIndex.Status indexStatus = checker.checkIndex();
if (unsupportedNames[i].startsWith("8.")) {
assertTrue(indexStatus.clean);
Expand All @@ -956,8 +955,8 @@ public void testUnsupportedOldIndexes() throws Exception {
// IndexFormatTooOldException
// or an IllegalArgumentException saying that the codec doesn't exist.
boolean formatTooOld =
bos.toString(IOUtils.UTF_8).contains(IndexFormatTooOldException.class.getName());
boolean missingCodec = bos.toString(IOUtils.UTF_8).contains("Could not load codec");
bos.toString(UTF_8).contains(IndexFormatTooOldException.class.getName());
boolean missingCodec = bos.toString(UTF_8).contains("Could not load codec");
assertTrue(formatTooOld || missingCodec);
}
checker.close();
Expand Down Expand Up @@ -1123,9 +1122,9 @@ private void doTestHits(ScoreDoc[] hits, int expectedCount, IndexReader reader)
assertEquals("wrong number of hits", expectedCount, hitCount);
StoredFields storedFields = reader.storedFields();
TermVectors termVectors = reader.termVectors();
for (int i = 0; i < hitCount; i++) {
storedFields.document(hits[i].doc);
termVectors.get(hits[i].doc);
for (ScoreDoc hit : hits) {
storedFields.document(hit.doc);
termVectors.get(hit.doc);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.lucene.benchmark.byTask.feeds;

import static java.nio.charset.StandardCharsets.UTF_8;

import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -35,7 +37,6 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.util.IOUtils;

/** Tests the functionality of {@link DocMaker}. */
public class TestDocMaker extends BenchmarkTestCase {
Expand Down Expand Up @@ -164,7 +165,7 @@ public void testDocMakerLeak() throws Exception {
// DocMaker did not close its ContentSource if resetInputs was called twice,
// leading to a file handle leak.
Path f = getWorkDir().resolve("docMakerLeak.txt");
PrintStream ps = new PrintStream(Files.newOutputStream(f), true, IOUtils.UTF_8);
PrintStream ps = new PrintStream(Files.newOutputStream(f), true, UTF_8);
ps.println("one title\t" + random().nextLong() + "\tsome content");
ps.close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
package org.apache.lucene.codecs.lucene90.blocktree;

import static java.nio.charset.StandardCharsets.UTF_8;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.Locale;
import org.apache.lucene.codecs.PostingsReaderBase;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;

/**
* BlockTree statistics for a single field returned by {@link FieldReader#getStats()}.
Expand Down Expand Up @@ -84,7 +84,7 @@ public class Stats {

/**
* Total number of bytes used to store term stats (not including what the {@link
* PostingsReaderBase} stores.
* PostingsReaderBase} stores).
*/
public long totalBlockStatsBytes;

Expand Down Expand Up @@ -179,12 +179,7 @@ void finish() {
@Override
public String toString() {
final ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
PrintStream out;
try {
out = new PrintStream(bos, false, IOUtils.UTF_8);
} catch (UnsupportedEncodingException bogus) {
throw new RuntimeException(bogus);
}
PrintStream out = new PrintStream(bos, false, UTF_8);

out.println(" index FST:");
out.println(" " + indexNumBytes + " bytes");
Expand Down Expand Up @@ -276,10 +271,6 @@ public String toString() {
assert totalBlockCount == total;
}

try {
return bos.toString(IOUtils.UTF_8);
} catch (UnsupportedEncodingException bogus) {
throw new RuntimeException(bogus);
}
return bos.toString(UTF_8);
}
}
Loading

0 comments on commit e41a526

Please sign in to comment.