Source:
<code>public void invalidate(Object obj, PageMode mode) { Contentlet asset = (Contentlet) obj; CacheLocator.getContentletCache() .remove(asset.getInode()); String folderPath = mode.name() + java.io.File.separator; String velocityRootPath = VelocityUtil.getVelocityRootPath(); velocityRootPath += java.io.File.separator; Set<Long> langs = new HashSet<Long>(); langs.add(asset.getLanguageId()); if (LanguageWebAPI.canApplyToAllLanguages(asset)) { for (Language ll : APILocator.getLanguageAPI() .getLanguages()) { langs.add(ll.getId()); } } for (Long langId : langs) { String filePath = folderPath + asset.getIdentifier() + "_" + langId + "." + VelocityType.CONTENT.fileExtension; java.io.File f = new java.io.File(velocityRootPath + filePath); f.delete(); DotResourceCache vc = CacheLocator.getVeloctyResourceCache(); vc.remove(ResourceManager.RESOURCE_TEMPLATE + filePath); } List<Field> fields; try { fields = asset.getContentType() .fields(); for (Field field : fields) { new FieldLoader().invalidate(field, mode); } } catch (DotDataException | DotSecurityException e) { throw new DotStateException(e); } try { if (asset.getContentType() .baseType() == BaseContentType.HTMLPAGE) { new PageLoader().invalidate(asset, mode); } <START> if (asset != null && asset.isVanityUrl()) { <END> VanityUrlServices.getInstance() .invalidateVanityUrl(asset); } if (asset != null && asset.isKeyValue()) { CacheLocator.getKeyValueCache() .remove(asset); } } catch (DotDataException | DotSecurityException e) { throw new DotStateException(e); } }</code><technical_language>![MAJOR](<LINK_1> 'Severity: MAJOR') Remove this expression evaluates "true" [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public void invalidate(Object obj, PageMode mode) { Contentlet asset = (Contentlet) obj; CacheLocator.getContentletCache() .remove(asset.getInode()); String folderPath = mode.name() + java.io.File.separator; String velocityRootPath = VelocityUtil.getVelocityRootPath(); velocityRootPath += java.io.File.separator; Set<Long> langs = new HashSet<Long>(); langs.add(asset.getLanguageId()); if (LanguageWebAPI.canApplyToAllLanguages(asset)) { for (Language ll : APILocator.getLanguageAPI() .getLanguages()) { langs.add(ll.getId()); } } for (Long langId : langs) { String filePath = folderPath + asset.getIdentifier() + "_" + langId + "." + VelocityType.CONTENT.fileExtension; java.io.File f = new java.io.File(velocityRootPath + filePath); f.delete(); DotResourceCache vc = CacheLocator.getVeloctyResourceCache(); vc.remove(ResourceManager.RESOURCE_TEMPLATE + filePath); } List<Field> fields; try { fields = asset.getContentType() .fields(); for (Field field : fields) { new FieldLoader().invalidate(field, asset, mode); } } catch (DotDataException | DotSecurityException e) { throw new DotStateException(e); } try { if (asset.getContentType() .baseType() == BaseContentType.HTMLPAGE) { new PageLoader().invalidate(asset, mode); } if (asset != null && asset.isVanityUrl()) { VanityUrlServices.getInstance() .invalidateVanityUrl(asset); } if (asset != null && asset.isKeyValue()) { CacheLocator.getKeyValueCache() .remove(asset); } } catch (DotDataException | DotSecurityException e) { throw new DotStateException(e); } }