From a19003077c1cfad2245d2e1e3034957433c9da55 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 18 Sep 2012 21:02:44 -0300 Subject: [PATCH] Fix NPE when browser version can not be detected. --- .../com/wisemapping/filter/SupportedUserAgent.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java b/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java index bb28dcd9..301a3780 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java @@ -41,17 +41,17 @@ public class SupportedUserAgent implements Serializable { final UserAgent userAgent = this.getUserAgent(); final Browser browser = userAgent.getBrowser(); - final Version version = userAgent.getBrowserVersion(); final OperatingSystem os = userAgent.getOperatingSystem(); + final Version version = userAgent.getBrowserVersion(); + final int majorVersion = version != null ? Integer.parseInt(version.getMajorVersion()) : -1; - final String majorVersion = version.getMajorVersion(); - boolean result = browser == Browser.FIREFOX && Integer.parseInt(majorVersion) >= 10; + boolean result = browser == Browser.FIREFOX && majorVersion >= 10; result = result || browser == Browser.IE8 || browser == Browser.IE9; - result = result || browser == Browser.IE && Integer.parseInt(majorVersion) >= 8; - result = result || browser == Browser.OPERA && Integer.parseInt(majorVersion) >= 11; - result = result || browser == Browser.CHROME && Integer.parseInt(majorVersion) >= 18; + result = result || browser == Browser.IE && majorVersion >= 8; + result = result || browser == Browser.OPERA && majorVersion >= 11; + result = result || browser == Browser.CHROME && majorVersion >= 18; result = result || browser == Browser.SAFARI5; - result = result || browser == Browser.SAFARI && Integer.parseInt(majorVersion) >= 5; + result = result || browser == Browser.SAFARI && majorVersion >= 5; result = result || browser == Browser.MOBILE_SAFARI; result = result || os.isMobileDevice() && (os == OperatingSystem.ANDROID || os == OperatingSystem.iOS4_IPHONE); result = result || browser.getBrowserType() == BrowserType.ROBOT;