/** * Log a task that has been rejected by {@link #doRescheduleTask}. * <p>The default implementation simply logs a corresponding message * at debug level. * @param task the rejected task object * @param ex the exception thrown from {@link #doRescheduleTask} */ protected void logRejectedTask(Object task, RuntimeException ex) { if (logger.isDebugEnabled()) { logger.debug("Listener container task [" + task + "] has been rejected and paused: " + ex); } }
/** * Add an attribute for a cacheable method. * <p>Method names can be exact matches, or of the pattern "xxx*", * "*xxx" or "*xxx*" for matching multiple methods. * @param methodName the name of the method * @param ops operation associated with the method */ public void addCacheMethod(String methodName, Collection<CacheOperation> ops) { if (logger.isDebugEnabled()) { logger.debug("Adding method [" + methodName + "] with cache operations [" + ops + "]"); } this.nameMap.put(methodName, ops); }
/** * Check the UserTransaction as well as the TransactionManager handle, * assuming standard JTA requirements. * @throws IllegalStateException if no sufficient handles are available */ protected void checkUserTransactionAndTransactionManager() throws IllegalStateException { // We at least need the JTA UserTransaction. if (this.userTransaction != null) { if (logger.isDebugEnabled()) { logger.debug("Using JTA UserTransaction: " + this.userTransaction); } } else { throw new IllegalStateException("No JTA UserTransaction available - specify either " + "'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transactionManagerName'"); } // For transaction suspension, the JTA TransactionManager is necessary too. if (this.transactionManager != null) { if (logger.isDebugEnabled()) { logger.debug("Using JTA TransactionManager: " + this.transactionManager); } } else { logger.warn("No JTA TransactionManager found: transaction suspension not available"); } }
private MessageProducer getCachedProducer(@Nullable Destination dest) throws JMSException { DestinationCacheKey cacheKey = (dest != null ? new DestinationCacheKey(dest) : null); MessageProducer producer = this.cachedProducers.get(cacheKey); if (producer != null) { if (logger.isTraceEnabled()) { logger.trace("Found cached JMS MessageProducer for destination [" + dest + "]: " + producer); } } else { producer = this.target.createProducer(dest); if (logger.isDebugEnabled()) { logger.debug("Registering cached JMS MessageProducer for destination [" + dest + "]: " + producer); } this.cachedProducers.put(cacheKey, producer); } return new CachedMessageProducer(producer); }
@Override public void onWriteInactivity(final Runnable runnable, final long duration) { Assert.state(getTaskScheduler() != null, "No TaskScheduler configured"); this.lastWriteTime = System.currentTimeMillis(); this.inactivityTasks.add(getTaskScheduler().scheduleWithFixedDelay(() -> { if (System.currentTimeMillis() - this.lastWriteTime > duration) { try { runnable.run(); } catch (Throwable ex) { if (logger.isDebugEnabled()) { logger.debug("WriteInactivityTask failure", ex); } } } }, duration / 2)); }
@Override public URI put(String key, Map<String, String> endpointDetails, URI defaultEndpoint) { loadAndScheduleRefresh(key, Long.valueOf(endpointDetails.get(Constants.CACHE_PERIOD)), defaultEndpoint); URI discoveredEndpoint = URI.create(String.format("%s://%s", defaultEndpoint.getScheme(), endpointDetails.get(Constants.ENDPOINT))); log.debug("Cached new endpoint from service: " + discoveredEndpoint.toASCIIString()); log.debug("Refresh scheduled in: " + endpointDetails.get(Constants.CACHE_PERIOD) + " minutes"); return cache.put(key, discoveredEndpoint); } }
/** * Return the header value, or {@code null} if it does not exist * or does not match the requested {@code type}. */ @Nullable protected <V> V getHeaderIfAvailable(Map<String, Object> headers, String name, Class<V> type) { Object value = headers.get(name); if (value == null) { return null; } if (!type.isAssignableFrom(value.getClass())) { if (logger.isDebugEnabled()) { logger.debug("Skipping header '" + name + "': expected type [" + type + "], but got [" + value.getClass() + "]"); } return null; } else { return type.cast(value); } }
if (logger.isDebugEnabled()) { List<String> patterns = new ArrayList<>(); if (getRootHandler() != null) { patterns.add("/"); patterns.add("/**"); logger.debug("Patterns " + patterns + " in " + formatMappingName());
/** * Look up a handler instance for the given URL lookup path. * <p>Supports direct matches, e.g. a registered "/test" matches "/test", * and various path pattern matches, e.g. a registered "/t*" matches * both "/test" and "/team". For details, see the PathPattern class. * @param lookupPath the URL the handler is mapped to * @param exchange the current exchange * @return the associated handler instance, or {@code null} if not found * @see org.springframework.web.util.pattern.PathPattern */ @Nullable protected Object lookupHandler(PathContainer lookupPath, ServerWebExchange exchange) throws Exception { List<PathPattern> matches = this.handlerMap.keySet().stream() .filter(key -> key.matches(lookupPath)) .collect(Collectors.toList()); if (matches.isEmpty()) { return null; } if (matches.size() > 1) { matches.sort(PathPattern.SPECIFICITY_COMPARATOR); if (logger.isTraceEnabled()) { logger.debug(exchange.getLogPrefix() + "Matching patterns " + matches); } } PathPattern pattern = matches.get(0); PathContainer pathWithinMapping = pattern.extractPathWithinPattern(lookupPath); return handleMatch(this.handlerMap.get(pattern), pattern, pathWithinMapping, exchange); }
configClasses.add(candidate); if (logger.isDebugEnabled()) { logger.debug(String.format( "Ignoring class [%s]; it must be static, non-private, non-final, and annotated " + "with @Configuration to be considered a default configuration class.", logger.info(String.format("Could not detect default configuration classes for test class [%s]: " + "%s does not declare any static, non-private, non-final, nested classes " + "annotated with @Configuration.", declaringClass.getName(), declaringClass.getSimpleName()));
if (logger.isDebugEnabled()) { logger.debug("Looking up default SQLErrorCodes for DataSource [" + identify(dataSource) + "]"); SQLErrorCodes sec = this.dataSourceCache.get(dataSource); if (sec == null) { synchronized (this.dataSourceCache) { sec = this.dataSourceCache.get(dataSource); if (sec == null) { logger.warn("Error while extracting database name - falling back to empty error codes", ex); if (logger.isDebugEnabled()) { logger.debug("SQLErrorCodes found in cache for DataSource [" + identify(dataSource) + "]");
protected void sendMessageToSubscribers(@Nullable String destination, Message<?> message) { MultiValueMap<String,String> subscriptions = this.subscriptionRegistry.findSubscriptions(message); if (!subscriptions.isEmpty() && logger.isDebugEnabled()) { logger.debug("Broadcasting to " + subscriptions.size() + " sessions."); Object payload = message.getPayload(); Message<?> reply = MessageBuilder.createMessage(payload, headerAccessor.getMessageHeaders()); SessionInfo info = this.sessions.get(sessionId); if (info != null) { try { logger.error("Failed to send " + message, ex);
public void afterTransportClosed(@Nullable CloseStatus closeStatus) { CloseStatus cs = this.closeStatus; if (cs == null) { cs = closeStatus; this.closeStatus = closeStatus; } Assert.state(cs != null, "CloseStatus not available"); if (logger.isDebugEnabled()) { logger.debug("Transport closed with " + cs + " in " + this); } this.state = State.CLOSED; try { this.webSocketHandler.afterConnectionClosed(this, cs); } catch (Throwable ex) { logger.error("WebSocketHandler.afterConnectionClosed threw an exception", ex); } }
return; if (logger.isDebugEnabled()) { logger.debug("Stopping beans in phase " + this.phase); latch.await(this.timeout, TimeUnit.MILLISECONDS); if (latch.getCount() > 0 && !countDownBeanNames.isEmpty() && logger.isInfoEnabled()) { logger.info("Failed to shut down " + countDownBeanNames.size() + " bean" + (countDownBeanNames.size() > 1 ? "s" : "") + " with phase value " + this.phase + " within timeout of " + this.timeout + ": " + countDownBeanNames);
/** * Perform a rollback, handling rollback exceptions properly. * @param status object representing the transaction * @param ex the thrown listener exception or error */ private void rollbackOnException(PlatformTransactionManager manager, TransactionStatus status, Throwable ex) { logger.debug("Initiating transaction rollback on listener exception", ex); try { manager.rollback(status); } catch (RuntimeException ex2) { logger.error("Listener exception overridden by rollback exception", ex); throw ex2; } catch (Error err) { logger.error("Listener exception overridden by rollback error", ex); throw err; } }
@Override public void shutdown(DataSource dataSource, String databaseName) { Connection con = null; try { con = dataSource.getConnection(); if (con != null) { con.createStatement().execute("SHUTDOWN"); } } catch (SQLException ex) { logger.info("Could not shut down embedded database", ex); } finally { if (con != null) { try { con.close(); } catch (Throwable ex) { logger.debug("Could not close JDBC Connection on shutdown", ex); } } } }
@Override public JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass) { MethodClassKey cacheKey = new MethodClassKey(method, targetClass); Object cached = this.cache.get(cacheKey); if (cached != null) { return (cached != NULL_CACHING_ATTRIBUTE ? (JCacheOperation<?>) cached : null); } else { JCacheOperation<?> operation = computeCacheOperation(method, targetClass); if (operation != null) { if (logger.isDebugEnabled()) { logger.debug("Adding cacheable method '" + method.getName() + "' with operation: " + operation); } this.cache.put(cacheKey, operation); } else { this.cache.put(cacheKey, NULL_CACHING_ATTRIBUTE); } return operation; } }
@Override public void onReadInactivity(final Runnable runnable, final long duration) { Assert.state(getTaskScheduler() != null, "No TaskScheduler configured"); this.lastReadTime = System.currentTimeMillis(); this.inactivityTasks.add(getTaskScheduler().scheduleWithFixedDelay(() -> { if (System.currentTimeMillis() - this.lastReadTime > duration) { try { runnable.run(); } catch (Throwable ex) { if (logger.isDebugEnabled()) { logger.debug("ReadInactivityTask failure", ex); } } } }, duration / 2)); }
/** * Add an attribute for a transactional method. * <p>Method names can be exact matches, or of the pattern "xxx*", * "*xxx" or "*xxx*" for matching multiple methods. * @param methodName the name of the method * @param attr attribute associated with the method */ public void addTransactionalMethod(String methodName, TransactionAttribute attr) { if (logger.isDebugEnabled()) { logger.debug("Adding transactional method [" + methodName + "] with attribute [" + attr + "]"); } this.nameMap.put(methodName, attr); }