/** * Displays a warning if a mapping is being overwritten. * * @param pattern Pattern to check. */ private void dupCheck(String pattern) { if (urlMap.containsKey(pattern)) { log.warn(() -> String.format("Overwriting URL pattern \"%s\" in theme \"%s\"", pattern, name)); } }
/** * Evict entries older than the specified eviction time. */ private void evict() { long threshold = System.currentTimeMillis() - evictionInterval; synchronized (timestamps) { Iterator<Entry<Integer, Long>> iter = timestamps.entrySet().iterator(); while (iter.hasNext()) { Entry<Integer, Long> entry = iter.next(); if (entry.getValue() < threshold) { iter.remove(); callbacks.remove(entry.getKey()); log.warn(() -> "Evicted expired callback #" + entry.getKey()); } else { break; } } } } }
/** * Find all classes belonging packages matching the pattern. * * @param pattern A pattern for matching package names. * @return List of member classes (never null). */ public List<Class<?>> getClasses(String pattern) { try { List<Class<?>> classes = new ArrayList<>(); for (Resource resource : resolver.getResources("classpath*:" + pattern.replace(".", "/") + "/*.class")) { try { String path = resource.getURL().getPath(); int i = path.lastIndexOf(".jar!/") + 6; i = i > 5 ? i : path.lastIndexOf("classes/") + 8; int j = path.lastIndexOf(".class"); path = path.substring(i, j).replace("/", "."); Class<?> clazz = Class.forName(path); classes.add(clazz); } catch (Exception e) { log.warn(() -> "Failed to extract class from resource " + resource, e); } } return classes; } catch (Exception e) { throw MiscUtil.toUnchecked(e); } }
/** * Resolve the label reference and any embedded label references. * * @param name The label name. * @param resolved Set of previously resolved label names (to detect infinite recursion). * @return The resolved message. */ private String getMessage(String name, Set<String> resolved) { try { String message; if (resolved.contains(name)) { message = name; log.warn(() -> "Circular reference to label \"" + name + "\" will not be resolved."); } else { resolved.add(name); message = messageSource.getMessage(name, null, LocaleContextHolder.getLocale()); int i = 0; while ((i = message.indexOf("${")) > -1) { int j = message.indexOf("}", i); String repl = getMessage(message.substring(i + 2, j), resolved); message = message.substring(0, i) + repl + message.substring(j + 1); } } return message; } catch (NoSuchMessageException e) { log.warn(() -> "Reference to unknown label \"" + name + "\" will be ignored."); return ""; } }
/** * Process FSPs marked for pre-compilation. */ @Override public void onApplicationEvent(ContextRefreshedEvent event) { if (precompiled != null) { Set<String> fsps = precompiled; precompiled = null; for (String fsp : fsps) { String url = fsp.trim(); if (url.isEmpty()) { continue; } if (!"fsp".equals(FilenameUtils.getExtension(url))) { url += ".fsp"; } try { log.info(() -> "Precompiling " + fsp); get(url); } catch (Exception e) { log.warn(() -> "Error precompiling " + fsp, e); } } } }
/** * Perform an action. * * @param message Message describing the failure. * @param args Additional arguments for formatting the message. */ void doAction(String message, Object... args) { switch (this) { case IGNORE: return; case EXCEPTION: message = StrUtil.formatMessage(message, args); throw new RuntimeException(message); case LOG: message = StrUtil.formatMessage(message, args); log.warn(message); return; } }
/** * Returns a formatted message given a label identifier. Recognizes line continuation with * backslash characters. * * @param id A label identifier. * @param locale The locale. If null, uses the default locale. * @param args Optional replaceable parameters. * @return The formatted label. */ public static String getMessage(String id, Locale locale, Object... args) { locale = locale == null ? getDefaultLocale() : locale; for (IMessageSource messageSource : messageSources) { try { return messageSource.getMessage(id, locale, args).replace("\\\n", ""); } catch (Exception e) { // Ignore and try next message source. } } // Failing resolution, just return null. log.warn(() -> "Label not found for identifier: " + id); return null; }
/** * Handle classpath syntax. * * @param filename "classpath*:"-prefixed filename. * @param propHolder The properties holder. * @return The new properties holder. */ private PropertiesHolder refreshClassPathProperties(String filename, PropertiesHolder propHolder) { Properties properties = new Properties(); long lastModified = -1; try { Resource[] resources = resolver.getResources(filename + PROPERTIES_SUFFIX); for (Resource resource : resources) { String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); lastModified = Math.min(lastModified, resource.lastModified()); } } catch (Exception e) { log.warn(() -> "Error reading message source: " + filename); } return new PropertiesHolder(properties, lastModified); }
buffer = null; attribs.remove(ATTR_BUFFER); log.warn(() -> "Large payload received from client (" + len + " bytes).");
log.warn(() -> "Large payload received from client (" + len + " bytes).");
@Override public void addViewControllers(ViewControllerRegistry registry) { try { Resource[] resources = applicationContext.getResources("/index.*"); if (resources.length > 0) { if (resources.length > 1) { log.warn("Multiple home page candidates detected - only one will be selected."); } String file = "/" + resources[0].getFilename(); registry.addRedirectViewController("/", file); log.info(() -> "Default home page set to: " + file); } else { log.info("No default home page detected."); } } catch (Exception e) { log.error("Error while attempting to detect default home page.", e); } }
log.warn(message); break;