Skip to content

SbgnUtil.readFrom(InputStream is) fails when conversion from Milestone 1 or 2 necessary #49

Description

@tczauderna

SbgnUtil.readFrom(InputStream is) fails when a conversion is necessary (from Milestone 1 or 2).

The problem is that the input stream can only be used once.

This happens here
Sbgn result = (Sbgn) unmarshaller.unmarshal(is);

Afterwards the input stream is closed and a conversion is not possible.

This will always fail
String docUri = XmlUtil.getDocumentUri(is);

Possible fixes

  1. Don't provide conversion when an input stream is used. There is other readFrom methods which don't provide a conversion.
  2. Save the input stream to a file and use readFromFile
public static Sbgn readFrom(InputStream is) throws IOException, JAXBException {
	
	try {
		File tmp = File.createTempFile("sbgn-", ".sbgn");
		tmp.deleteOnExit();
		Files.copy(is, tmp.toPath(), StandardCopyOption.REPLACE_EXISTING);
		return readFromFile(tmp);
	} catch (IOException ex) {
		throw ex;
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions