Skip to content

Commit

Permalink
Guards against calling setTimeZone() with null argument. wocommunity#774
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhoadley committed Jun 27, 2016
1 parent e60d618 commit 6a195fa
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.TimeZone;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webobjects.appserver.WOApplication;
import com.webobjects.appserver.WOContext;
Expand Down Expand Up @@ -47,6 +49,11 @@ public class ERXTimeZoneDetector extends ERXStatelessComponent {
*/
private static final long serialVersionUID = 1L;

/**
* Logger
*/
private static final Logger log = LoggerFactory.getLogger(ERXTimeZoneDetector.class);

public static final String TIMEZONE_SESSION_KEY = "detectedTimeZone";

private static final String TIMEZONE_DATA_KEY = "_timezone";
Expand Down Expand Up @@ -145,7 +152,14 @@ public void takeValuesFromRequest(WORequest request, WOContext context) {
boolean dst = "1".equals(data[1]);
boolean southern = "1".equals(data[2]);
TimeZone tz = zoneWithRawOffset(rawOffset, dst, southern);
session.setTimeZone(tz);
// Call ERXSession.setTimeZone() if tz is not null
// https://github.com/wocommunity/wonder/issues/774
if (tz != null) {
session.setTimeZone(tz);
}
else {
log.warn("Unable to find a timezone for '{}'.", zoneString);
}
}
}

Expand Down

0 comments on commit 6a195fa

Please sign in to comment.