Skip to content
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 @@ -932,15 +932,16 @@ protected synchronized ScheduledExecutorService getCompactorExecutor() {
return this.compactorExecutor;
}

// only public so mockito can mock it
public Compactor newCompactor() throws PulsarServerException {
return new TwoPhaseCompactor(this.getConfiguration(),
getClient(), getBookKeeperClient(),
getCompactorExecutor());
}

public synchronized Compactor getCompactor() throws PulsarServerException {
if (this.compactor == null) {
try {
this.compactor = new TwoPhaseCompactor(this.getConfiguration(),
getClient(), getBookKeeperClient(),
getCompactorExecutor());
} catch (Exception e) {
throw new PulsarServerException(e);
}
this.compactor = newCompactor();
}
return this.compactor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.pulsar.broker.auth;

import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

Expand Down Expand Up @@ -246,9 +247,6 @@ protected PulsarService startBroker(ServiceConfiguration conf) throws Exception
pulsar.start();
conf.setAuthorizationEnabled(isAuthorizationEnabled);

Compactor spiedCompactor = spy(pulsar.getCompactor());
doReturn(spiedCompactor).when(pulsar).getCompactor();

return pulsar;
}

Expand All @@ -261,6 +259,10 @@ protected void setupBrokerMocks(PulsarService pulsar) throws Exception {
doReturn(namespaceServiceSupplier).when(pulsar).getNamespaceServiceProvider();

doReturn(sameThreadOrderedSafeExecutor).when(pulsar).getOrderedExecutor();

doAnswer((invocation) -> {
return spy(invocation.callRealMethod());
}).when(pulsar).newCompactor();
}

public TenantInfo createDefaultTenantInfo() throws PulsarAdminException {
Expand Down