Am Thu, 17 Apr 2014 21:50:23 +0200 schrieb Bernd Eckenfels <bernd-2...@eckenfels.net>:
> Hello, > > I would propose to use Integer.valueOf(tmp) instead, but looking at > the context I think it is even better to skip this and the following > null check with Integer.parseInt(). This is even shorter and it reduces the privileged actions invocations: Integer tmp = java.security.AccessController.doPrivileged ( new PrivilegedAction<String>() { public String run() { try { String tmpString = Security.getProperty(cachePolicyProp); if (tmpString != null) return Integer.valueOf(tmpString); } catch (NumberFormatException | IllegalArgumentException ignored) { } try { return Integer.getInteger(cachePolicyPropFallback); } catch (NumberFormatException | IllegalArgumentException ignored) { } return null; } }); if (tmp != null) { cachePolicy = tmp.intValue(); if (cachePolicy < 0) { cachePolicy = FOREVER; } propertySet = true; } else { /* No properties defined for positive caching. If there is no * security manager then use the default positive cache value. */ if (System.getSecurityManager() == null) { cachePolicy = DEFAULT_POSITIVE; } } NB: this will