eclipse-ee4j / eclipse-ee4j/metro-mimepull

Proper streaming parsing

Open
#9 5 comments 0 reactions 1 assignee Claimed by @glassfishrobot View on GitHub
Component: code ERR: Assignee Priority: Critical Type: New Feature
Dominant language
Java
Stars
5
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.