Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Proper streaming parsing #9

Open
glassfishrobot opened this issue Oct 25, 2013 · 3 comments
Open

Proper streaming parsing #9

glassfishrobot opened this issue Oct 25, 2013 · 3 comments

Comments

@glassfishrobot
Copy link
Contributor

Currently I have the following ugly code to parse incoming multipart stream:

MIMEMessage mm = new MIMEMessage(inputStream, boundary);
int i = 0;

while (true) {
	try {
		MIMEPart part = mm.getPart(i);
		try {
			// work with part.getHeader(...); 			// work with part.readOnce(); 		} finally {
			part.close();
		i++;
	} catch (final MIMEParsingException | IllegalStateException e) {
		// No more parts 		log.debug("Done parsing multipart with {} parts", i);
		break;
	}
}

It is ugly because I have to catch exception to determine that there are no more parts. Can this API be improved? Or maybe I'm doing something wrong? Thanks.

Affected Versions

[1.9.3]

@glassfishrobot
Copy link
Contributor Author

Reported by ash2k

@glassfishrobot
Copy link
Contributor Author

Was assigned to snajper

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA MIMEPULL-9

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant