Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not easy for caller to handle specific exception cases well #2

Closed
ghost opened this issue May 13, 2011 · 3 comments
Closed

Not easy for caller to handle specific exception cases well #2

ghost opened this issue May 13, 2011 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented May 13, 2011

Right now the parse method throws:
IOException - any IO issue, including creating the original GZipInputStream
RuntimeException - malformed content

Throwing IOException is great, except it is also thrown when the private GZipInputStream is closed which the catcher would have no access to, to try and correctly close or dispose of it.

Throwing RuntimeException is a bit misleading as the problem is more specific with that; malformed content.

The caller would want to know that so they could skip the log file or discard it, as opposed to retrying the parse operation just incase they thought it was a library or memory or actual VM-runtime failure that caused the original issue.

@ghost
Copy link
Author

ghost commented May 13, 2011

Fixed. parse has the following behavior:

  1. IllegalArgumentException - thrown when something wrong with the method args.
  2. IOException - thrown when the underlying InputStream cannot be read from or some other IO problem with it.
  3. MalformedContentException - thrown when the parser finds incorrectly formatted CloudFront logs.
  4. RuntimeException - thrown when parse() tries to cleanly close the internal GZipInputStream but fails to. The caller don't need to worry about this as much as he should just make sure to close his own input stream he passed in.

@ghost ghost closed this as completed May 13, 2011
@ghost ghost reopened this May 13, 2011
@ghost
Copy link
Author

ghost commented May 13, 2011

Reopened issue to try and troubleshoot GitHub Milestone automatically closing itself and becoming unusable, it's a GitHub bug:
http://support.github.com/discussions/issues-issues/594-milestone-not-used

@ghost ghost closed this as completed May 13, 2011
@ghost
Copy link
Author

ghost commented May 13, 2011

Additionally, protected "parseFieldsDirective" method was updated to throw the MalformedContentException as well if the log type could not be determined by parsing the Fields directive which it should be able to do.

It checks up to 5 field names unique to DOWNLOAD and STREAMING log files to determine type; if it cannot, there is something wrong with the log file content.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants