muttakin2301/ccr_train_1000 huggingface dataset:
Code review comment: Save the error msg somewhere for user to get?

Code before review:
private void clearJob() {
Preconditions.checkState(state == JobState.FINISHED || state == JobState.CANCELLED);
LOG.debug("kill etl job and delete etl files. id: {}, state: {}", id, state);
if (state == JobState.CANCELLED) {
if ((!Strings.isNullOrEmpty(appId) && sparkResource.isYarnMaster()) || sparkAppHandle != null) {
try {
} catch (Exception e) {
LOG.warn("kill etl job failed. id: {}, state: {}", id, state, e);
}
}
}
if (!Strings.isNullOrEmpty(etlOutputPath)) {
try {
String outputPath = etlOutputPath.substring(0, etlOutputPath.lastIndexOf("/"));
} catch (Exception e) {
LOG.warn("delete etl files failed. id: {}, state: {}", id, state, e);
}
}
LOG.debug("clear push tasks and infos that not persist. id: {}, state: {}", id, state);
writeLock();
try {
for (Map<Long, PushTask> sentReplicaPushTask : tabletToSentReplicaPushTask.values()) {
for (PushTask pushTask : sentReplicaPushTask.values()) {
if (pushTask == null) {
continue;
}
AgentTaskQueue.removeTask(pushTask.getBackendId(), pushTask.getTaskType(), pushTask.getSignature());
}
}
hiveTableName = "";
sparkAppHandle = null;
resourceDesc = null;
tableToLoadPartitions.clear();
indexToSchemaHash.clear();
tabletToSentReplicaPushTask.clear();
finishedReplicas.clear();
quorumTablets.clear();
fullTablets.clear();
} finally {
writeUnlock();
}
}

Line under review: } catch (Exception e) {

Code after addressing the review:
private void clearJob() {
Preconditions.checkState(state == JobState.FINISHED || state == JobState.CANCELLED);
LOG.debug("kill etl job and delete etl files. id: {}, state: {}", id, state);
if (state == JobState.CANCELLED) {
if ((!Strings.isNullOrEmpty(appId) && sparkResource.isYarnMaster()) || sparkAppHandle != null) {
try {
} catch (Exception e) {
LOG.warn("kill etl job failed. id: {}, state: {}", id, state, e);
}
}
}
if (!Strings.isNullOrEmpty(etlOutputPath)) {
try {
String outputPath = etlOutputPath.substring(0, etlOutputPath.lastIndexOf("/"));
} catch (Exception e) {
LOG.warn("delete etl files failed. id: {}, state: {}", id, state, e);
}
}
LOG.debug("clear push tasks and infos that not persist. id: {}, state: {}", id, state);
writeLock();
try {
for (Map<Long, PushTask> sentReplicaPushTask : tabletToSentReplicaPushTask.values()) {
for (PushTask pushTask : sentReplicaPushTask.values()) {
if (pushTask == null) {
continue;
}
AgentTaskQueue.removeTask(pushTask.getBackendId(), pushTask.getTaskType(), pushTask.getSignature());
}
}
hiveTableName = "";
sparkAppHandle = null;
resourceDesc = null;
tableToLoadPartitions.clear();
indexToSchemaHash.clear();
tabletToSentReplicaPushTask.clear();
finishedReplicas.clear();
quorumTablets.clear();
fullTablets.clear();
} finally {
writeUnlock();
}
}
Code review comment: Changed code to return an empty List instead of throwing the exception. 

Code before review:
public List getAsArray(String key) {
if (key == null) {
return null;
}
Object value = configEntries.get(key);
if (value instanceof List) {
return (List) value;
}
throw new IllegalArgumentException("config key '" + key + "' does not map to a valid 'array'");
}

Line under review: throw new IllegalArgumentException("config key '" + key + "' does not map to a valid 'array'");

Code after addressing the review:
public List getAsArray(String key) {
if (key == null) {
return null;
}
Object value = configEntries.get(key);
if (value instanceof List) {
return (List) value;
}
return new ArrayList();
}
Code review comment: That was the the creeping feeling I had.

Code before review:
protected void destroy() {
laterExecutor.shutdown();
docprocServiceRegistry.allComponents().forEach(docprocService -> docprocService.deconstruct());
}

Line under review: docprocServiceRegistry.allComponents().forEach(docprocService -> docprocService.deconstruct());

Code after addressing the review:
protected void destroy() {
laterExecutor.shutdown();
docprocServiceRegistry.allComponents().forEach(docprocService -> docprocService.deconstruct());
}
Code review comment: @stuartwdouglas I've updated this mapper to check for the 1st non-null cause, but for now I'd still rather prefer it be a generic mapper. Does it work for you ?

Code before review:
public Response toResponse(CompositeException ex) {
Throwable t = ex.getCauses().get(0);
if (t == null) {
throw new InternalServerErrorException();
}
ExceptionMapper<Throwable> mapper = (ExceptionMapper<Throwable>) p.getExceptionMapper(t.getClass());
if (mapper == null) {
throw new InternalServerErrorException();
}
return mapper.toResponse(t);
}

Line under review: Throwable t = ex.getCauses().get(0);

Code after addressing the review:
public Response toResponse(CompositeException ex) {
Throwable t = ex.getCauses().stream().filter(s -> s != null).findFirst()
.orElseThrow(() -> new InternalServerErrorException());
ExceptionMapper<Throwable> mapper = (ExceptionMapper<Throwable>) p.getExceptionMapper(t.getClass());
if (mapper == null) {
throw new InternalServerErrorException();
}
return mapper.toResponse(t);
}
Code review comment: Well, it will work once https://github.com/quarkusio/quarkus/pull/2629 is merged. Tests are not CDI beans ATM.

Code before review:
public void persist(Object entity) {
try (EntityManagerResult emr = getEntityManager()) {
if (!emr.allowModification) {
throw new TransactionRequiredException("Transaction is not active");
}
emr.em.persist(entity);
}
}

Line under review: throw new TransactionRequiredException("Transaction is not active");

Code after addressing the review:
public void persist(Object entity) {
try (EntityManagerResult emr = getEntityManager()) {
if (!emr.allowModification) {
throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE);
}
emr.em.persist(entity);
}
}
Code review comment: Yes you are right if you consider all commits. I made this comment with the state of commit `b8309e1` in mind where it was first touched. So in the end you can ignore it now.

Code before review:
private Optional<BufferOrEvent> getNextBufferOrEvent(boolean blocking) throws IOException, InterruptedException {
if (hasReceivedAllEndOfPartitionEvents) {
return Optional.empty();
}
if (isReleased) {
throw new IllegalStateException("Released");
}
requestPartitions();
InputChannel currentChannel;
boolean moreAvailable;
Optional<BufferAndAvailability> result = Optional.empty();
do {
synchronized (inputChannelsWithData) {
while (inputChannelsWithData.size() == 0) {
if (isReleased) {
throw new IllegalStateException("Released");
}
if (blocking) {
inputChannelsWithData.wait();
}
else {
return Optional.empty();
}
}
currentChannel = inputChannelsWithData.remove();
result = currentChannel.getNextBuffer();
if (result.isPresent() && result.get().moreAvailable()) {
inputChannelsWithData.add(currentChannel);
} else {
enqueuedInputChannelsWithData.clear(currentChannel.getChannelIndex());
}
moreAvailable = !inputChannelsWithData.isEmpty();
}
} while (!result.isPresent());
final Buffer buffer = result.get().buffer();
numBytesIn.inc(buffer.getSizeUnsafe());
if (buffer.isBuffer()) {
return Optional.of(new BufferOrEvent(buffer, currentChannel.getChannelIndex(), moreAvailable));
}
else {
final AbstractEvent event = EventSerializer.fromBuffer(buffer, getClass().getClassLoader());
if (event.getClass() == EndOfPartitionEvent.class) {
channelsWithEndOfPartitionEvents.set(currentChannel.getChannelIndex());
if (channelsWithEndOfPartitionEvents.cardinality() == numberOfInputChannels) {
checkState(!moreAvailable || !pollNextBufferOrEvent().isPresent());
moreAvailable = false;
hasReceivedAllEndOfPartitionEvents = true;
}
currentChannel.notifySubpartitionConsumed();
currentChannel.releaseAllResources();
}
return Optional.of(new BufferOrEvent(event, currentChannel.getChannelIndex(), moreAvailable));
}
}


Code after addressing the review:
private Optional<BufferOrEvent> getNextBufferOrEvent(boolean blocking) throws IOException, InterruptedException {
if (hasReceivedAllEndOfPartitionEvents) {
return Optional.empty();
}
if (isReleased) {
throw new IllegalStateException("Released");
}
requestPartitions();
Optional<InputWithData<InputChannel, BufferAndAvailability>> next = waitAndGetNextData(blocking);
if (!next.isPresent()) {
return Optional.empty();
}
InputWithData<InputChannel, BufferAndAvailability> inputWithData = next.get();
return Optional.of(transformToBufferOrEvent(
inputWithData.data.buffer(),
inputWithData.moreAvailable,
inputWithData.input));
}
Code review comment: it's not clear to me how this would work here, can you make a (full) github "suggestion" so I can understand better?

Code before review:
private static String getHttpUrlFromServerSpanStableSemconv(Attributes attributes) {
String scheme = attributes.get(SemanticAttributes.URL_SCHEME);
if (scheme == null) {
return null;
}
String path = attributes.get(SemanticAttributes.URL_PATH);
if (path == null) {
return null;
}
String host = attributes.get(SemanticAttributes.SERVER_ADDRESS);
if (host == null) {
return null;
}
Long port = attributes.get(SemanticAttributes.SERVER_PORT);
if (port != null && port > 0) {
return scheme + ":
}
return scheme + ":
}

Line under review: Long port = attributes.get(SemanticAttributes.SERVER_PORT);

Code after addressing the review:
private static String getHttpUrlFromServerSpanStableSemconv(Attributes attributes) {
String scheme = attributes.get(SemanticAttributes.URL_SCHEME);
if (scheme == null) {
return null;
}
String path = attributes.get(SemanticAttributes.URL_PATH);
if (path == null) {
return null;
}
String host = attributes.get(SemanticAttributes.SERVER_ADDRESS);
if (host == null) {
return null;
}
Long port = attributes.get(SemanticAttributes.SERVER_PORT);
if (port != null && port > 0) {
return scheme + ":
}
return scheme + ":
}
Code review comment: It was changed recently though with https://github.com/quarkusio/quarkus/pull/22271.

Code before review:
void testCacheResult() {
Uni<String> uni1 = cachedService.cacheResult1(KEY_1);
assertEquals(0, cachedService.getCacheResultInvocations());
Uni<String> uni2 = cachedService.cacheResult1(KEY_1);
assertEquals(0, cachedService.getCacheResultInvocations());
assertNotSame(uni1, uni2);
String emittedItem1 = uni1.await().indefinitely();
assertEquals(1, cachedService.getCacheResultInvocations());
String emittedItem2 = uni2.await().indefinitely();
assertEquals(1, cachedService.getCacheResultInvocations());
assertSame(emittedItem1, emittedItem2);
String emittedItem3 = cachedService.cacheResult1("another-key").await().indefinitely();
assertEquals(2, cachedService.getCacheResultInvocations());
assertNotSame(emittedItem2, emittedItem3);
}


Code after addressing the review:
void testCacheResult() {
Uni<String> uni1 = cachedService.cacheResult1(KEY_1);
assertEquals(0, cachedService.getCacheResultInvocations());
Uni<String> uni2 = cachedService.cacheResult1(KEY_1);
assertEquals(0, cachedService.getCacheResultInvocations());
assertNotSame(uni1, uni2);
String emittedItem1 = uni1.await().indefinitely();
assertEquals(1, cachedService.getCacheResultInvocations());
String emittedItem2 = uni2.await().indefinitely();
assertEquals(1, cachedService.getCacheResultInvocations());
assertSame(emittedItem1, emittedItem2);
String emittedItem3 = cachedService.cacheResult1("another-key").await().indefinitely();
assertEquals(2, cachedService.getCacheResultInvocations());
assertNotSame(emittedItem2, emittedItem3);
}
Code review comment: https://github.com/jbossas/protean-shamrock/issues/706

Code before review:
private void sanitizeOptions() {
if (className == null) {
className = DEFAULT_CLASS_NAME;
}
if (className.endsWith(MojoUtils.JAVA_EXTENSION)) {
className = className.substring(0, className.length() - MojoUtils.JAVA_EXTENSION.length());
}
if (!className.contains(".")) {
className = projectGroupId.replace("-", ".").replace("_", ".") + "." + className;
}
if (StringUtils.isBlank(path)) {
path = "/hello";
}
if (!path.startsWith("/")) {
path = "/" + path;
}
}

Line under review: path = "/hello";

Code after addressing the review:
private void sanitizeOptions() {
if (className != null) {
if (className.endsWith(MojoUtils.JAVA_EXTENSION)) {
className = className.substring(0, className.length() - MojoUtils.JAVA_EXTENSION.length());
}
if (!className.contains(".")) {
className = projectGroupId.replace("-", ".").replace("_", ".") + "." + className;
}
if (StringUtils.isBlank(path)) {
path = "/hello";
}
if (!path.startsWith("/")) {
path = "/" + path;
}
}
}
Code review comment: Same here.

Code before review:
public void testParameterConstructorExtractRoleAuthorities() {
when(jwt.getClaim("scp")).thenReturn(null);
AADJwtBearerTokenAuthenticationConverter converter = new AADJwtBearerTokenAuthenticationConverter("roles",
"APPROLE_");
AbstractAuthenticationToken authenticationToken = converter.convert(jwt);
assertThat(authenticationToken.getPrincipal()).isExactlyInstanceOf(AADOAuth2AuthenticatedPrincipal.class);
AADOAuth2AuthenticatedPrincipal principal = (AADOAuth2AuthenticatedPrincipal) authenticationToken
.getPrincipal();
assertThat(principal.getAttributes()).isNotEmpty();
assertThat(principal.getAttributes()).hasSize(2);
assertThat(principal.getAuthorities()).hasSize(2);
}

Line under review: when(jwt.getClaim("scp")).thenReturn(null);

Code after addressing the review:
public void testParameterConstructorExtractRoleAuthorities() {
AADJwtBearerTokenAuthenticationConverter converter = new AADJwtBearerTokenAuthenticationConverter("roles",
"APPROLE_");
AbstractAuthenticationToken authenticationToken = converter.convert(jwt);
assertThat(authenticationToken.getPrincipal()).isExactlyInstanceOf(AADOAuth2AuthenticatedPrincipal.class);
AADOAuth2AuthenticatedPrincipal principal = (AADOAuth2AuthenticatedPrincipal) authenticationToken
.getPrincipal();
assertThat(principal.getAttributes()).isNotEmpty();
assertThat(principal.getAttributes()).hasSize(2);
assertThat(principal.getAuthorities()).hasSize(2);
}
Code review comment: @AHeise nice catch, this looks much cleaner! Now the reader will only return a new future when there is no more input from the underlying reader and the future was completed.

Code before review:
public CompletableFuture<Void> isAvailable() {
if (currentReader != null) {
return availabilityFuture = currentReader.isAvailable();
}
return availabilityFuture;
}

Line under review: return availabilityFuture = currentReader.isAvailable();

Code after addressing the review:
public CompletableFuture<Void> isAvailable() {
return availabilityFuture;
}
Code review comment: Shouldn't this be corrected as follows? Otherwise returns `true` even when the `annotationKeyword` is missing. ```suggestion                 && (semicolonToken.isMissing() || cursor < semicolonToken.textRange().endOffset()); ```

Code before review:
public boolean onPreValidation(BallerinaCompletionContext context, AnnotationDeclarationNode node) {
Token annotationKeyword = node.annotationKeyword();
Token semicolonToken = node.semicolonToken();
int cursor = context.getCursorPositionInTree();
return !annotationKeyword.isMissing() && cursor >= annotationKeyword.textRange().endOffset()
&& (semicolonToken.isMissing()) || cursor < semicolonToken.textRange().endOffset();
}

Line under review: && (semicolonToken.isMissing()) || cursor < semicolonToken.textRange().endOffset();

Code after addressing the review:
public boolean onPreValidation(BallerinaCompletionContext context, AnnotationDeclarationNode node) {
Token annotationKeyword = node.annotationKeyword();
Token semicolonToken = node.semicolonToken();
int cursor = context.getCursorPositionInTree();
return !annotationKeyword.isMissing() && cursor >= annotationKeyword.textRange().endOffset()
&& (semicolonToken.isMissing() || cursor < semicolonToken.textRange().endOffset());
}
Code review comment: Never tried to grab the binary from the instance, I will have a look.

Code before review:
private static void s2iBuild(OpenShiftClient client, BuildConfig buildConfig, File binaryFile, S2iConfig s2iConfig) {
Build build;
try {
build = client.buildConfigs().withName(buildConfig.getMetadata().getName()).instantiateBinary()
.withTimeoutInMillis(s2iConfig.buildTimeout.toMillis()).fromFile(binaryFile);
} catch (Exception e) {
if (e.getCause() instanceof StreamResetException) {
LOG.warn("Stream was reset while building. Falling back to building with the 'oc' binary.");
if (!ExecUtil.exec("oc", "start-build", buildConfig.getMetadata().getName(), "--from-archive",
binaryFile.toPath().toAbsolutePath().toString())) {
throw s2iException(e);
}
return;
} else {
throw s2iException(e);
}
}
try (BufferedReader reader = new BufferedReader(
client.builds().withName(build.getMetadata().getName()).getLogReader())) {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
System.out.println(line);
}
} catch (IOException e) {
throw s2iException(e);
}
}

Line under review: if (!ExecUtil.exec("oc", "start-build", buildConfig.getMetadata().getName(), "--from-archive",

Code after addressing the review:
private static void s2iBuild(OpenShiftClient client, BuildConfig buildConfig, File binaryFile, S2iConfig s2iConfig) {
Build build;
try {
build = client.buildConfigs().withName(buildConfig.getMetadata().getName()).instantiateBinary()
.withTimeoutInMillis(s2iConfig.buildTimeout.toMillis()).fromFile(binaryFile);
} catch (Exception e) {
if (e.getCause() instanceof StreamResetException) {
LOG.warn("Stream was reset while building. Falling back to building with the 'oc' binary.");
if (!ExecUtil.exec("oc", "start-build", buildConfig.getMetadata().getName(), "--from-archive",
binaryFile.toPath().toAbsolutePath().toString())) {
throw s2iException(e);
}
return;
} else {
throw s2iException(e);
}
}
try (BufferedReader reader = new BufferedReader(
client.builds().withName(build.getMetadata().getName()).getLogReader())) {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
System.out.println(line);
}
} catch (IOException e) {
throw s2iException(e);
}
}
Code review comment: Maybe delete the  ``` catch (Exception e) { 			e.printStackTrace(); 			fail(e.getMessage()); 		} ```   block here as well

Code before review:
public void tryLocalExecution() {
try {
PackagedProgram packagedProgramMock = mock(PackagedProgram.class);
when(packagedProgramMock.isUsingInteractiveMode()).thenReturn(true);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
ExecutionEnvironment.createLocalEnvironment();
return null;
}
}).when(packagedProgramMock).invokeInteractiveModeForExecution();
try {
final ClusterClient<?> client = new MiniClusterClient(new Configuration(), MINI_CLUSTER_RESOURCE.getMiniCluster());
client.setDetached(true);
client.run(packagedProgramMock, 1);
fail("Creating the local execution environment should not be possible");
}
catch (InvalidProgramException e) {
}
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}

Line under review: try {

Code after addressing the review:
public void tryLocalExecution() throws ProgramInvocationException, ProgramMissingJobException {
PackagedProgram packagedProgramMock = mock(PackagedProgram.class);
when(packagedProgramMock.isUsingInteractiveMode()).thenReturn(true);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
ExecutionEnvironment.createLocalEnvironment();
return null;
}
}).when(packagedProgramMock).invokeInteractiveModeForExecution();
try {
final ClusterClient<?> client = new MiniClusterClient(new Configuration(), MINI_CLUSTER_RESOURCE.getMiniCluster());
client.setDetached(true);
client.run(packagedProgramMock, 1);
fail("Creating the local execution environment should not be possible");
}
catch (InvalidProgramException e) {
}
}
Code review comment: Remove unused args

Code before review:
public void testIterateMirrorTable() throws Exception {
BValue[] args = {};
BValue[] returns = BRunUtil.invokeFunction(resultMirror, "testIterateMirrorTable", connectionArgs);
Assert.assertNotNull(returns);
Assert.assertEquals(returns[0].stringValue(), "([{id:1, name:\"Manuri\", address:\"Sri Lanka\"}, {id:2, "
+ "name:\"Devni\", address:\"Sri Lanka\"}, {id:3, name:\"Thurani\", address:\"Sri Lanka\"}], [{id:1, "
+ "name:\"Manuri\", address:\"Sri Lanka\"}, {id:2, name:\"Devni\", address:\"Sri Lanka\"}, {id:3, "
+ "name:\"Thurani\", address:\"Sri Lanka\"}])");
}

Line under review: BValue[] returns = BRunUtil.invokeFunction(resultMirror, "testIterateMirrorTable", connectionArgs);

Code after addressing the review:
public void testIterateMirrorTable() throws Exception {
BValue[] returns = BRunUtil.invokeFunction(resultMirror, "testIterateMirrorTable", connectionArgs);
Assert.assertNotNull(returns);
Assert.assertEquals(returns[0].stringValue(), "([{id:1, name:\"Manuri\", address:\"Sri Lanka\"}, {id:2, "
+ "name:\"Devni\", address:\"Sri Lanka\"}, {id:3, name:\"Thurani\", address:\"Sri Lanka\"}], [{id:1, "
+ "name:\"Manuri\", address:\"Sri Lanka\"}, {id:2, name:\"Devni\", address:\"Sri Lanka\"}, {id:3, "
+ "name:\"Thurani\", address:\"Sri Lanka\"}])");
}
Code review comment: It's only used here, I don't see the point. It's in the JDK that this interface belongs :(

Code before review:
public void close() {
}

Line under review: }

Code after addressing the review:
public void close() {
}
Code review comment: I don't  have an environmental to test the case with the principal of the hostname(fqdn), so I think it's better to keep the comment for reminders. 

Code before review:
private static String preparePrincipal(String originalPrincipal) throws UnknownHostException {
String finalPrincipal = originalPrincipal;
String[] components = originalPrincipal.split("[/@]");
if (components != null && components.length == 3) {
if (components[1].equals("_HOST")) {
finalPrincipal = components[0] + "/" +
StringUtils.toLowerCase(InetAddress.getLocalHost().getCanonicalHostName())
+ "@" + components[2];
} else if (components[1].equals("_IP")) {
finalPrincipal = components[0] + "/" +
InetAddress.getByName(InetAddress.getLocalHost().getCanonicalHostName()).getHostAddress()
+ "@" + components[2];
}
}
return finalPrincipal;
}


Code after addressing the review:
private static String preparePrincipal(String originalPrincipal) throws UnknownHostException {
String finalPrincipal = originalPrincipal;
String[] components = originalPrincipal.split("[/@]");
if (components != null && components.length == 3) {
if (components[1].equals("_HOST")) {
finalPrincipal = components[0] + "/" +
StringUtils.toLowerCase(InetAddress.getLocalHost().getCanonicalHostName())
+ "@" + components[2];
} else if (components[1].equals("_IP")) {
finalPrincipal = components[0] + "/" +
InetAddress.getByName(InetAddress.getLocalHost().getCanonicalHostName()).getHostAddress()
+ "@" + components[2];
}
}
return finalPrincipal;
}
Code review comment: it is better to extract a private createRow method here

Code before review:
protected MergedResult createMergedResult() {
boolean masterOnly = HintManager.isMasterRouteOnly();
boolean databaseOnly = HintManager.isDatabaseShardingOnly();
HintShardingType shardingType = databaseOnly ? HintShardingType.DATABASES_ONLY : HintShardingType.DATABASES_TABLES;
List<Object> row = new ArrayList<>(2);
row.add(String.valueOf(masterOnly).toLowerCase());
row.add(String.valueOf(shardingType).toLowerCase());
return new ShowShardingCTLMergedResult(Collections.singletonList(row));
}

Line under review: return new ShowShardingCTLMergedResult(Collections.singletonList(row));

Code after addressing the review:
protected MergedResult createMergedResult() {
HintShardingType shardingType = HintManager.isDatabaseShardingOnly() ? HintShardingType.DATABASES_ONLY : HintShardingType.DATABASES_TABLES;
List<Object> row = createRow(HintManager.isMasterRouteOnly(), shardingType);
return new ShowShardingCTLMergedResult(Collections.singletonList(row));
}
Code review comment: out of curiosity, you mind explain briefly about the change

Code before review:
public void testThreadsAreAddedOnlyAsNeededWithContention() throws Exception {
UnboundedScheduledExecutorService executorService = new UnboundedScheduledExecutorService();
CountDownLatch start = new CountDownLatch(100);
ThreadPoolExecutor executor =
new ThreadPoolExecutor(100, 100, Long.MAX_VALUE, MILLISECONDS, new SynchronousQueue<>());
for (int i = 0; i < 100; ++i) {
executor.execute(
() -> {
start.countDown();
try {
start.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
for (int j = 0; j < 1000; ++j) {
try {
executorService
.submit(
() -> {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
})
.get();
} catch (InterruptedException | ExecutionException e) {
}
}
});
}
executor.shutdown();
executor.awaitTermination(3, MINUTES);
int largestPool = executorService.threadPoolExecutor.getLargestPoolSize();
LOG.info("Created {} threads to execute at most 100 parallel tasks", largestPool);
assertTrue(largestPool <= 110);
executorService.shutdown();
}

Line under review: assertTrue(largestPool <= 110);

Code after addressing the review:
public void testThreadsAreAddedOnlyAsNeededWithContention() throws Exception {
UnboundedScheduledExecutorService executorService = new UnboundedScheduledExecutorService();
CountDownLatch start = new CountDownLatch(100);
ThreadPoolExecutor executor =
new ThreadPoolExecutor(100, 100, Long.MAX_VALUE, MILLISECONDS, new SynchronousQueue<>());
for (int i = 0; i < 100; ++i) {
executor.execute(
() -> {
start.countDown();
try {
start.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
for (int j = 0; j < 1000; ++j) {
try {
executorService
.submit(
() -> {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
})
.get();
} catch (InterruptedException | ExecutionException e) {
}
}
});
}
executor.shutdown();
executor.awaitTermination(3, MINUTES);
int largestPool = executorService.threadPoolExecutor.getLargestPoolSize();
LOG.info("Created {} threads to execute at most 100 parallel tasks", largestPool);
assertTrue(largestPool <= 110);
executorService.shutdown();
}
Code review comment: Update: I think we should indent `case` since it increases readability.

Code before review:
public void generate(GenType type, String definitionPath, String outPath) throws IOException {
OpenAPI api = new OpenAPIV3Parser().read(definitionPath);
OpenApiWrapper context = new OpenApiWrapper().buildFromOpenAPI(api).apiPackage(apiPackage);
if (outPath == null || "".equals(outPath)) {
String fileName = api.getInfo().getTitle().replaceAll(" ", "") + ".bal";
outPath = definitionPath.substring(0, definitionPath.lastIndexOf(File.separator) + 1);
outPath += fileName;
}
switch (type) {
case SKELETON:
writeBallerina(context, GeneratorConstants.DEFAULT_SKELETON_DIR, GeneratorConstants.SKELETON_TEMPLATE_NAME,
outPath);
break;
case CONNECTOR:
writeBallerina(context, GeneratorConstants.DEFAULT_CONNECTOR_DIR,
GeneratorConstants.CONNECTOR_TEMPLATE_NAME, outPath);
break;
case MOCK:
writeBallerina(context, GeneratorConstants.DEFAULT_MOCK_DIR, GeneratorConstants.MOCK_TEMPLATE_NAME,
outPath);
break;
default:
return;
}
}

Line under review: case SKELETON:

Code after addressing the review:
public void generate(GenType type, String definitionPath, String outPath) throws IOException {
OpenAPI api = new OpenAPIV3Parser().read(definitionPath);
OpenApiWrapper context = new OpenApiWrapper().buildFromOpenAPI(api).apiPackage(apiPackage);
if (outPath == null || outPath.isEmpty()) {
String fileName = api.getInfo().getTitle().replaceAll(" ", "") + ".bal";
outPath = definitionPath.substring(0, definitionPath.lastIndexOf(File.separator) + 1);
outPath += fileName;
}
switch (type) {
case SKELETON:
writeBallerina(context, GeneratorConstants.DEFAULT_SKELETON_DIR,
GeneratorConstants.SKELETON_TEMPLATE_NAME, outPath);
break;
case CONNECTOR:
writeBallerina(context, GeneratorConstants.DEFAULT_CONNECTOR_DIR,
GeneratorConstants.CONNECTOR_TEMPLATE_NAME, outPath);
break;
case MOCK:
writeBallerina(context, GeneratorConstants.DEFAULT_MOCK_DIR, GeneratorConstants.MOCK_TEMPLATE_NAME,
outPath);
break;
default:
return;
}
}
Code review comment: would be better to inject a clock to this and the same one into StreamingDataflowWorker instead of relying on sleep timing  Can you take a look at if that would be not too bad to add? Somewhat existing but would be nice to cleanup while modifying

Code before review:
GetDataResponse getData(GetDataRequest request) {
boolean isActiveWorkRefresh = true;
for (ComputationGetDataRequest computationRequest : request.getRequestsList()) {
if (!computationRequest.getComputationId().equals(DEFAULT_COMPUTATION_ID)) {
isActiveWorkRefresh = false;
continue;
}
for (KeyedGetDataRequest keyedRequest : computationRequest.getRequestsList()) {
if (keyedRequest.getWorkToken() == 0
|| keyedRequest.getShardingKey() != DEFAULT_SHARDING_KEY
|| keyedRequest.getValuesToFetchCount() != 0
|| keyedRequest.getBagsToFetchCount() != 0
|| keyedRequest.getTagValuePrefixesToFetchCount() != 0
|| keyedRequest.getWatermarkHoldsToFetchCount() != 0) {
isActiveWorkRefresh = false;
continue;
}
for (LatencyAttribution la : keyedRequest.getLatencyAttributionList()) {
EnumMap<LatencyAttribution.State, Duration> durations =
totalDurations.computeIfAbsent(
keyedRequest.getWorkToken(),
(Long workToken) ->
new EnumMap<LatencyAttribution.State, Duration>(
LatencyAttribution.State.class));
Duration old = durations.get(la.getState());
Duration cur = Duration.millis(la.getTotalDurationMillis());
if (old == null || old.isShorterThan(cur)) {
durations.put(la.getState(), cur);
}
}
}
}
if (!isActiveWorkRefresh) {
Uninterruptibles.sleepUninterruptibly(2000, TimeUnit.MILLISECONDS);
}
return EMPTY_DATA_RESPONDER.apply(request);
}

Line under review: || keyedRequest.getValuesToFetchCount() != 0

Code after addressing the review:
GetDataResponse getData(GetDataRequest request) {
if (!isActiveWorkRefresh(request)) {
return responder.apply(request);
}
for (ComputationGetDataRequest computationRequest : request.getRequestsList()) {
for (KeyedGetDataRequest keyedRequest : computationRequest.getRequestsList()) {
for (LatencyAttribution la : keyedRequest.getLatencyAttributionList()) {
EnumMap<LatencyAttribution.State, Duration> durations =
totalDurations.computeIfAbsent(
keyedRequest.getWorkToken(),
(Long workToken) ->
new EnumMap<LatencyAttribution.State, Duration>(
LatencyAttribution.State.class));
Duration cur = Duration.millis(la.getTotalDurationMillis());
durations.compute(la.getState(), (s, d) -> d == null || d.isShorterThan(cur) ? cur : d);
}
}
}
return EMPTY_DATA_RESPONDER.apply(request);
}
Code review comment: ```suggestion         return Files.walk(packagePath).anyMatch(path -> path.toString().endsWith(ProjectConstants.BLANG_SOURCE_EXT)); ```

Code before review:
public static boolean balFilesExists(Path packagePath) throws IOException {
if (Files.walk(packagePath).anyMatch(path -> path.toString().endsWith(ProjectConstants.BLANG_SOURCE_EXT))) {
return true;
}
return false;
}

Line under review: return false;

Code after addressing the review:
public static boolean balFilesExists(Path packagePath) throws IOException {
return Files.list(packagePath).anyMatch(path -> path.toString().endsWith(ProjectConstants.BLANG_SOURCE_EXT));
}
Code review comment: due to the PUT is `current` https://github.com/azure/azure-rest-api-specs/blob/216e7ae3aafefd2ea16a5b64a49281d21da6cb1a/specification/synapse/resource-manager/Microsoft.Synapse/preview/2019-06-01-preview/sqlPool.json#L1745

Code before review:
protected Observable<SensitivityLabelInner> getInnerAsync() {
SqlPoolSensitivityLabelsInner client = this.manager().inner().sqlPoolSensitivityLabels();
return client.getAsync(this.resourceGroupName, this.workspaceName, this.sqlPoolName, this.schemaName, this.tableName, this.columnName, SensitivityLabelSource.CURRENT);
}

Line under review: return client.getAsync(this.resourceGroupName, this.workspaceName, this.sqlPoolName, this.schemaName, this.tableName, this.columnName, SensitivityLabelSource.CURRENT);

Code after addressing the review:
protected Observable<SensitivityLabelInner> getInnerAsync() {
SqlPoolSensitivityLabelsInner client = this.manager().inner().sqlPoolSensitivityLabels();
return client.getAsync(this.resourceGroupName, this.workspaceName, this.sqlPoolName, this.schemaName, this.tableName, this.columnName, this.sensitivityLabelSource);
}
Code review comment: Equality test should be done on unescaped paths (segment lists) because the escaped form is not canonical.  Consider the following test cases, that would not pass with the current code:  ``` ... WHERE `a` > 1 ORDER BY a  -->  ORDER BY a, __name__ ... WHERE `a` > 1 AND a < 3  -->  ORDER BY a, __name__ ... ORDER BY `__name__` --> ORDER BY `__name__` ... WHERE `__name__` > ".../foo/bar" --> ORDER BY __name__ ```

Code before review:
static List<Order> getImplicitOrderBy(StructuredQuery query) {
List<String> expectedImplicitOrders = new ArrayList<>();
if (query.hasWhere()) {
fillInequalityFields(query.getWhere(), expectedImplicitOrders);
}
if (!expectedImplicitOrders.contains("__name__")) {
expectedImplicitOrders.add("__name__");
}
for (Order order : query.getOrderByList()) {
String orderField = order.getField().getFieldPath();
expectedImplicitOrders.remove(orderField);
}
List<Order> additionalOrders = new ArrayList<>();
if (!expectedImplicitOrders.isEmpty()) {
Direction lastDirection =
query.getOrderByCount() == 0
? Direction.ASCENDING
: query.getOrderByList().get(query.getOrderByCount() - 1).getDirection();
for (String field : expectedImplicitOrders) {
additionalOrders.add(
Order.newBuilder()
.setDirection(lastDirection)
.setField(FieldReference.newBuilder().setFieldPath(field).build())
.build());
}
}
return additionalOrders;
}

Line under review: for (String field : expectedImplicitOrders) {

Code after addressing the review:
static List<Order> getImplicitOrderBy(StructuredQuery query) {
List<OrderByFieldPath> expectedImplicitOrders = new ArrayList<>();
if (query.hasWhere()) {
fillInequalityFields(query.getWhere(), expectedImplicitOrders);
}
Collections.sort(expectedImplicitOrders);
if (expectedImplicitOrders.stream().noneMatch(OrderByFieldPath::isDocumentName)) {
expectedImplicitOrders.add(OrderByFieldPath.fromString("__name__"));
}
for (Order order : query.getOrderByList()) {
OrderByFieldPath orderField = OrderByFieldPath.fromString(order.getField().getFieldPath());
expectedImplicitOrders.remove(orderField);
}
List<Order> additionalOrders = new ArrayList<>();
if (!expectedImplicitOrders.isEmpty()) {
Direction lastDirection =
query.getOrderByCount() == 0
? Direction.ASCENDING
: query.getOrderByList().get(query.getOrderByCount() - 1).getDirection();
for (OrderByFieldPath field : expectedImplicitOrders) {
additionalOrders.add(
Order.newBuilder()
.setDirection(lastDirection)
.setField(
FieldReference.newBuilder().setFieldPath(field.getOriginalString()).build())
.build());
}
}
return additionalOrders;
}
Code review comment: Ah it is out-of-date... Removed

Code before review:
public void processElement(ProcessContext c) {
Row row = c.element();
IntervalWindow window = windowFn.assignWindow(row.getDateTime(windowFieldIndex).toInstant());
Row.Builder builder = Row.withSchema(outputSchema);
builder.addValues(row.getValues());
builder.addValue(window.start());
builder.addValue(window.end());
c.output(builder.build());
}


Code after addressing the review:
public void processElement(ProcessContext c) {
Row row = c.element();
IntervalWindow window = windowFn.assignWindow(row.getDateTime(windowFieldIndex).toInstant());
Row.Builder builder = Row.withSchema(outputSchema);
builder.addValues(row.getValues());
builder.addValue(window.start());
builder.addValue(window.end());
c.output(builder.build());
}
Code review comment: Ah, yes, late night copy/paste. Fixed.

Code before review:
public void testStateNotKeyed() {
final String stateId = "foo";
MyIntegerCoder myIntegerCoder = MyIntegerCoder.of();
pipeline.getCoderRegistry().registerCoderForClass(MyInteger.class, myIntegerCoder);
DoFn<String, Integer> fn =
new DoFn<String, Integer>() {
@StateId(stateId)
private final StateSpec<ValueState<Integer>> intState =
StateSpecs.value();
@ProcessElement
public void processElement(
ProcessContext c, @StateId(stateId) ValueState<Integer> state) {}
};
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("state");
thrown.expectMessage("KvCoder");
pipeline.apply(Create.of("hello", "goodbye", "hello again")).apply(ParDo.of(fn));
}

Line under review: pipeline.getCoderRegistry().registerCoderForClass(MyInteger.class, myIntegerCoder);

Code after addressing the review:
public void testStateNotKeyed() {
final String stateId = "foo";
DoFn<String, Integer> fn =
new DoFn<String, Integer>() {
@StateId(stateId)
private final StateSpec<ValueState<Integer>> intState =
StateSpecs.value();
@ProcessElement
public void processElement(
ProcessContext c, @StateId(stateId) ValueState<Integer> state) {}
};
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("state");
thrown.expectMessage("KvCoder");
pipeline.apply(Create.of("hello", "goodbye", "hello again")).apply(ParDo.of(fn));
}
Code review comment: nevermind, the point of this test is to trigger an exception

Code before review:
public void testReadXMLInvalidRecordClassWithCustomEventHandler() throws IOException {
File file = tempFolder.newFile("trainXMLSmall");
Files.write(file.toPath(), trainXML.getBytes(StandardCharsets.UTF_8));
ValidationEventHandler validationEventHandler =
event -> {
throw new RuntimeException("MyCustomValidationEventHandler failure mesage");
};
BoundedSource<WrongTrainType> source =
XmlIO.<WrongTrainType>read()
.from(file.toPath().toString())
.withRootElement("trains")
.withRecordElement("train")
.withRecordClass(WrongTrainType.class)
.withValidationEventHandler(validationEventHandler)
.createSource();
exception.expect(RuntimeException.class);
exception.expectMessage("MyCustomValidationEventHandler failure mesage");
try (Reader<WrongTrainType> reader = source.createReader(null)) {
for (boolean available = reader.start(); available; available = reader.advance()) {
reader.getCurrent();
}
}
}

Line under review: }

Code after addressing the review:
public void testReadXMLInvalidRecordClassWithCustomEventHandler() throws IOException {
File file = tempFolder.newFile("trainXMLSmall");
Files.write(file.toPath(), trainXML.getBytes(StandardCharsets.UTF_8));
ValidationEventHandler validationEventHandler =
event -> {
throw new RuntimeException("MyCustomValidationEventHandler failure mesage");
};
BoundedSource<WrongTrainType> source =
XmlIO.<WrongTrainType>read()
.from(file.toPath().toString())
.withRootElement("trains")
.withRecordElement("train")
.withRecordClass(WrongTrainType.class)
.withValidationEventHandler(validationEventHandler)
.createSource();
exception.expect(RuntimeException.class);
exception.expectMessage("MyCustomValidationEventHandler failure mesage");
try (Reader<WrongTrainType> reader = source.createReader(null)) {
for (boolean available = reader.start(); available; available = reader.advance()) {
reader.getCurrent();
}
}
}
Code review comment: May want to use `Mono.fromSupplier` as this'll eagerly create the authorization header

Code before review:
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
final ByteBuffer contents = context.getHttpRequest().getBodyAsBinaryData()
== null ? getEmptyBuffer() : context.getHttpRequest().getBodyAsBinaryData().toByteBuffer();
return Mono.just(credentials
.getAuthorizationHeaders(
context.getHttpRequest().getUrl(),
context.getHttpRequest().getHttpMethod().toString(),
contents))
.flatMapMany(headers -> Flux.fromIterable(headers.entrySet()))
.map(header -> context.getHttpRequest().setHeader(header.getKey(), header.getValue()))
.last()
.flatMap(request -> next.process());
}

Line under review: return Mono.just(credentials

Code after addressing the review:
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
return Mono.defer(() -> Mono.just(credentials.getAuthorizationHeaders(
context.getHttpRequest().getUrl(),
context.getHttpRequest().getHttpMethod().toString(),
context.getHttpRequest().getBodyAsBinaryData()))
.flatMapMany(headers -> Flux.fromIterable(headers.entrySet()))
.map(header -> context.getHttpRequest().setHeader(header.getKey(), header.getValue()))
.last()
.flatMap(request -> next.process()));
}
Code review comment: I'd be tempted to suggest checking for the other type here.

Code before review:
public TableResultInternal execute(Context ctx) {
String cName =
catalogName == null ? ctx.getCatalogManager().getCurrentCatalog() : catalogName;
String[] databases =
ctx.getCatalogManager().getCatalogOrThrowException(cName).listDatabases().stream()
.sorted()
.toArray(String[]::new);
if (likeType != null) {
databases =
Arrays.stream(databases)
.filter(
row -> {
if (likeType == LikeType.ILIKE) {
return notLike
!= SqlLikeUtils.ilike(row, likePattern, "\\");
} else {
return notLike
!= SqlLikeUtils.like(row, likePattern, "\\");
}
})
.sorted()
.toArray(String[]::new);
}
return buildStringArrayResult("database name", databases);
}

Line under review: } else {

Code after addressing the review:
public TableResultInternal execute(Context ctx) {
String cName =
catalogName == null ? ctx.getCatalogManager().getCurrentCatalog() : catalogName;
Stream<String> databases =
ctx.getCatalogManager().getCatalogOrThrowException(cName).listDatabases().stream();
if (likeType != null) {
databases =
databases.filter(
row -> {
if (likeType == LikeType.ILIKE) {
return notLike != SqlLikeUtils.ilike(row, likePattern, "\\");
} else if (likeType == LikeType.LIKE) {
return notLike != SqlLikeUtils.like(row, likePattern, "\\");
}
return false;
});
}
return buildStringArrayResult("database name", databases.sorted().toArray(String[]::new));
}
Code review comment: switch to null pointer exception check.

Code before review:
private static List<String> toLonLatStrings(GeoPoint point) {
if (point == null) {
return null;
}
return Arrays.asList(String.valueOf(point.getLongitude()), String.valueOf(point.getLatitude()));
}

Line under review: }

