Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][broker] Revert "Skip loading broker interceptor when disableBrokerInterceptors is true #20422" #20710

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ The delayed message index time step(in seconds) in per bucket snapshot segment,

@FieldContext(
category = CATEGORY_SERVER,
doc = "Enable or disable the broker interceptor"
doc = "Enable or disable the broker interceptor, which is only used for testing for now"
)
private boolean disableBrokerInterceptors = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public BrokerInterceptors(Map<String, BrokerInterceptorWithClassLoader> intercep
* @return the collection of broker event interceptor
*/
public static BrokerInterceptor load(ServiceConfiguration conf) throws IOException {
if (conf.isDisableBrokerInterceptors()) {
log.info("Skip loading the broker interceptors when disableBrokerInterceptors is true");
return null;
}

BrokerInterceptorDefinitions definitions =
BrokerInterceptorUtils.searchForInterceptors(conf.getBrokerInterceptorsDirectory(),
conf.getNarExtractionDirectory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@

import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;

import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -39,7 +36,6 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.testcontext.PulsarTestContext;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.api.Consumer;
Expand Down Expand Up @@ -311,25 +307,4 @@ public void requestInterceptorFailedTest() {
}
}

@Test
public void testLoadWhenDisableBrokerInterceptorsIsTrue() throws IOException {
ServiceConfiguration serviceConfiguration = spy(ServiceConfiguration.class);
serviceConfiguration.setDisableBrokerInterceptors(true);
BrokerInterceptor brokerInterceptor = BrokerInterceptors.load(serviceConfiguration);
assertNull(brokerInterceptor);

verify(serviceConfiguration, times(1)).isDisableBrokerInterceptors();
verify(serviceConfiguration, times(0)).getBrokerInterceptorsDirectory();
}

@Test
public void testLoadWhenDisableBrokerInterceptorsIsFalse() throws IOException {
ServiceConfiguration serviceConfiguration = spy(ServiceConfiguration.class);
serviceConfiguration.setDisableBrokerInterceptors(false);
BrokerInterceptor brokerInterceptor = BrokerInterceptors.load(serviceConfiguration);
assertNull(brokerInterceptor);

verify(serviceConfiguration, times(1)).isDisableBrokerInterceptors();
verify(serviceConfiguration, times(1)).getBrokerInterceptorsDirectory();
}
}
Loading