<commit_before>package app.we.go.utils.rx2;

import io.reactivex.Observable;

import java.io.BufferedReader;

public class ObservableCreation {

    public ObservableCreation() {
        // Private constructor for static utils class
    }


    /**
     * Creates an {@link Observable} that emits all lines of a {@link BufferedReader} as {@link String}s.
     *
     * @param reader The {@link BufferedReader} to read from
     * @return An {@link Observable} that emits {@link String}s.
     */
    public static Observable<String> fromBufferedReader(BufferedReader reader) {
        return Observable.create(e -> {
            String line;
            while ((line = reader.readLine()) != null) {
                if (!e.isDisposed()) {
                    e.onNext(line);
                }
            }
            e.onComplete();
        });
    }<commit_msg>Changed condition of while, to make sure that when cancelling/disposing, and the reader.close() is called, the readLine is not called again.<commit_after>package app.we.go.utils.rx2;

import io.reactivex.Observable;

import java.io.BufferedReader;

public class ObservableCreation {

    public ObservableCreation() {
        // Private constructor for static utils class
    }


    /**
     * Creates an {@link Observable} that emits all lines of a {@link BufferedReader} as {@link String}s.
     *
     * @param reader The {@link BufferedReader} to read from
     * @return An {@link Observable} that emits {@link String}s.
     */
    public static Observable<String> fromBufferedReader(BufferedReader reader) {
        return Observable.create(e -> {
            String line;
            while (!e.isDisposed() && (line = reader.readLine()) != null) {
                e.onNext(line);
            }
            e.onComplete();
        });
    }
{'fraction_non_alphanumeric': 0.10822749861954721, 'fraction_numerical': 0.0011043622308117063, 'mean_word_length': 2.318681318681319, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3432759', 'n_tokens_mistral': 497, 'n_tokens_neox': 485, 'n_words': 149}