Code after addressing the review:
private static List<String> toLonLatStrings(GeoPoint point) {
Objects.requireNonNull(point);
return Arrays.asList(String.valueOf(point.getLongitude()), String.valueOf(point.getLatitude()));
}
Code review comment: change to empty or end with '_'

Code before review:
public List<Long> getDatabaseNamesWithPrefix(String prefix) {
if (closing) {
return null;
}
List<Long> ret = new ArrayList<Long>();
List<String> names = replicatedEnvironment.getDatabaseNames();
for (String name : names) {
if (name.equals("epochDB")) {
continue;
}
if (Strings.isNullOrEmpty(prefix)) {
if (StringUtils.isNumeric(name)) {
long db = Long.parseLong(name);
ret.add(db);
} else {
}
} else {
if (name.startsWith(prefix)) {
String dbStr = name.substring(prefix.length());
if (StringUtils.isNumeric(dbStr)) {
long db = Long.parseLong(dbStr);
ret.add(db);
} else {
}
} else {
}
}
}
Collections.sort(ret);
return ret;
}

Line under review: String dbStr = name.substring(prefix.length());

Code after addressing the review:
public List<Long> getDatabaseNamesWithPrefix(String prefix) {
if (closing) {
return null;
}
List<Long> ret = new ArrayList<Long>();
List<String> names = replicatedEnvironment.getDatabaseNames();
for (String name : names) {
if (name.equals("epochDB")) {
continue;
}
if (Strings.isNullOrEmpty(prefix)) {
if (StringUtils.isNumeric(name)) {
long db = Long.parseLong(name);
ret.add(db);
} else {
}
} else {
if (name.startsWith(prefix)) {
String dbStr = name.substring(prefix.length());
if (StringUtils.isNumeric(dbStr)) {
long db = Long.parseLong(dbStr);
ret.add(db);
} else {
}
} else {
}
}
}
Collections.sort(ret);
return ret;
}
Code review comment: 建议isNotBlank

