hapifhir / hapi-hl7v2

282 stars 137 forks source link

Hl7InputStreamMessageStringIterator returns silently on non HL7 content #113

Open kirupha2000 opened 10 months ago

kirupha2000 commented 10 months ago

When the Hl7InputStreamMessageStringIterator is used to read an input stream from a file containing non HL7 content, it returns silently without throwing an exception or erroring out.

Example code:

package com.example;

import ca.uhn.hl7v2.util.Hl7InputStreamMessageStringIterator;

import java.io.FileInputStream;

public class HL7FileRead {
    public static void main(String[] args) {
        try {
            FileInputStream fis = new FileInputStream("<filepath>");
            Hl7InputStreamMessageStringIterator it = new Hl7InputStreamMessageStringIterator(fis);
            while (it.hasNext()) {
                String msg = it.next();
                System.out.println(msg);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Say the file contains the following content

{ 
    "abc":"def"
}

The program will exit silently without throwing any exceptions or errors.