diff --git a/context/src/main/java/io/micronaut/scheduling/async/AsyncInterceptor.java b/context/src/main/java/io/micronaut/scheduling/async/AsyncInterceptor.java index 5c7d0e4c0a5..1c704a8300e 100644 --- a/context/src/main/java/io/micronaut/scheduling/async/AsyncInterceptor.java +++ b/context/src/main/java/io/micronaut/scheduling/async/AsyncInterceptor.java @@ -111,7 +111,7 @@ public Object intercept(MethodInvocationContext context) { context.proceed(); } catch (Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error occurred executing @Async method [" + context.getExecutableMethod() + "]: " + e.getMessage(), e); + LOG.error("Error occurred executing @Async method [{}]: {}", context.getExecutableMethod(), e.getMessage(), e); } } }); diff --git a/context/src/main/java/io/micronaut/scheduling/io/watch/DefaultWatchThread.java b/context/src/main/java/io/micronaut/scheduling/io/watch/DefaultWatchThread.java index bdc75fe62be..e5bf49719d9 100644 --- a/context/src/main/java/io/micronaut/scheduling/io/watch/DefaultWatchThread.java +++ b/context/src/main/java/io/micronaut/scheduling/io/watch/DefaultWatchThread.java @@ -134,7 +134,7 @@ public DefaultWatchThread start() { } } catch (IOException e) { if (LOG.isErrorEnabled()) { - LOG.error("Error starting file watch service: " + e.getMessage(), e); + LOG.error("Error starting file watch service: {}", e.getMessage(), e); } } return this; @@ -168,7 +168,7 @@ protected void closeWatchService() { getWatchService().close(); } catch (IOException e) { if (LOG.isErrorEnabled()) { - LOG.error("Error stopping file watch service: " + e.getMessage(), e); + LOG.error("Error stopping file watch service: {}", e.getMessage(), e); } } } diff --git a/core/src/main/java/io/micronaut/core/io/IOUtils.java b/core/src/main/java/io/micronaut/core/io/IOUtils.java index dfdf4d0c6de..6541907b464 100644 --- a/core/src/main/java/io/micronaut/core/io/IOUtils.java +++ b/core/src/main/java/io/micronaut/core/io/IOUtils.java @@ -225,7 +225,7 @@ public static String readText(BufferedReader reader) throws IOException { } catch (IOException e) { Logger logger = LoggerFactory.getLogger(Logger.class); if (logger.isWarnEnabled()) { - logger.warn("Failed to close reader: " + e.getMessage(), e); + logger.warn("Failed to close reader: {}", e.getMessage(), e); } } } diff --git a/core/src/main/java/io/micronaut/core/reflect/InstantiationUtils.java b/core/src/main/java/io/micronaut/core/reflect/InstantiationUtils.java index 3444b67c1fb..5d7162ceb3c 100644 --- a/core/src/main/java/io/micronaut/core/reflect/InstantiationUtils.java +++ b/core/src/main/java/io/micronaut/core/reflect/InstantiationUtils.java @@ -56,7 +56,7 @@ public static Optional tryInstantiate(String name, ClassLoader classLoader) { } catch (Throwable e) { Logger log = LoggerFactory.getLogger(InstantiationUtils.class); if (log.isDebugEnabled()) { - log.debug("Tried, but could not instantiate type: " + name, e); + log.debug("Tried, but could not instantiate type: {}", name, e); } return Optional.empty(); } @@ -81,7 +81,7 @@ public static Optional tryInstantiate(String name, ClassLoader classLoader) { final Supplier reflectionFallback = () -> { Logger log = LoggerFactory.getLogger(InstantiationUtils.class); if (log.isDebugEnabled()) { - log.debug("Tried, but could not instantiate type: " + type); + log.debug("Tried, but could not instantiate type: {}", type); } return null; }; @@ -156,7 +156,7 @@ public static Optional tryInstantiate(String name, ClassLoader classLoader) { } catch (Throwable e1) { Logger log = LoggerFactory.getLogger(InstantiationUtils.class); if (log.isDebugEnabled()) { - log.debug("Tried, but could not instantiate type: " + type, e); + log.debug("Tried, but could not instantiate type: {}", type, e); } return null; } @@ -187,7 +187,7 @@ public static Optional tryInstantiate(String name, ClassLoader classLoader) { } catch (Throwable e) { Logger log = ClassUtils.REFLECTION_LOGGER; if (log.isDebugEnabled()) { - log.debug("Tried, but could not instantiate type: " + type, e); + log.debug("Tried, but could not instantiate type: {}", type, e); } return Optional.empty(); } @@ -207,7 +207,7 @@ public static T instantiate(Class type) { try { Logger log = ClassUtils.REFLECTION_LOGGER; if (log.isDebugEnabled()) { - log.debug("Reflectively instantiating type: " + type); + log.debug("Reflectively instantiating type: {}", type); } return type.getDeclaredConstructor().newInstance(); } catch (Throwable e) { @@ -236,7 +236,7 @@ public static T instantiate(Class type, Class[] argTypes, Object... ar try { Logger log = ClassUtils.REFLECTION_LOGGER; if (log.isDebugEnabled()) { - log.debug("Reflectively instantiating type: " + type); + log.debug("Reflectively instantiating type: {}", type); } final Constructor declaredConstructor = type.getDeclaredConstructor(argTypes); declaredConstructor.setAccessible(true); diff --git a/discovery-core/src/main/java/io/micronaut/discovery/cloud/digitalocean/DigitalOceanMetadataResolver.java b/discovery-core/src/main/java/io/micronaut/discovery/cloud/digitalocean/DigitalOceanMetadataResolver.java index 3b5968a4cf7..bd895a191c8 100644 --- a/discovery-core/src/main/java/io/micronaut/discovery/cloud/digitalocean/DigitalOceanMetadataResolver.java +++ b/discovery-core/src/main/java/io/micronaut/discovery/cloud/digitalocean/DigitalOceanMetadataResolver.java @@ -138,11 +138,11 @@ public Optional resolve(Environment environment) { } } catch (MalformedURLException mue) { if (LOG.isErrorEnabled()) { - LOG.error("Digital Ocean metadataUrl value is invalid!: " + configuration.getUrl(), mue); + LOG.error("Digital Ocean metadataUrl value is invalid!: {}", configuration.getUrl(), mue); } } catch (IOException ioe) { if (LOG.isErrorEnabled()) { - LOG.error("Error connecting to" + configuration.getUrl() + "reading instance metadata", ioe); + LOG.error("Error connecting to {} reading instance metadata", configuration.getUrl(), ioe); } } diff --git a/http-client-core/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java b/http-client-core/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java index eb306c9ea41..cfab7dfbc30 100644 --- a/http-client-core/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java +++ b/http-client-core/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java @@ -381,7 +381,7 @@ protected void doOnError(Throwable t) { } } if (LOG.isErrorEnabled()) { - LOG.error("Client [" + declaringType.getName() + "] received HTTP error response: " + t.getMessage(), t); + LOG.error("Client [{}] received HTTP error response: {}", declaringType.getName(), t.getMessage(), t); } future.completeExceptionally(t); } diff --git a/http-client-jdk/src/main/java/io/micronaut/http/client/jdk/DefaultJdkHttpClientRegistry.java b/http-client-jdk/src/main/java/io/micronaut/http/client/jdk/DefaultJdkHttpClientRegistry.java index 4c480f95278..739e9efb9b7 100644 --- a/http-client-jdk/src/main/java/io/micronaut/http/client/jdk/DefaultJdkHttpClientRegistry.java +++ b/http-client-jdk/src/main/java/io/micronaut/http/client/jdk/DefaultJdkHttpClientRegistry.java @@ -330,7 +330,7 @@ public void close() throws Exception { httpClient.close(); } catch (Throwable e) { if (LOG.isWarnEnabled()) { - LOG.warn("Error shutting down HTTP client: " + e.getMessage(), e); + LOG.warn("Error shutting down HTTP client: {}", e.getMessage(), e); } } } diff --git a/http-client/src/main/java/io/micronaut/http/client/netty/DefaultHttpClient.java b/http-client/src/main/java/io/micronaut/http/client/netty/DefaultHttpClient.java index 293a7ad86fa..394f2c2a168 100644 --- a/http-client/src/main/java/io/micronaut/http/client/netty/DefaultHttpClient.java +++ b/http-client/src/main/java/io/micronaut/http/client/netty/DefaultHttpClient.java @@ -2201,7 +2201,7 @@ private void forwardResponseToPromise(FullHttpResponse msg) { } catch (Exception t) { makeNormalBodyParseError(msg, t, cause -> { if (!responsePromise.tryFailure(cause) && log.isWarnEnabled()) { - log.warn("Exception fired after handler completed: " + t.getMessage(), t); + log.warn("Exception fired after handler completed: {}", t.getMessage(), t); } }); } diff --git a/http-client/src/main/java/io/micronaut/http/client/netty/DefaultNettyHttpClientRegistry.java b/http-client/src/main/java/io/micronaut/http/client/netty/DefaultNettyHttpClientRegistry.java index 6cbf4b7f633..8c0666562ba 100644 --- a/http-client/src/main/java/io/micronaut/http/client/netty/DefaultNettyHttpClientRegistry.java +++ b/http-client/src/main/java/io/micronaut/http/client/netty/DefaultNettyHttpClientRegistry.java @@ -225,7 +225,7 @@ public void close() { httpClient.close(); } catch (Throwable e) { if (LOG.isWarnEnabled()) { - LOG.warn("Error shutting down HTTP client: " + e.getMessage(), e); + LOG.warn("Error shutting down HTTP client: {}", e.getMessage(), e); } } } diff --git a/http-client/src/main/java/io/micronaut/http/client/netty/FullNettyClientHttpResponse.java b/http-client/src/main/java/io/micronaut/http/client/netty/FullNettyClientHttpResponse.java index 44f6d2111c0..e81d3d0644b 100644 --- a/http-client/src/main/java/io/micronaut/http/client/netty/FullNettyClientHttpResponse.java +++ b/http-client/src/main/java/io/micronaut/http/client/netty/FullNettyClientHttpResponse.java @@ -176,7 +176,7 @@ public Optional getBody(Argument type) { throw e; } else { if (LOG.isDebugEnabled()) { - LOG.debug("Error decoding HTTP error response body: " + e.getMessage(), e); + LOG.debug("Error decoding HTTP error response body: {}", e.getMessage(), e); } converted = Optional.empty(); } diff --git a/http-netty/src/main/java/io/micronaut/http/netty/websocket/AbstractNettyWebSocketHandler.java b/http-netty/src/main/java/io/micronaut/http/netty/websocket/AbstractNettyWebSocketHandler.java index 2e22928e361..825f33ef082 100644 --- a/http-netty/src/main/java/io/micronaut/http/netty/websocket/AbstractNettyWebSocketHandler.java +++ b/http-netty/src/main/java/io/micronaut/http/netty/websocket/AbstractNettyWebSocketHandler.java @@ -224,7 +224,7 @@ protected final void forwardErrorToUser(ChannelHandlerContext ctx, Consumer flowable = Flux.from(instrumentPublisher(ctx, result)); flowable.collectList().subscribe(objects -> fallback.accept(cause), throwable -> { if (throwable != null && LOG.isErrorEnabled()) { - LOG.error("Error subscribing to @OnError handler " + target.getClass().getSimpleName() + "." + errorMethod.getExecutableMethod() + ": " + throwable.getMessage(), throwable); + LOG.error("Error subscribing to @OnError handler {}.{}: {}", target.getClass().getSimpleName(), errorMethod.getExecutableMethod(), throwable.getMessage(), throwable); } fallback.accept(cause); }); @@ -425,7 +425,7 @@ protected void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame ms }, error -> { if (LOG.isErrorEnabled()) { - LOG.error("Error Processing WebSocket Pong Message [" + webSocketBean + "]: " + error.getMessage(), error); + LOG.error("Error Processing WebSocket Pong Message [{}]: {}", webSocketBean, error.getMessage(), error); } exceptionCaught(ctx, error); }, @@ -434,7 +434,7 @@ protected void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame ms } } catch (Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error Processing WebSocket Message [" + webSocketBean + "]: " + e.getMessage(), e); + LOG.error("Error Processing WebSocket Message [{}]: {}", webSocketBean, e.getMessage(), e); } exceptionCaught(ctx, e); } @@ -451,7 +451,7 @@ protected void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame ms private void messageProcessingException(ChannelHandlerContext ctx, Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error Processing WebSocket Message [" + webSocketBean + "]: " + e.getMessage(), e); + LOG.error("Error Processing WebSocket Message [{}]: {}", webSocketBean, e.getMessage(), e); } exceptionCaught(ctx, e); } @@ -505,7 +505,7 @@ protected void handleCloseReason(ChannelHandlerContext ctx, CloseReason cr, bool invokeAndClose(ctx, target, boundExecutable, methodExecutionHandle, true); } catch (Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error invoking @OnClose handler for WebSocket bean [" + target + "]: " + e.getMessage(), e); + LOG.error("Error invoking @OnClose handler for WebSocket bean [{}]: {}", target, e.getMessage(), e); } } } else { @@ -527,7 +527,7 @@ private void invokeAndClose(ChannelHandlerContext ctx, Object target, BoundExecu result = invokeExecutable(boundExecutable, methodExecutionHandle); } catch (Exception e) { if (LOG.isErrorEnabled()) { - LOG.error("Error invoking @OnClose handler " + target.getClass().getSimpleName() + "." + methodExecutionHandle.getExecutableMethod() + ": " + e.getMessage(), e); + LOG.error("Error invoking @OnClose handler {}.{}: {}", target.getClass().getSimpleName(), methodExecutionHandle.getExecutableMethod(), e.getMessage(), e); } ctx.close(); return; @@ -539,7 +539,7 @@ private void invokeAndClose(ChannelHandlerContext ctx, Object target, BoundExecu }, throwable -> { if (throwable != null && LOG.isErrorEnabled()) { - LOG.error("Error subscribing to @" + (isClose ? "OnClose" : "OnError") + " handler for WebSocket bean [" + target + "]: " + throwable.getMessage(), throwable); + LOG.error("Error subscribing to @{} handler for WebSocket bean [{}]: {}", (isClose ? "OnClose" : "OnError"), target, throwable.getMessage(), throwable); } ctx.close(); }); diff --git a/http-server-netty/src/main/java/io/micronaut/http/server/netty/NettyHttpServer.java b/http-server-netty/src/main/java/io/micronaut/http/server/netty/NettyHttpServer.java index ffe96af59ab..61008ff44e3 100644 --- a/http-server-netty/src/main/java/io/micronaut/http/server/netty/NettyHttpServer.java +++ b/http-server-netty/src/main/java/io/micronaut/http/server/netty/NettyHttpServer.java @@ -490,8 +490,7 @@ protected EventLoopGroup createWorkerEventLoopGroup(@Nullable EventLoopGroupConf String configName = workerConfig != null ? workerConfig.getName() : EventLoopGroupConfiguration.DEFAULT; return nettyEmbeddedServices.getEventLoopGroupRegistry().getEventLoopGroup(configName) .orElseGet(() -> { - LOG.warn("The configuration for 'micronaut.server.netty.worker.{}' is deprecated. " + - "Use 'micronaut.netty.event-loops.default' configuration instead.", configName); + LOG.warn("The configuration for 'micronaut.server.netty.worker.{}' is deprecated. Use 'micronaut.netty.event-loops.default' configuration instead.", configName); final EventLoopGroup newGroup = newEventLoopGroup(workerConfig); shutdownWorker = true; return newGroup; @@ -570,7 +569,7 @@ protected void initChannel(@NonNull Channel ch) { if (isBindError) { LOG.error("Unable to start server. Port {} already in use.", displayAddress(cfg)); } else { - LOG.error("Error starting Micronaut server: " + e.getMessage(), e); + LOG.error("Error starting Micronaut server: {}", e.getMessage(), e); } } stopInternal(false); @@ -606,7 +605,7 @@ private void fireStartupEvents() { private void logShutdownErrorIfNecessary(Future future) { if (!future.isSuccess() && LOG.isWarnEnabled()) { Throwable e = future.cause(); - LOG.warn("Error stopping Micronaut server: " + e.getMessage(), e); + LOG.warn("Error stopping Micronaut server: {}", e.getMessage(), e); } } @@ -666,7 +665,7 @@ private void stopInternal(boolean stopServerOnly) { } } catch (Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error stopping Micronaut server: " + e.getMessage(), e); + LOG.error("Error stopping Micronaut server: {}", e.getMessage(), e); } } } diff --git a/http-server-netty/src/main/java/io/micronaut/http/server/netty/RoutingInBoundHandler.java b/http-server-netty/src/main/java/io/micronaut/http/server/netty/RoutingInBoundHandler.java index f3892ee7133..0994789e106 100644 --- a/http-server-netty/src/main/java/io/micronaut/http/server/netty/RoutingInBoundHandler.java +++ b/http-server-netty/src/main/java/io/micronaut/http/server/netty/RoutingInBoundHandler.java @@ -155,7 +155,7 @@ private void cleanupRequest(NettyHttpRequest request) { terminateEventPublisher.publishEvent(new HttpRequestTerminatedEvent(request)); } catch (Exception e) { if (LOG.isErrorEnabled()) { - LOG.error("Error publishing request terminated event: " + e.getMessage(), e); + LOG.error("Error publishing request terminated event: {}", e.getMessage(), e); } } } @@ -175,18 +175,18 @@ public void handleUnboundError(Throwable cause) { // running any filters if (isIgnorable(cause)) { if (LOG.isDebugEnabled()) { - LOG.debug("Swallowed an IOException caused by client connectivity: " + cause.getMessage(), cause); + LOG.debug("Swallowed an IOException caused by client connectivity: {}", cause.getMessage(), cause); } return; } if (cause instanceof SSLException || cause.getCause() instanceof SSLException) { if (LOG.isDebugEnabled()) { - LOG.debug("Micronaut Server Error - No request state present. Cause: " + cause.getMessage(), cause); + LOG.debug("Micronaut Server Error - No request state present. Cause: {}", cause.getMessage(), cause); } } else { if (LOG.isErrorEnabled()) { - LOG.error("Micronaut Server Error - No request state present. Cause: " + cause.getMessage(), cause); + LOG.error("Micronaut Server Error - No request state present. Cause: {}", cause.getMessage(), cause); } } } diff --git a/http-server-netty/src/main/java/io/micronaut/http/server/netty/binders/NettyInputStreamBodyBinder.java b/http-server-netty/src/main/java/io/micronaut/http/server/netty/binders/NettyInputStreamBodyBinder.java index 7679a75251c..68cd5cdaa6e 100644 --- a/http-server-netty/src/main/java/io/micronaut/http/server/netty/binders/NettyInputStreamBodyBinder.java +++ b/http-server-netty/src/main/java/io/micronaut/http/server/netty/binders/NettyInputStreamBodyBinder.java @@ -68,7 +68,7 @@ public BindingResult bind(ArgumentConversionContext co return () -> Optional.of(s); } catch (ContentLengthExceededException t) { if (LOG.isTraceEnabled()) { - LOG.trace("Server received error for argument [" + context.getArgument() + "]: " + t.getMessage(), t); + LOG.trace("Server received error for argument [{}]: {}", context.getArgument(), t.getMessage(), t); } return BindingResult.empty(); } diff --git a/http-server-netty/src/main/java/io/micronaut/http/server/netty/multipart/NettyStreamingFileUpload.java b/http-server-netty/src/main/java/io/micronaut/http/server/netty/multipart/NettyStreamingFileUpload.java index b2397167cc0..95a7cff2378 100644 --- a/http-server-netty/src/main/java/io/micronaut/http/server/netty/multipart/NettyStreamingFileUpload.java +++ b/http-server-netty/src/main/java/io/micronaut/http/server/netty/multipart/NettyStreamingFileUpload.java @@ -194,7 +194,7 @@ public void onError(Throwable t) { } } catch (IOException e) { if (LOG.isWarnEnabled()) { - LOG.warn("Failed to close file stream : " + fileUpload.getName()); + LOG.warn("Failed to close file stream : {}", fileUpload.getName()); } } } @@ -207,7 +207,7 @@ public void onComplete() { emitter.success(true); } catch (IOException e) { if (LOG.isWarnEnabled()) { - LOG.warn("Failed to close file stream : " + fileUpload.getName()); + LOG.warn("Failed to close file stream : {}", fileUpload.getName()); } emitter.success(false); } diff --git a/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketHandler.java b/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketHandler.java index 01116fd332a..6234e95fb3c 100644 --- a/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketHandler.java +++ b/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketHandler.java @@ -368,7 +368,7 @@ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { Channel channel = ctx.channel(); channel.attr(NettyWebSocketSession.WEB_SOCKET_SESSION_KEY).set(null); if (LOG.isDebugEnabled()) { - LOG.debug("Removing WebSocket Server session: " + serverSession); + LOG.debug("Removing WebSocket Server session: {}", serverSession); } webSocketSessionRepository.removeChannel(channel); try { diff --git a/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketUpgradeHandler.java b/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketUpgradeHandler.java index 75fbdccc5aa..cd0efa54c82 100644 --- a/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketUpgradeHandler.java +++ b/http-server-netty/src/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketUpgradeHandler.java @@ -206,7 +206,7 @@ private void writeResponse(ChannelHandlerContext ctx, NettyHttpRequest msg, b } catch (Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error opening WebSocket: " + e.getMessage(), e); + LOG.error("Error opening WebSocket: {}", e.getMessage(), e); } ctx.writeAndFlush(new CloseWebSocketFrame(CloseReason.INTERNAL_ERROR.getCode(), CloseReason.INTERNAL_ERROR.getReason())); } diff --git a/http-server/src/main/java/io/micronaut/http/server/RouteExecutor.java b/http-server/src/main/java/io/micronaut/http/server/RouteExecutor.java index 42e2bcd8678..0481e1595ca 100644 --- a/http-server/src/main/java/io/micronaut/http/server/RouteExecutor.java +++ b/http-server/src/main/java/io/micronaut/http/server/RouteExecutor.java @@ -271,7 +271,7 @@ void logException(Throwable cause) { logIgnoredException(cause); } else { if (LOG.isErrorEnabled()) { - LOG.error("Unexpected error occurred: " + cause.getMessage(), cause); + LOG.error("Unexpected error occurred: {}", cause.getMessage(), cause); } } } @@ -283,7 +283,7 @@ static boolean isIgnorable(Throwable cause) { static void logIgnoredException(Throwable cause) { if (LOG.isDebugEnabled()) { - LOG.debug("Swallowed an IOException caused by client connectivity: " + cause.getMessage(), cause); + LOG.debug("Swallowed an IOException caused by client connectivity: {}", cause.getMessage(), cause); } } diff --git a/http-server/src/main/java/io/micronaut/http/server/cors/CorsFilter.java b/http-server/src/main/java/io/micronaut/http/server/cors/CorsFilter.java index 09c6d81f603..23bdabc343e 100644 --- a/http-server/src/main/java/io/micronaut/http/server/cors/CorsFilter.java +++ b/http-server/src/main/java/io/micronaut/http/server/cors/CorsFilter.java @@ -96,7 +96,7 @@ public CorsFilter(HttpServerConfiguration.CorsConfiguration corsConfiguration, public final HttpResponse filterRequest(HttpRequest request) { String origin = request.getOrigin().orElse(null); if (origin == null) { - LOG.trace("Http Header " + HttpHeaders.ORIGIN + " not present. Proceeding with the request."); + LOG.trace("Http Header {} not present. Proceeding with the request.", HttpHeaders.ORIGIN); return null; // proceed } CorsOriginConfiguration corsOriginConfiguration = getConfiguration(request).orElse(null); diff --git a/inject-groovy/src/main/groovy/io/micronaut/ast/groovy/scan/ClassPathAnnotationScanner.java b/inject-groovy/src/main/groovy/io/micronaut/ast/groovy/scan/ClassPathAnnotationScanner.java index 2238ad45a50..339408ccec0 100644 --- a/inject-groovy/src/main/groovy/io/micronaut/ast/groovy/scan/ClassPathAnnotationScanner.java +++ b/inject-groovy/src/main/groovy/io/micronaut/ast/groovy/scan/ClassPathAnnotationScanner.java @@ -118,7 +118,7 @@ protected List> doScan(String annotation, String pkg) { traverseFile(annotation, classes, Paths.get(url.toURI())); } catch (URISyntaxException e) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring file [" + url + "] due to URI error: " + e.getMessage(), e); + LOG.debug("Ignoring file [{}] due to URI error: {}", url, e.getMessage(), e); } } } else if (includeJars && Arrays.asList("jar", "zip", "war").contains(protocol)) { @@ -135,17 +135,17 @@ protected List> doScan(String annotation, String pkg) { scanInputStream(annotation, inputStream, classes); } catch (IOException e) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring JAR entry [" + entry.getName() + "] due to I/O error: " + e.getMessage(), e); + LOG.debug("Ignoring JAR entry [{}] due to I/O error: {}", entry.getName(), e.getMessage(), e); } } catch (ClassNotFoundException e) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring JAR entry [" + entry.getName() + "]. Class not found: " + e.getMessage(), e); + LOG.debug("Ignoring JAR entry [{}]. Class not found: {}", entry.getName(), e.getMessage(), e); } } }); } else { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring JAR URI entry [" + url + "]. No JarURLConnection found."); + LOG.debug("Ignoring JAR URI entry [{}]. No JarURLConnection found.", url); } // TODO: future support for servlet containers } @@ -155,7 +155,7 @@ protected List> doScan(String annotation, String pkg) { return classes; } catch (IOException e) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring I/O Exception scanning package: " + pkg, e); + LOG.debug("Ignoring I/O Exception scanning package: {}", pkg, e); } return Collections.emptyList(); } @@ -178,7 +178,7 @@ protected void traverseFile(String annotation, List> classes, Path file }); } catch (IOException e) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring directory [" + filePath + "] due to I/O error: " + e.getMessage(), e); + LOG.debug("Ignoring directory [{}] due to I/O error: {}", filePath, e.getMessage(), e); } } } else { @@ -199,11 +199,11 @@ protected void scanFile(String annotation, Path filePath, List> classes scanInputStream(annotation, inputStream, classes); } catch (IOException e) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring file [" + fileName + "] due to I/O error: " + e.getMessage(), e); + LOG.debug("Ignoring file [{}] due to I/O error: {}", fileName, e.getMessage(), e); } } catch (ClassNotFoundException e) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring file [" + fileName + "]. Class not found: " + e.getMessage(), e); + LOG.debug("Ignoring file [{}]. Class not found: {}", fileName, e.getMessage(), e); } } } diff --git a/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinition.java b/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinition.java index 1c59fd911dd..9f20e2bfa16 100644 --- a/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinition.java +++ b/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinition.java @@ -911,7 +911,7 @@ protected final void invokeMethodWithReflection(BeanResolutionContext resolution MethodReference methodRef = methodInjection[methodIndex]; Argument[] methodArgumentTypes = methodRef.arguments == null ? Argument.ZERO_ARGUMENTS : methodRef.arguments; if (ClassUtils.REFLECTION_LOGGER.isDebugEnabled()) { - ClassUtils.REFLECTION_LOGGER.debug("Bean of type [" + getBeanType() + "] uses reflection to inject method: '" + methodRef.methodName + "'"); + ClassUtils.REFLECTION_LOGGER.debug("Bean of type [{}] uses reflection to inject method: '{}'", getBeanType(), methodRef.methodName); } try { Method method = ReflectionUtils.getMethod( @@ -945,7 +945,7 @@ protected final void setFieldWithReflection(BeanResolutionContext resolutionCont FieldReference fieldRef = fieldInjection[index]; try { if (ClassUtils.REFLECTION_LOGGER.isDebugEnabled()) { - ClassUtils.REFLECTION_LOGGER.debug("Bean of type [" + getBeanType() + "] uses reflection to inject field: '" + fieldRef.argument.getName() + "'"); + ClassUtils.REFLECTION_LOGGER.debug("Bean of type [{}] uses reflection to inject field: '{}'", getBeanType(), fieldRef.argument.getName()); } Field field = ReflectionUtils.getRequiredField(fieldRef.declaringType, fieldRef.argument.getName()); field.setAccessible(true); diff --git a/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinitionReference.java b/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinitionReference.java index 800a9ec703d..7ce31588e61 100644 --- a/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinitionReference.java +++ b/inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinitionReference.java @@ -199,7 +199,7 @@ public boolean isPresent() { } catch (Throwable e) { if (e instanceof TypeNotPresentException || e instanceof ClassNotFoundException || e instanceof NoClassDefFoundError) { if (ConditionLog.LOG.isTraceEnabled()) { - ConditionLog.LOG.trace("Bean definition for type [" + beanTypeName + "] not loaded since it is not on the classpath", e); + ConditionLog.LOG.trace("Bean definition for type [{}] not loaded since it is not on the classpath", beanTypeName, e); } } else { throw new BeanContextException("Unexpected error loading bean definition [" + beanDefinitionTypeName + "]: " + e.getMessage(), e); diff --git a/inject/src/main/java/io/micronaut/context/AnnotationProcessorListener.java b/inject/src/main/java/io/micronaut/context/AnnotationProcessorListener.java index f0b25237120..4ce2aa2a596 100644 --- a/inject/src/main/java/io/micronaut/context/AnnotationProcessorListener.java +++ b/inject/src/main/java/io/micronaut/context/AnnotationProcessorListener.java @@ -76,7 +76,7 @@ public AnnotationProcessor onCreated(BeanCreatedEvent event } } catch (Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error processing bean method " + beanDefinition + "." + executableMethod + " with processor (" + processor + "): " + e.getMessage(), e); + LOG.error("Error processing bean method {}.{} with processor ({}): {}", beanDefinition, executableMethod, processor, e.getMessage(), e); } Boolean shutdownOnError = executableMethod.getAnnotationMetadata().booleanValue(Parallel.class, "shutdownOnError").orElse(true); if (shutdownOnError) { diff --git a/inject/src/main/java/io/micronaut/context/DefaultBeanContext.java b/inject/src/main/java/io/micronaut/context/DefaultBeanContext.java index b63b01c2692..8e4a4ffde2d 100644 --- a/inject/src/main/java/io/micronaut/context/DefaultBeanContext.java +++ b/inject/src/main/java/io/micronaut/context/DefaultBeanContext.java @@ -856,7 +856,7 @@ public T getBean(@NonNull Argument beanType, @Nullable Qualifier quali return getBean(null, beanType, qualifier); } catch (DisabledBeanException e) { if (AbstractBeanContextConditional.ConditionLog.LOG.isDebugEnabled()) { - AbstractBeanContextConditional.ConditionLog.LOG.debug("Bean of type [{}] disabled for reason: {}", beanType.getSimpleName(), e.getMessage()); + AbstractBeanContextConditional.ConditionLog.LOG.debug("Bean of type [{}] disabled for reason: {}", beanType.getSimpleName(), e.getMessage(), e); } throw newNoSuchBeanException( null, @@ -1214,7 +1214,7 @@ private void destroyBean(@NonNull BeanRegistration registration, boolean ((DisposableBeanDefinition) definition).dispose(this, beanToDestroy); } catch (Exception e) { if (LOG.isWarnEnabled()) { - LOG.warn("Error disposing bean [" + beanToDestroy + "]... Continuing...", e); + LOG.warn("Error disposing bean [{}]... Continuing...", beanToDestroy, e); } } } @@ -2033,7 +2033,7 @@ protected void initializeContext( processor.process(beanDefinition, method); } catch (Throwable e) { if (LOG.isErrorEnabled()) { - LOG.error("Error processing bean method " + beanDefinition + "." + method + " with processor (" + processor + "): " + e.getMessage(), e); + LOG.error("Error processing bean method {}.{} with processor ({}): {}", beanDefinition, method, processor, e.getMessage(), e); } Boolean shutdownOnError = method.booleanValue(Parallel.class, "shutdownOnError").orElse(true); if (shutdownOnError) { @@ -2448,7 +2448,7 @@ protected void processParallelBeans(List parallelBeans) loadEagerBeans(producer, parallelDefinitions); } catch (Throwable e) { BeanDefinitionReference beanDefinitionReference = producer.getReference(); - LOG.error("Parallel Bean definition [" + beanDefinitionReference.getName() + MSG_COULD_NOT_BE_LOADED + e.getMessage(), e); + LOG.error("Parallel Bean definition [{}{}{}]", beanDefinitionReference.getName(), MSG_COULD_NOT_BE_LOADED, e.getMessage(), e); Boolean shutdownOnError = beanDefinitionReference.getAnnotationMetadata().booleanValue(Parallel.class, "shutdownOnError").orElse(true); if (shutdownOnError) { stop(); @@ -2462,7 +2462,7 @@ protected void processParallelBeans(List parallelBeans) try { initializeEagerBean(beanDefinition); } catch (Throwable e) { - LOG.error("Parallel Bean definition [" + beanDefinition.getName() + MSG_COULD_NOT_BE_LOADED + e.getMessage(), e); + LOG.error("Parallel Bean definition [{}{}{}]", beanDefinition.getName(), MSG_COULD_NOT_BE_LOADED, e.getMessage(), e); Boolean shutdownOnError = beanDefinition.getAnnotationMetadata().booleanValue(Parallel.class, "shutdownOnError").orElse(true); if (shutdownOnError) { stop(); diff --git a/inject/src/main/java/io/micronaut/context/event/ApplicationEventPublisherFactory.java b/inject/src/main/java/io/micronaut/context/event/ApplicationEventPublisherFactory.java index c72be109abb..f3d0baf777d 100644 --- a/inject/src/main/java/io/micronaut/context/event/ApplicationEventPublisherFactory.java +++ b/inject/src/main/java/io/micronaut/context/event/ApplicationEventPublisherFactory.java @@ -268,7 +268,7 @@ private void notifyEventListeners(@NonNull Object event, ApplicationEventListene String msg = ex.getMessage(); if (msg == null || msg.startsWith(event.getClass().getName())) { if (EventLogger.LOG.isDebugEnabled()) { - EventLogger.LOG.debug("Incompatible listener for event: " + listener, ex); + EventLogger.LOG.debug("Incompatible listener for event: {}", listener, ex); } } else { throw ex; diff --git a/inject/src/main/java/io/micronaut/context/i18n/ResourceBundleMessageSource.java b/inject/src/main/java/io/micronaut/context/i18n/ResourceBundleMessageSource.java index 090021fe73f..29178dc391a 100644 --- a/inject/src/main/java/io/micronaut/context/i18n/ResourceBundleMessageSource.java +++ b/inject/src/main/java/io/micronaut/context/i18n/ResourceBundleMessageSource.java @@ -67,7 +67,7 @@ public ResourceBundleMessageSource(@NonNull String baseName, @Nullable Locale de } } catch (MissingResourceException e) { if (LOG.isDebugEnabled()) { - LOG.debug("No default bundle (locale: " + defaultLocale + ") found for base name " + baseName); + LOG.debug("No default bundle (locale: {}) found for base name {}", defaultLocale, baseName); } defaultBundle = null; } diff --git a/jackson-core/src/main/java/io/micronaut/jackson/core/parser/JacksonCoreProcessor.java b/jackson-core/src/main/java/io/micronaut/jackson/core/parser/JacksonCoreProcessor.java index 572ea89408d..64e989afa48 100644 --- a/jackson-core/src/main/java/io/micronaut/jackson/core/parser/JacksonCoreProcessor.java +++ b/jackson-core/src/main/java/io/micronaut/jackson/core/parser/JacksonCoreProcessor.java @@ -102,7 +102,7 @@ protected void doOnComplete() { @Override protected void onUpstreamMessage(byte[] message) { if (LOG.isTraceEnabled()) { - LOG.trace("Received upstream bytes of length: " + message.length); + LOG.trace("Received upstream bytes of length: {}", message.length); } try { diff --git a/jackson-databind/src/main/java/io/micronaut/jackson/modules/BeanIntrospectionModule.java b/jackson-databind/src/main/java/io/micronaut/jackson/modules/BeanIntrospectionModule.java index eb9055525a8..b4d3c01a588 100644 --- a/jackson-databind/src/main/java/io/micronaut/jackson/modules/BeanIntrospectionModule.java +++ b/jackson-databind/src/main/java/io/micronaut/jackson/modules/BeanIntrospectionModule.java @@ -319,7 +319,7 @@ public JsonSerializer build() { return super.build(); } catch (RuntimeException e) { if (LOG.isErrorEnabled()) { - LOG.error("Error building bean serializer for type [" + beanClass + "]: " + e.getMessage(), e); + LOG.error("Error building bean serializer for type [{}]: {}", beanClass, e.getMessage(), e); } throw e; } diff --git a/jackson-databind/src/main/java/io/micronaut/jackson/parser/JacksonProcessor.java b/jackson-databind/src/main/java/io/micronaut/jackson/parser/JacksonProcessor.java index fd8e3546b20..232d7da9da7 100644 --- a/jackson-databind/src/main/java/io/micronaut/jackson/parser/JacksonProcessor.java +++ b/jackson-databind/src/main/java/io/micronaut/jackson/parser/JacksonProcessor.java @@ -147,7 +147,7 @@ protected void doOnComplete() { @Override protected void onUpstreamMessage(byte[] message) { if (LOG.isTraceEnabled()) { - LOG.trace("Received upstream bytes of length: " + message.length); + LOG.trace("Received upstream bytes of length: {}", message.length); } try { diff --git a/management/src/main/java/io/micronaut/management/health/indicator/HealthResult.java b/management/src/main/java/io/micronaut/management/health/indicator/HealthResult.java index 44084d173a2..43c6956a197 100644 --- a/management/src/main/java/io/micronaut/management/health/indicator/HealthResult.java +++ b/management/src/main/java/io/micronaut/management/health/indicator/HealthResult.java @@ -120,7 +120,7 @@ public Builder exception(@NotNull Throwable ex) { final String message = ex.getClass().getName() + ": " + ex.getMessage(); error.put("error", message); if (LOG.isErrorEnabled()) { - LOG.error("Health indicator [" + name + "] reported exception: " + message, ex); + LOG.error("Health indicator [{}] reported exception: {}", name, message, ex); } return details(error); } diff --git a/retry/src/main/java/io/micronaut/retry/intercept/CircuitBreakerRetry.java b/retry/src/main/java/io/micronaut/retry/intercept/CircuitBreakerRetry.java index a5199f616d5..753a6d7cbc2 100644 --- a/retry/src/main/java/io/micronaut/retry/intercept/CircuitBreakerRetry.java +++ b/retry/src/main/java/io/micronaut/retry/intercept/CircuitBreakerRetry.java @@ -201,7 +201,7 @@ private CircuitState openCircuit(Throwable cause) { eventPublisher.publishEvent(new CircuitOpenEvent(method, childState, cause)); } catch (Exception e) { if (LOG.isErrorEnabled()) { - LOG.error("Error publishing CircuitOpen event: " + e.getMessage(), e); + LOG.error("Error publishing CircuitOpen event: {}", e.getMessage(), e); } } } @@ -229,7 +229,7 @@ private CircuitState closeCircuit() { eventPublisher.publishEvent(new CircuitClosedEvent(method)); } catch (Exception e) { if (LOG.isErrorEnabled()) { - LOG.error("Error publishing CircuitClosedEvent: " + e.getMessage(), e); + LOG.error("Error publishing CircuitClosedEvent: {}", e.getMessage(), e); } } } diff --git a/retry/src/main/java/io/micronaut/retry/intercept/DefaultRetryInterceptor.java b/retry/src/main/java/io/micronaut/retry/intercept/DefaultRetryInterceptor.java index d6a92ba214f..b39a2ea483b 100644 --- a/retry/src/main/java/io/micronaut/retry/intercept/DefaultRetryInterceptor.java +++ b/retry/src/main/java/io/micronaut/retry/intercept/DefaultRetryInterceptor.java @@ -170,7 +170,7 @@ public Object intercept(MethodInvocationContext context) { try { eventPublisher.publishEvent(new RetryEvent(context, retryState, exception)); } catch (Exception e) { - LOG.error("Error occurred publishing RetryEvent: " + e.getMessage(), e); + LOG.error("Error occurred publishing RetryEvent: {}", e.getMessage(), e); } } executorService.schedule(() -> { @@ -200,7 +200,7 @@ public Object intercept(MethodInvocationContext context) { try { eventPublisher.publishEvent(new RetryEvent(context, retryState, exception)); } catch (Exception e1) { - LOG.error("Error occurred publishing RetryEvent: " + e1.getMessage(), e1); + LOG.error("Error occurred publishing RetryEvent: {}", e1.getMessage(), e1); } } if (LOG.isDebugEnabled()) { @@ -244,7 +244,7 @@ private Object retrySync(MethodInvocationContext context, Mutabl try { eventPublisher.publishEvent(new RetryEvent(context, retryState, e)); } catch (Exception e1) { - LOG.error("Error occurred publishing RetryEvent: " + e1.getMessage(), e1); + LOG.error("Error occurred publishing RetryEvent: {}", e1.getMessage(), e1); } } if (LOG.isDebugEnabled()) { diff --git a/retry/src/main/java/io/micronaut/retry/intercept/RecoveryInterceptor.java b/retry/src/main/java/io/micronaut/retry/intercept/RecoveryInterceptor.java index 4af428f7fb1..82bb0940ed8 100644 --- a/retry/src/main/java/io/micronaut/retry/intercept/RecoveryInterceptor.java +++ b/retry/src/main/java/io/micronaut/retry/intercept/RecoveryInterceptor.java @@ -187,7 +187,7 @@ private CompletionStage fallbackForFuture(MethodInvocationContext fallbackForSuspend(MethodInvocationContext context, RuntimeException exception) { if (LOG.isErrorEnabled()) { - LOG.error("Type [" + context.getTarget().getClass().getName() + "] executed with error: " + exception.getMessage(), exception); + LOG.error("Type [{}] executed with error: {}", context.getTarget().getClass().getName(), exception.getMessage(), exception); } Optional> fallback = findFallbackMethod(context); diff --git a/runtime-osx/src/main/java/io/micronaut/scheduling/io/watch/osx/MacOsWatchServiceFactory.java b/runtime-osx/src/main/java/io/micronaut/scheduling/io/watch/osx/MacOsWatchServiceFactory.java index f6e8519c0c0..1b4b2ecda41 100644 --- a/runtime-osx/src/main/java/io/micronaut/scheduling/io/watch/osx/MacOsWatchServiceFactory.java +++ b/runtime-osx/src/main/java/io/micronaut/scheduling/io/watch/osx/MacOsWatchServiceFactory.java @@ -60,7 +60,7 @@ protected WatchService macWatchService() throws IOException { return new MacOSXListeningWatchService(); } catch (Exception e) { if (LOG.isWarnEnabled()) { - LOG.warn("Unable to create Mac OS X specific watch service. Falling back to default polling strategy: " + e.getMessage(), e); + LOG.warn("Unable to create Mac OS X specific watch service. Falling back to default polling strategy: {}", e.getMessage(), e); } return new WatchServiceFactory().watchService(); }