Commit 92861224 authored by Mihai Nita's avatar Mihai Nita

Eliminate memory leaks (as reported by Eclipse)

parent 10b2157f
......@@ -231,8 +231,8 @@ public final class IntegrationtestUtils {
if (paramters != null) {
filter.setParameters((IParameters) paramters);
}
try {
filter.open(new RawDocument(snippet, LocaleId.ENGLISH));
try (RawDocument rawDoc = new RawDocument(snippet, LocaleId.ENGLISH)) {
filter.open(rawDoc);
while (filter.hasNext()) {
Event event = filter.next();
list.add(event);
......
......@@ -79,31 +79,33 @@ public final class RoundTripUtils {
// Filter events to raw document final step (using the XLIFF writer)
FilterEventsWriterStep fewStep = new FilterEventsWriterStep();
XLIFFWriter writer = new XLIFFWriter();
fewStep.setFilterWriter(writer);
XLIFFWriterParameters params = (XLIFFWriterParameters)writer.getParameters();
params.setPlaceholderMode(false);
params.setIncludeAltTrans(true);
params.setEscapeGt(true);
params.setIncludeCodeAttrs(true);
params.setCopySource(true);
params.setIncludeIts(true);
params.setIncludeNoTranslate(true);
params.setToolId("okapi");
params.setToolName("okapi-tests");
params.setToolCompany("okapi");
params.setToolVersion("M29");
fewStep.setDocumentRoots(Util.getDirectoryName(originalPath));
driver.addStep(fewStep);
try (XLIFFWriter writer = new XLIFFWriter();
RawDocument originalDoc = new RawDocument(Util.toURI(originalPath), StandardCharsets.UTF_8.name(), source, target)) {
fewStep.setFilterWriter(writer);
XLIFFWriterParameters params = writer.getParameters();
params.setPlaceholderMode(false);
params.setIncludeAltTrans(true);
params.setEscapeGt(true);
params.setIncludeCodeAttrs(true);
params.setCopySource(true);
params.setIncludeIts(true);
params.setIncludeNoTranslate(true);
params.setToolId("okapi");
params.setToolName("okapi-tests");
params.setToolCompany("okapi");
params.setToolVersion("M29");
RawDocument originalDoc = new RawDocument(Util.toURI(originalPath), StandardCharsets.UTF_8.name(), source, target);
originalDoc.setFilterConfigId(filterConfig);
fewStep.setDocumentRoots(Util.getDirectoryName(originalPath));
driver.addStep(fewStep);
originalDoc.setFilterConfigId(filterConfig);
driver.addBatchItem(originalDoc, new File(outputPath).toURI(), StandardCharsets.UTF_8.name());
driver.addBatchItem(originalDoc, new File(outputPath).toURI(), StandardCharsets.UTF_8.name());
// Process
driver.processBatch();
// Process
driver.processBatch();
}
}
public static void merge(LocaleId source, LocaleId target, Boolean legacy, String originalPath, String xlfPath, String outputPath, String filterConfig, String customConfigPath) throws URISyntaxException {
......@@ -120,25 +122,27 @@ public final class RoundTripUtils {
mapper.updateCustomConfigurations();
}
RawDocument originalDoc = new RawDocument(Util.toURI(originalPath), StandardCharsets.UTF_8.name(), source, target);
originalDoc.setFilterConfigId(filterConfig);
try (RawDocument originalDoc = new RawDocument(Util.toURI(originalPath), StandardCharsets.UTF_8.name(), source, target);
RawDocument xlfDoc = new RawDocument(Util.toURI(xlfPath), StandardCharsets.UTF_8.name(), source, target)) {
originalDoc.setFilterConfigId(filterConfig);
IPipelineDriver driver = new PipelineDriver();
driver.setFilterConfigurationMapper(mapper);
BatchItemContext bic = new BatchItemContext(
new RawDocument(Util.toURI(xlfPath), StandardCharsets.UTF_8.name(), source, target),
Util.toURI(outputPath),
StandardCharsets.UTF_8.name(),
originalDoc);
driver.addBatchItem(bic);
if (legacy) {
driver.addStep(new LegacyXliffMergerStep());
} else {
driver.addStep(new OriginalDocumentXliffMergerStep());
IPipelineDriver driver = new PipelineDriver();
driver.setFilterConfigurationMapper(mapper);
BatchItemContext bic = new BatchItemContext(
xlfDoc,
Util.toURI(outputPath),
StandardCharsets.UTF_8.name(),
originalDoc);
driver.addBatchItem(bic);
if (legacy) {
driver.addStep(new LegacyXliffMergerStep());
} else {
driver.addStep(new OriginalDocumentXliffMergerStep());
}
driver.addStep(new RawDocumentWriterStep());
driver.processBatch();
driver.destroy();
}
driver.addStep(new RawDocumentWriterStep());
driver.processBatch();
driver.destroy();
}
/**
......
package net.sf.okapi.common.pipeline.integration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
......@@ -43,54 +44,58 @@ public class FilterEventsToRawDocumentStepTestIT
Event event = null;
eventToDoc = new FilterEventsToRawDocumentStep();
RawDocument rawDoc = new RawDocument(htmlSnippet, locEN);
File tmpFile = File.createTempFile("~okapi-1_", ".tmp");
eventToDoc.setOutputURI(tmpFile.toURI());
eventToDoc.setOutputEncoding("UTF-8");
try (RawDocument rawDoc = new RawDocument(htmlSnippet, locEN)) {
File tmpFile = File.createTempFile("~okapi-1_", ".tmp");
eventToDoc.setOutputURI(tmpFile.toURI());
eventToDoc.setOutputEncoding("UTF-8");
htmlFilter.open(rawDoc);
while (htmlFilter.hasNext()) {
event = eventToDoc.handleEvent(htmlFilter.next());
}
htmlFilter.close();
htmlFilter.open(rawDoc);
while (htmlFilter.hasNext()) {
event = eventToDoc.handleEvent(htmlFilter.next());
}
htmlFilter.close();
// last event should be RawDocument
assertTrue(event.getEventType() == EventType.RAW_DOCUMENT);
// Get the EventsToRawDocumentStep output and compare it to our input
assertEquals(htmlSnippet, convertRawDocumentToString((RawDocument)event.getResource()));
eventToDoc.destroy();
assertNotNull(event);
// last event should be RawDocument
assertTrue(event.getEventType() == EventType.RAW_DOCUMENT);
// Get the EventsToRawDocumentStep output and compare it to our input
assertEquals(htmlSnippet, convertRawDocumentToString((RawDocument)event.getResource()));
eventToDoc.destroy();
}
}
@Test
public void htmlEventsToRawDocument() throws IOException {
Event event = null;
eventToDoc = new FilterEventsToRawDocumentStep();
RawDocument rawDoc = new RawDocument(htmlSnippet, locEN);
eventToDoc.setOutputEncoding("UTF-8");
try (RawDocument rawDoc = new RawDocument(htmlSnippet, locEN)) {
eventToDoc.setOutputEncoding("UTF-8");
htmlFilter.open(rawDoc);
while ( htmlFilter.hasNext() ) {
event = eventToDoc.handleEvent(htmlFilter.next());
}
htmlFilter.close();
htmlFilter.open(rawDoc);
while ( htmlFilter.hasNext() ) {
event = eventToDoc.handleEvent(htmlFilter.next());
}
htmlFilter.close();
// last event should be RawDocument
assertTrue(event.getEventType() == EventType.RAW_DOCUMENT);
// Get the EventsToRawDocumentStep output and compare it to our input
assertEquals(htmlSnippet, convertRawDocumentToString((RawDocument)event.getResource()));
eventToDoc.destroy();
assertNotNull(event);
// last event should be RawDocument
assertTrue(event.getEventType() == EventType.RAW_DOCUMENT);
// Get the EventsToRawDocumentStep output and compare it to our input
assertEquals(htmlSnippet, convertRawDocumentToString((RawDocument)event.getResource()));
eventToDoc.destroy();
}
}
private String convertRawDocumentToString(RawDocument d) throws IOException {
int c;
StringWriter sw = new StringWriter();
Reader r = d.getReader();
while ( true ) {
c = r.read();
if (c == -1) break;
sw.append((char) c);
try (Reader r = d.getReader()) {
while ( true ) {
c = r.read();
if (c == -1) break;
sw.append((char) c);
}
}
d.getReader().close();
return sw.toString();
}
}
......@@ -63,27 +63,27 @@ public class FilterRoundtripTestIT
@Test
public void runPipelineFromString() {
driver.clearItems();
RawDocument rd = new RawDocument(
"<p>Before <input type=\"radio\" name=\"FavouriteFare\" value=\"spam\" checked=\"checked\"/> after.</p>",
locEN, locES);
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "genericOutput.txt")).toURI(), "UTF-8");
driver.processBatch();
assertEquals("spam",
PipelineTestUtil.getFirstTUSource(new RawDocument((new File(root, "genericOutput.txt")).toURI(),
"UTF-8", locES)));
try (RawDocument rd = new RawDocument(
"<p>Before <input type=\"radio\" name=\"FavouriteFare\" value=\"spam\" checked=\"checked\"/> after.</p>",
locEN, locES);
RawDocument rawDoc = new RawDocument((new File(root, "genericOutput.txt")).toURI(), "UTF-8", locES)) {
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "genericOutput.txt")).toURI(), "UTF-8");
driver.processBatch();
assertEquals("spam", PipelineTestUtil.getFirstTUSource(rawDoc));
}
}
@Test
public void runPipelineFromStream() {
driver.clearItems();
RawDocument rd = new RawDocument("\nX\n\nY\n", locEN, locFR);
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "genericOutput.txt")).toURI(), "UTF-8");
driver.processBatch();
assertEquals("X Y",
PipelineTestUtil.getFirstTUSource(new RawDocument((new File(root, "genericOutput.txt")).toURI(),
"UTF-8", locFR)));
try (RawDocument rd = new RawDocument("\nX\n\nY\n", locEN, locFR);
RawDocument rawDoc = new RawDocument((new File(root, "genericOutput.txt")).toURI(), "UTF-8", locFR)) {
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "genericOutput.txt")).toURI(), "UTF-8");
driver.processBatch();
assertEquals("X Y", PipelineTestUtil.getFirstTUSource(rawDoc));
}
}
@Test
......@@ -91,22 +91,24 @@ public class FilterRoundtripTestIT
String snippet = "<b>TEST ME</b>";
// First pass
driver.clearItems();
RawDocument rd = new RawDocument(snippet, locEN, locES);
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "output1.html")).toURI(), "UTF-8");
driver.processBatch();
try (RawDocument rd = new RawDocument(snippet, locEN, locES)) {
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "output1.html")).toURI(), "UTF-8");
driver.processBatch();
}
// Second pass
driver.clearItems();
rd = new RawDocument((new File(root, "output1.html")).toURI(), "UTF-8", locES, locEN);
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "output2.html")).toURI(), "UTF-8");
driver.processBatch();
try (RawDocument rd = new RawDocument((new File(root, "output1.html")).toURI(), "UTF-8", locES, locEN)) {
rd.setFilterConfigId("okf_html");
driver.addBatchItem(rd, (new File(root, "output2.html")).toURI(), "UTF-8");
driver.processBatch();
}
// Check result
assertEquals(snippet,
PipelineTestUtil.getFirstTUSource(new RawDocument((new File(root, "output2.html")).toURI(),
"UTF-8", locES)));
try (RawDocument rd = new RawDocument((new File(root, "output2.html")).toURI(), "UTF-8", locES)) {
assertEquals(snippet, PipelineTestUtil.getFirstTUSource(rd));
}
}
@After
......
......@@ -81,18 +81,22 @@ public class MultistepPipelineTestIT
RawDocument rawDoc = new RawDocument(getUri("test01.xml"), "UTF-8", locEN, locFR);
rawDoc.setFilterConfigId("okf_xml");
driver.addBatchItem(rawDoc, getOutputUri("test01.xml"), "UTF-8");
rawDoc.close();
rawDoc = new RawDocument(getUri("test02.xml"), "UTF-8", locEN, locFR);
rawDoc.setFilterConfigId("okf_xml");
driver.addBatchItem(rawDoc, getOutputUri("test02.xml"), "UTF-8");
rawDoc.close();
rawDoc = new RawDocument(getUri("test03.xml"), "UTF-8", locEN, locFR);
rawDoc.setFilterConfigId("okf_xml");
driver.addBatchItem(rawDoc, getOutputUri("test03.xml"), "UTF-8");
rawDoc.close();
rawDoc = new RawDocument(getUri("test04.xml"), "UTF-8", locEN, locFR);
rawDoc.setFilterConfigId("okf_xml");
driver.addBatchItem(rawDoc, getOutputUri("test04.xml"), "UTF-8");
rawDoc.close();
driver.processBatch();
......@@ -119,16 +123,17 @@ public class MultistepPipelineTestIT
driver.addStep(step3);
// Set the info for the input and output
RawDocument rawDoc = new RawDocument(getUri("okapi_intro_test.html"), "UTF-8", locEN, locFR);
rawDoc.setFilterConfigId("okf_html");
driver.addBatchItem(rawDoc);
try (RawDocument rawDoc = new RawDocument(getUri("okapi_intro_test.html"), "UTF-8", locEN, locFR)) {
rawDoc.setFilterConfigId("okf_html");
driver.addBatchItem(rawDoc);
driver.processBatch();
driver.processBatch();
assertTrue(step3.isFound());
assertTrue(step3.isFound());
driver.clearItems();
driver.clearSteps();
driver.clearItems();
driver.clearSteps();
}
}
@Test
......@@ -149,16 +154,17 @@ public class MultistepPipelineTestIT
driver.addStep(findStep);
// Set the info for the input and output
RawDocument rawDoc = new RawDocument(getUri("okapi_intro_test.html"), "UTF-8", locEN, locFR);
rawDoc.setFilterConfigId("okf_html");
driver.addBatchItem(rawDoc, getOutputUri("okapi_intro_test.html"), "UTF-8");
try (RawDocument rawDoc = new RawDocument(getUri("okapi_intro_test.html"), "UTF-8", locEN, locFR)) {
rawDoc.setFilterConfigId("okf_html");
driver.addBatchItem(rawDoc, getOutputUri("okapi_intro_test.html"), "UTF-8");
driver.processBatch();
driver.processBatch();
assertTrue(findStep.isFound());
assertTrue(findStep.isFound());
driver.clearItems();
driver.clearSteps();
driver.clearItems();
driver.clearSteps();
}
}
@Test
......@@ -173,14 +179,17 @@ public class MultistepPipelineTestIT
RawDocument rawDoc = new RawDocument(getUri("Test01.properties"), "UTF-8", locEN, locEUES);
rawDoc.setFilterConfigId("okf_properties");
driver.addBatchItem(rawDoc, getOutputUri("Test01.properties"), "UTF-8");
rawDoc.close();
rawDoc = new RawDocument(getUri("Test02.properties"), "UTF-8", locEN, locEUES);
rawDoc.setFilterConfigId("okf_properties");
driver.addBatchItem(rawDoc, getOutputUri("Test02.properties"), "UTF-8");
rawDoc.close();
rawDoc = new RawDocument(getUri("Test03.properties"), "UTF-8", locEN, locEUES);
rawDoc.setFilterConfigId("okf_properties");
driver.addBatchItem(rawDoc, getOutputUri("Test03.properties"), "UTF-8");
rawDoc.close();
driver.processBatch();
......@@ -203,16 +212,17 @@ public class MultistepPipelineTestIT
driver.addStep(new FilterEventsWriterStep());
// Set the info for the input and output
RawDocument rawDoc = new RawDocument(getUri("Test01.properties"), "UTF-8", locEN);
rawDoc.setFilterConfigId("okf_properties");
driver.addBatchItem(rawDoc, getOutputUri("Test01.properties"), "UTF-8");
try (RawDocument rawDoc = new RawDocument(getUri("Test01.properties"), "UTF-8", locEN)) {
rawDoc.setFilterConfigId("okf_properties");
driver.addBatchItem(rawDoc, getOutputUri("Test01.properties"), "UTF-8");
driver.processBatch();
driver.processBatch();
assertTrue((new File(getOutputUri("Test01.properties"))).exists());
assertTrue((new File(getOutputUri("Test01.properties"))).exists());
driver.clearItems();
driver.clearSteps();
driver.clearItems();
driver.clearSteps();
}
}
private URI getUri(String fileName) throws URISyntaxException {
......
......@@ -29,6 +29,7 @@ import org.junit.Test;
public class QueryManagerTestIT
{
private QueryManager qm;
private PensieveTMConnector pensieveConnector;
private final LocaleId locENUS = LocaleId.fromString("EN-US");
private final LocaleId locFRFR = LocaleId.fromString("FR-FR");
......@@ -51,7 +52,7 @@ public class QueryManagerTestIT
qm.setRootDirectory(rootDir);
qm.setLanguages(locENUS, locFRFR);
PensieveTMConnector pensieveConnector = new PensieveTMConnector();
pensieveConnector = new PensieveTMConnector();
net.sf.okapi.connectors.pensieve.Parameters p = new net.sf.okapi.connectors.pensieve.Parameters();
p.setDbDirectory(Util.ROOT_DIRECTORY_VAR);
qm.addAndInitializeResource(
......@@ -66,6 +67,10 @@ public class QueryManagerTestIT
qm.close();
qm = null;
}
if (pensieveConnector != null) {
pensieveConnector.close();
pensieveConnector = null;
}
}
@Test
......
......@@ -53,44 +53,44 @@ public class XsltPipelineTestIT
// Input resource
URL inputXml = XsltPipelineTestIT.class.getResource("test.xml");
// Make copy of input
InputStream in1 = XsltPipelineTestIT.class.getResourceAsStream("identity.xsl");
driver.addStep(new XsltTransformStep(in1));
try (InputStream in1 = XsltPipelineTestIT.class.getResourceAsStream("identity.xsl");
InputStream in2 = XsltPipelineTestIT.class.getResourceAsStream("remove_b_tags.xsl");
RawDocument rd = new RawDocument(inputXml.toURI(), "UTF-8", locEN)) {
// Make copy of input
driver.addStep(new XsltTransformStep(in1));
// Remove b tags from input
InputStream in2 = XsltPipelineTestIT.class.getResourceAsStream("remove_b_tags.xsl");
driver.addStep(new XsltTransformStep(in2));
// Remove b tags from input
driver.addStep(new XsltTransformStep(in2));
// Filtering step - converts resource to events
driver.addStep(new RawDocumentToFilterEventsStep());
// Filtering step - converts resource to events
driver.addStep(new RawDocumentToFilterEventsStep());
// Writer step - converts events to a resource
driver.addStep(new FilterEventsWriterStep());
// Writer step - converts events to a resource
driver.addStep(new FilterEventsWriterStep());
RawDocument rd = new RawDocument(inputXml.toURI(), "UTF-8", locEN);
rd.setFilterConfigId("okf_xml");
File outFile = new File(root, "output.xml");
driver.addBatchItem(rd, outFile.toURI(), "UTF-8");
driver.processBatch();
rd.setFilterConfigId("okf_xml");
File outFile = new File(root, "output.xml");
driver.addBatchItem(rd, outFile.toURI(), "UTF-8");
driver.processBatch();
// Read the result and compare
StringBuilder tmp = new StringBuilder();
BufferedReader reader;
reader = new BufferedReader(
new InputStreamReader(new FileInputStream(outFile), "UTF-8"));
char[] buf = new char[2048];
int count;
while ((count = reader.read(buf)) != -1) {
tmp.append(buf, 0, count);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(outFile), "UTF-8"))) {
char[] buf = new char[2048];
int count;
while ((count = reader.read(buf)) != -1) {
tmp.append(buf, 0, count);
}
}
//Remove new lines so this test will pass on all OSes
String tmpStr = tmp.toString().replaceAll("\n", "");
tmpStr = tmpStr.replaceAll("\r", "");
reader.close();
// Remove new lines so this test will pass on all OSes
String tmpStr = tmp.toString().replaceAll("\n", "").replaceAll("\r", "");
assertEquals(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><start fileID=\"02286_000_000\"><para id=\"1\">This is a test with .</para></start>",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<start fileID=\"02286_000_000\">"
+ "<para id=\"1\">This is a test with .</para>"
+ "</start>",
tmpStr);
}
}
}
......@@ -2,6 +2,7 @@ package net.sf.okapi.common.pipeline.integration;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
......@@ -62,30 +63,26 @@ public class XsltTransformStep
ByteArrayOutputStream tempStream = new ByteArrayOutputStream();
// get the input xml and xslt streams
Reader XmlInput = ((RawDocument)event.getResource()).getReader();
Source xmlSource = new StreamSource(XmlInput);
Source xsltSource = new StreamSource(xstlInputstream);
try (Reader XmlInput = ((RawDocument)event.getResource()).getReader()) {
Result result = new StreamResult(tempStream);
Source xmlSource = new StreamSource(XmlInput);
Source xsltSource = new StreamSource(xstlInputstream);
TransformerFactory transFact = TransformerFactory.newInstance();
Transformer trans;
try {
trans = transFact.newTransformer(xsltSource);
Result result = new StreamResult(tempStream);
TransformerFactory transFact = TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
// do the transformation
trans.transform(xmlSource, result);
} catch (TransformerConfigurationException e) {
throw new OkapiException(e);
} catch (TransformerException e) {
ByteArrayInputStream transformedInput = new ByteArrayInputStream(tempStream.toByteArray());
// overwrite our event to the new transformed content
// Possible memory leak, but we can't close the raw doc here, because we need to read from it
event.setResource(new RawDocument(transformedInput, "UTF-8", locEN));
} catch (TransformerException | IOException e) {
throw new OkapiException(e);
}
ByteArrayInputStream transformedInput = new ByteArrayInputStream(tempStream.toByteArray());
// overwrite our event to the new transformed content
event.setResource(new RawDocument(transformedInput, "UTF-8", locEN));
// this step is done generating events
done = true;
......
......@@ -42,6 +42,8 @@ public class DocxMemoryLeakTestIT
PipelineDriver pd = simplePipeline();
for (int i = 0; i <= 10000000L; i++) {
// Intentional memory leak for testing
@SuppressWarnings("resource")
RawDocument rd = new RawDocument(getUri("/docx/OpenXML_text_reference_v1_2.docx"), "UTF-8", locEN);
rd.setFilterConfigId("okf_openxml");
pd.addBatchItem(rd, (new File("genericOutput.txt")).toURI(), "UTF-8");
......
......@@ -43,6 +43,8 @@ public class HtmlMemoryLeakTestIT
PipelineDriver pd = simplePipeline();
for (int i = 0; i <= 10000000L; i++) {
// Intentional memory leak for testing
@SuppressWarnings("resource")
RawDocument rd = new RawDocument(getUri("/html/testBOM.html"), "UTF-8", locEN);
rd.setFilterConfigId("okf_html");
pd.addBatchItem(rd, (new File("genericOutput.txt")).toURI(), "UTF-8");
......
......@@ -43,6 +43,8 @@ public class PlainTextMemoryLeakTestIT
PipelineDriver pd = simplePipeline();
for (int i = 0; i <= 10000000L; i++) {
// Intentional memory leak for testing
@SuppressWarnings("resource")
RawDocument rd = new RawDocument(getUri("/plaintext/lgpl.txt"), "UTF-8", locEN);
rd.setFilterConfigId("okf_plaintext");
pd.addBatchItem(rd, (new File("genericOutput.txt")).toURI(), "UTF-8");
......
......@@ -43,6 +43,8 @@ public class RegexMemoryLeakTestIT
PipelineDriver pd = simplePipeline();
for (int i = 0; i <= 10000000L; i++) {
// Intentional memory leak for testing
@SuppressWarnings("resource")
RawDocument rd = new RawDocument(getUri("/plaintext/lgpl.txt"), "UTF-8", locEN);
rd.setFilterConfigId("okf_regex");
pd.addBatchItem(rd, (new File("genericOutput.txt")).toURI(), "UTF-8");
......
......@@ -31,6 +31,8 @@ public class SimpleDocxMemoryLeakTestIT
setUp();
for (int i = 0; i <= 10000000L; i++) {
// Intentional memory leak for testing
@SuppressWarnings("resource")
RawDocument rd = new RawDocument(getUri("/docx/OpenXML_text_reference_v1_2.docx"), "UTF-8", locEN);
rd.setFilterConfigId("okf_openxml");
OpenXMLFilter f = new OpenXMLFilter();
......
......@@ -43,6 +43,8 @@ public class TableMemoryLeakTestIT
PipelineDriver pd = simplePipeline();
for (int i = 0; i <= 10000000L; i++) {
// Intentional memory leak for testing
@SuppressWarnings("resource")
RawDocument rd = new RawDocument(getUri("/table/test2cols.csv"), "UTF-8", locEN);
rd.setFilterConfigId("okf_table_csv");
pd.addBatchItem(rd, (new File("genericOutput.txt")).toURI(), "UTF-8");
......
......@@ -43,6 +43,8 @@ public class XmlMemoryLeakTestIT
PipelineDriver pd = simplePipeline();
for (int i = 0; i <= 10000000L; i++) {
// Intentional memory leak for testing
@SuppressWarnings("resource")
RawDocument rd = new RawDocument(getUri("/xml/input.xml"), "UTF-8", locEN);
rd.setFilterConfigId("okf_xml");
pd.addBatchItem(rd, (new File("genericOutput.txt")).toURI(), "UTF-8");
......