You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2022/09/13 07:24:31 UTC

[pulsar] branch branch-2.11 updated: [fix][functions] Fix flaky testJavaLoggingFunction (#17471)

This is an automated email from the ASF dual-hosted git repository.

technoboy pushed a commit to branch branch-2.11
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.11 by this push:
     new fcef41c520c [fix][functions] Fix flaky testJavaLoggingFunction (#17471)
fcef41c520c is described below

commit fcef41c520c348eacf0cb2caf6b8da9696787ad7
Author: Christophe Bornet <cb...@hotmail.com>
AuthorDate: Thu Sep 8 07:36:34 2022 +0200

    [fix][functions] Fix flaky testJavaLoggingFunction (#17471)
---
 .../functions/instance/JavaInstanceRunnable.java       | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java b/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
index 7429156ca50..82ca518821d 100644
--- a/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
+++ b/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
@@ -276,7 +276,6 @@ public class JavaInstanceRunnable implements AutoCloseable, Runnable {
                     }
                 }
 
-                addLogTopicHandler();
                 JavaExecutionResult result;
 
                 // set last invocation time
@@ -297,8 +296,6 @@ public class JavaInstanceRunnable implements AutoCloseable, Runnable {
                 // register end time
                 stats.processTimeEnd();
 
-                removeLogTopicHandler();
-
                 if (result != null) {
                     // process the synchronous results
                     handleResult(currentRecord, result);
@@ -626,16 +623,10 @@ public class JavaInstanceRunnable implements AutoCloseable, Runnable {
                     instanceConfig.getInstanceName());
             logAppender.start();
             setupLogTopicAppender(LoggerContext.getContext());
+            setupLogTopicAppender(LoggerContext.getContext(false));
         }
     }
 
-    private void addLogTopicHandler() {
-        if (logAppender == null) {
-            return;
-        }
-        setupLogTopicAppender(LoggerContext.getContext(false));
-    }
-
     private void setupLogTopicAppender(LoggerContext context) {
         Configuration config = context.getConfiguration();
         config.addAppender(logAppender);
@@ -646,13 +637,6 @@ public class JavaInstanceRunnable implements AutoCloseable, Runnable {
         context.updateLoggers();
     }
 
-    private void removeLogTopicHandler() {
-        if (logAppender == null) {
-            return;
-        }
-        removeLogTopicAppender(LoggerContext.getContext(false));
-    }
-
     private void removeLogTopicAppender(LoggerContext context) {
         Configuration config = context.getConfiguration();
         for (final LoggerConfig loggerConfig : config.getLoggers().values()) {