Skip to content

Apache Lucene open-source search software

Correcting getByte() sensitive to local file.encoding.

Dawid Weisse91e59af9507
diff --git a/lucene/core/src/test/org/apache/lucene/document/TestDocument.java b/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
index a75f396e20c..d33116bc607 100644
--- a/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
+++ b/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
@@ -51,8 +51,8 @@ public class TestDocument extends LuceneTestCase {
FieldType ft = new FieldType();
ft.setStored(true);
IndexableField stringFld = new Field("string", binaryVal, ft);
- IndexableField binaryFld = new StoredField("binary", binaryVal.getBytes());
- IndexableField binaryFld2 = new StoredField("binary", binaryVal2.getBytes());
+ IndexableField binaryFld = new StoredField("binary", binaryVal.getBytes("UTF-8"));
+ IndexableField binaryFld2 = new StoredField("binary", binaryVal2.getBytes("UTF-8"));
doc.add(stringFld);
doc.add(binaryFld);
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java
index 912a4dc7cdf..4ffee9d222a 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java
@@ -166,7 +166,7 @@ public class TestNumericRangeQueryBuilder extends LuceneTestCase {
private static Document getDocumentFromString(String str)
throws SAXException, IOException, ParserConfigurationException {
- InputStream is = new ByteArrayInputStream(str.getBytes());
+ InputStream is = new ByteArrayInputStream(str.getBytes("UTF-8"));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
diff --git a/lucene/test-framework/src/java/org/apache/lucene/analysis/MockPayloadAnalyzer.java b/lucene/test-framework/src/java/org/apache/lucene/analysis/MockPayloadAnalyzer.java
index c94ce4bdffb..2c17c78b3cf 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/analysis/MockPayloadAnalyzer.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/analysis/MockPayloadAnalyzer.java
@@ -67,7 +67,7 @@ final class MockPayloadFilter extends TokenFilter {
@Override
public boolean incrementToken() throws IOException {
if (input.incrementToken()) {
- payloadAttr.setPayload(new BytesRef(("pos: " + pos).getBytes()));
+ payloadAttr.setPayload(new BytesRef(("pos: " + pos).getBytes("UTF-8")));
int posIncr;
if (pos == 0 || i % 2 == 1) {
posIncr = 1;