G'day,
When MDLReader is used with a StringReader it fails
with the following exception:
Exception in thread "main"
org.openscience.cdk.exception.CDKException: Error while
parsing line 1: null in property block.
at
org.openscience.cdk.io.MDLReader.readMolecule(MDLReader.java:442)
at
org.openscience.cdk.io.MDLReader.readChemModel(MDLReader.java:158)
at
org.openscience.cdk.io.MDLReader.readChemFile(MDLReader.java:127)
at
org.openscience.cdk.io.MDLReader.read(MDLReader.java:108)
at CDKMDLReaderBug.main(CDKMDLReaderBug.java:43)
Attached is an example program that generates this error.
I think the problem is the use of input.ready() to try
to determine when the end of the input stream has been
reached. However, input.ready() is always true when
the underlying stream is from a StringReader, even when
at the end of the stream.
I believe the correct way to determine when the end of
the stream has been reached is to check whether
input.readLine() == null.
Regards,
Chris.
Example code to generate MDLReader bug
Logged In: YES
user_id=25678
Added a JUnit test for it to CDK cvs, based on the test
file. Thanx for that.
Logged In: YES
user_id=25678
Suggest fix applied, and attached test is now working.