Re: Occasional NPEs from ERXTimeZoneDetector
Re: Occasional NPEs from ERXTimeZoneDetector
- Subject: Re: Occasional NPEs from ERXTimeZoneDetector
- From: Ramsey Gurley <email@hidden>
- Date: Tue, 19 Apr 2016 09:54:31 -0700
Hi Paul,
That’s probably something that doesn’t live in your zones array, so zonesWithRawOffset is returning an empty array of which lastObject returns null, and thus the null pointer exception. Without knowing the zone string causing the problem, it’s a tough one. I’d probably start by logging that on a NullPointerException and trying to handle that event properly. You could go into handleException on the app and log the ERXSession.session().objectStore().valueForKey(“detectedTimeZone”) on any NPE perhaps.
Ramsey
On Apr 17, 2016, at 10:10 PM, Paul Hoadley <email@hidden> wrote:
> Hello,
>
> I’m a big fan of Ramsey’s ERXTimeZoneDetector. I’m seeing occasional NPEs like this:
>
> java.lang.NullPointerException: timeZone must not be set to null
> at er.extensions.appserver.ERXSession.setTimeZone(ERXSession.java:810)
> at er.extensions.components.ERXTimeZoneDetector.takeValuesFromRequest(ERXTimeZoneDetector.java:148)
> at com.webobjects.appserver._private.WOComponentReference.takeValuesFromRequest(WOComponentReference.java:119)
>
> ERXSession.setTimeZone() doesn’t like nulls, and that’s fair enough. It’s being called from here:
>
> public void takeValuesFromRequest(WORequest request, WOContext context) {
> super.takeValuesFromRequest(request, context);
> if (shouldPostData() && request.formValueForKey(TIMEZONE_DATA_KEY) != null) {
> ...
> TimeZone tz = zoneWithRawOffset(rawOffset, dst, southern);
> session.setTimeZone(tz);
> }
> }
>
> That is, when ERXTimeZoneDetector thinks it’s found the TimeZone, it calls setTimeZone(), except sometimes tz is null. In the resulting log output, ERXBasicBrowser is suggesting the culprit is usually IE 8, sometimes IE 9. I don’t know whether this is a legitimate app user, or someone browsing the login page, or a bot. I don’t currently have the facilities to try to reproduce this with IE.
>
> I’m not sure how much I really care, but it would be nice to avoid the NPEs. Ramsey, what would your preference be for the behaviour of the component here if it reaches setTimeZone() but tz is null? Meanwhile, I might add some extra logging and… wait. It would be interesting to know what zoneString turned out to be, for example.
>
>
> --
> Paul Hoadley
> http://logicsquad.net/
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden