rkalla / cloudfront-log-parser

Amazon CloudFront Log Parser
Apache License 2.0
22 stars 6 forks source link

ILogEntry.getFieldIndex returns -1 when a value is not found but LogParser expects a null #11

Closed ghost closed 11 years ago

ghost commented 11 years ago

Big thanks to Michael Sørensen for finding this bug and reporting it.

AWS added 2-3 new fields to the log format, unfortunately it exacerbated a bug in the way ILogEntry.getFieldIndex is implemented in DownloadLogEntry and StreamingLogEntry -- the method returns an "int", so 'null' values coming out of the MAP are converted to -1 and returned.

The caller, LogParser, is casting the value to an Integer and then checking for null -- this is a horrible mess created by autoboxing and not noticing the lack of precision.

When AWS added the new log fields, fieldIndex positions get put into the list as "-1" which of course causes an exception at runtime.

The fix is to have LogParser recognize the -1 as "not found" and add the field to the skip list.

THEN add support for the new column types.

tarraq commented 11 years ago

Much welcome!

ghost commented 11 years ago

Fixed in the 1.4 release.