Skip to content

Commit

Permalink
Fix oracle#2030 : avoid ReusableStringReader for some analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
idodeclare committed Feb 8, 2020
1 parent a8b461b commit f1d994a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Copyright (c) 2012, https://stackoverflow.com/users/1270457/amas
* Copyright (c) 2012, https://stackoverflow.com/questions/11945728/how-to-use-termvector-lucene-4-0
* Portions Copyright (c) 2018, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2018, 2020, Chris Fraire <cfraire@me.com>.
*/

package org.opengrok.indexer.analysis;
Expand Down Expand Up @@ -61,16 +61,6 @@ public OGKTextField(String name, Reader reader, Store store) {
super(name, reader, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
}

/**
* Creates a new instance with {@code String} value.
* @param name field name
* @param value string value
* @param store store
*/
public OGKTextField(String name, String value, Store store) {
super(name, value, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
}

/**
* Creates a new un-stored instance with {@link TokenStream} value.
* @param name field name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2018-2019, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2018-2020, Chris Fraire <cfraire@me.com>.
*/
package org.opengrok.indexer.analysis.executables;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.StringReader;
import java.io.Writer;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
Expand Down Expand Up @@ -101,7 +102,7 @@ public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOExc
}

if (content != null && !content.isEmpty()) {
doc.add(new OGKTextField(QueryBuilder.FULL, content, Store.NO));
doc.add(new OGKTextField(QueryBuilder.FULL, new StringReader(content), Store.NO));
if (xrefOut != null) {
xrefOut.append("</pre>");
Util.htmlize(content, xrefOut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2018-2019, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2018-2020, Chris Fraire <cfraire@me.com>.
*/
package org.opengrok.indexer.analysis.executables;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -106,7 +107,7 @@ public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOExc
for (String name : FIELD_NAMES) {
if (jfbuilder.hasField(name)) {
String fstr = jfbuilder.write(name).toString();
doc.add(new OGKTextField(name, fstr, Store.NO));
doc.add(new OGKTextField(name, new StringReader(fstr), Store.NO));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2018-2019, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2018-2020, Chris Fraire <cfraire@me.com>.
*/
package org.opengrok.indexer.analysis.executables;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
Expand Down Expand Up @@ -151,13 +152,13 @@ void analyze(Document doc, InputStream in, Writer xrefOut,

if (jfbuilder == null) {
String dstr = dout.toString();
doc.add(new OGKTextField(QueryBuilder.DEFS, dstr, Store.NO));
doc.add(new OGKTextField(QueryBuilder.DEFS, new StringReader(dstr), Store.NO));

String rstr = rout.toString();
doc.add(new OGKTextField(QueryBuilder.REFS, rstr, Store.NO));
doc.add(new OGKTextField(QueryBuilder.REFS, new StringReader(rstr), Store.NO));

String fstr = fout.toString();
doc.add(new OGKTextField(QueryBuilder.FULL, fstr, Store.NO));
doc.add(new OGKTextField(QueryBuilder.FULL, new StringReader(fstr), Store.NO));
}
}

Expand Down

0 comments on commit f1d994a

Please sign in to comment.