Code before review:
public static void deleteBodyTmpFiles(String reportId) {
if (StringUtils.isNotEmpty(reportId)) {
String executeTmpFolder = StringUtils.join(
BODY_FILE_DIR,
File.separator,
"tmp",
File.separator,
reportId
);
try {
FileUtils.deleteDir(executeTmpFolder);
} catch (Exception e) {
LoggerUtil.error("删除[" + reportId + "]执行中产生的临时文件失败!", e);
}
}
}

Line under review: if (StringUtils.isNotEmpty(reportId)) {

Code after addressing the review:
public static void deleteBodyTmpFiles(String reportId) {
if (StringUtils.isNotEmpty(reportId)) {
String executeTmpFolder = StringUtils.join(
BODY_FILE_DIR,
File.separator,
"tmp",
File.separator,
reportId
);
try {
FileUtils.deleteDir(executeTmpFolder);
} catch (Exception e) {
LoggerUtil.error("删除[" + reportId + "]执行中产生的临时文件失败!", e);
}
}
}
Code review comment: The most risky bug in this code is: Potential creation of unmanaged threads leading to resource leaks if executors are not properly shut down.  You can modify the code like this: ```java @@ -53,6 +53,7 @@ public class IcebergConnector implements Connector, Closeable { // Make sure to implement Closeable or another interface for proper cleanup     private final String catalogName;     private IcebergCatalog icebergNativeCatalog;     private ExecutorService icebergJobPlanningExecutor; +    private ExecutorService refreshOtherFeExecutor;      public IcebergConnector(ConnectorContext context) {         this.catalogName = context.getCatalogName(); ... @@ -107,7 +108,8 @@ public void close() throws IOException { // Override close method to properly shutdown executors         if (icebergJobPlanningExecutor != null && !icebergJobPlanningExecutor.isShutdown()) {             icebergJobPlanningExecutor.shutdown();         } +       if (refreshOtherFeExecutor != null && !refreshOtherFeExecutor.isShutdown()) { +           refreshOtherFeExecutor.shutdown(); +       }     } ``` Explanation: It seems that the executors being created here (`icebergJobPlanningExecutor` and `refreshOtherFeExecutor`) have no corresponding shutdown mechanism in the provided code snippet. When an executor service is created but not properly shut down, it keeps running and waiting for tasks. This can lead to a situation where these executor services consume system resources unnecessarily and potentially cause memory leaks or thread leaks, which would be considered a serious issue, particularly if new instances of `IcebergConnector` are frequently created and disposed of. Implementing `Closeable` and adding a `close` method (or ensuring there is one if it's already part of the superclass not visible in the snippet), which shuts down these executors, allows for proper cleanup when an `IcebergConnector` instance is no longer needed.

Code before review:
private ExecutorService buildBackgroundJobPlanningExecutor() {
int defaultPoolSize = Math.max(2, Runtime.getRuntime().availableProcessors() / 8);
int backgroundIcebergJobPlanningThreadPoolSize = Integer.parseInt(properties.getOrDefault(
"background_iceberg_job_planning_thread_num", String.valueOf(defaultPoolSize)));
return newWorkerPool(catalogName + "-background-iceberg-worker-pool", backgroundIcebergJobPlanningThreadPoolSize);
}

Line under review: int backgroundIcebergJobPlanningThreadPoolSize = Integer.parseInt(properties.getOrDefault(

Code after addressing the review:
private ExecutorService buildBackgroundJobPlanningExecutor() {
int defaultPoolSize = Math.max(2, Runtime.getRuntime().availableProcessors() / 8);
int backgroundIcebergJobPlanningThreadPoolSize = Integer.parseInt(properties.getOrDefault(
"background_iceberg_job_planning_thread_num", String.valueOf(defaultPoolSize)));
return newWorkerPool(catalogName + "-background-iceberg-worker-pool", backgroundIcebergJobPlanningThreadPoolSize);
}
Code review comment: >   One other reason that could explain that it works is that some execution engines write at parallelism one resulting into a single instance of the write DoFn

Code before review:
public void teardown() throws Exception {
if (producer != null) {
if (producer.getOutstandingRecordsCount() > 0) {
producer.flushSync();
}
producer.destroy();
}
producer = null;
}

Line under review: producer = null;

Code after addressing the review:
public void teardown() throws Exception {
teardownSharedProducer();
}