<commit_before>package imcode.server.document.index;

import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.util.PDFTextStripper;
import org.apache.log4j.Logger;

import java.io.InputStream;
import java.io.IOException;

class PdfTextExtractor implements StreamTextsExtractor {

    public String[] extractTexts(InputStream in) throws IOException {
        PDDocument pdf = PDDocument.load(in);
        PDFTextStripper stripper = new PDFTextStripper();
        String text = stripper.getText(pdf) ;
        return new String[] {text} ;
    }
}<commit_msg>Issue 6132: Properly close PDF document after use.<commit_after>package imcode.server.document.index;

import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.util.PDFTextStripper;

import java.io.IOException;
import java.io.InputStream;

class PdfTextExtractor implements StreamTextsExtractor {

    public String[] extractTexts(InputStream in) throws IOException {
        PDDocument pdf = PDDocument.load(in);
        try {
            PDFTextStripper stripper = new PDFTextStripper();
            String text = stripper.getText(pdf) ;
            return new String[] {text} ;
        } finally {
            pdf.close();
        }
    }
}
{'fraction_non_alphanumeric': 0.09181969949916527, 'fraction_numerical': 0.004173622704507512, 'mean_word_length': 3.4080882352941178, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3954676', 'n_tokens_mistral': 346, 'n_tokens_neox': 344, 'n_words': 80}