muttakin2301/ccr2000 huggingface dataset:
Code review comment: FWIW I took a quick stab at making Neo4j Config Serializable but it didn't pan out.  My colleagues at Neo4j will pick up the task but it's apparently not realistically something that can be fixed in the short term.   https://github.com/neo4j/neo4j-java-driver/issues/1081

Code under review:
void populateDisplayData(DisplayData.Builder builder) {
      builder.addIfNotNull(DisplayData.item("neo4j-url", getUrl()));
      builder.addIfNotNull(DisplayData.item("neo4j-username", getUsername()));
      builder.addIfNotNull(
          DisplayData.item(
              "neo4j-password", getPassword() != null ? "<provided>" : "<not-provided>"));
      builder.addIfNotNull(
          DisplayData.item(
              "neo4j-encryption", getEncryption() != null ? "<provided>" : "<not-provided>"));
    }

Line commented on: builder.addIfNotNull(

Revised code:
void populateDisplayData(DisplayData.Builder builder) {
      builder.addIfNotNull(DisplayData.item("neo4j-url", getUrl()));
      builder.addIfNotNull(DisplayData.item("neo4j-username", getUsername()));
      builder.addIfNotNull(
          DisplayData.item(
              "neo4j-password", getPassword() != null ? "<provided>" : "<not-provided>"));
    }
Code review comment: This is very nitpicky, but I wonder if this should just say `"none"`. Given the format of the string we'd end up with something like: ``` [Authenticated account] Client ID: No Application Identifier Available, Tenant ID:... ```  Which both feels wordy and also because the consts don't match the string you get weird disconnects.

Code under review:
private String getAccountIdentifierMessage(String identifierName, String identifierValue) {
        if (identifierValue == null) {
            return "No " + identifierName + " available.";
        }
        return identifierValue;
    }

Line commented on: return "No " + identifierName + " available.";

Revised code:
private String getAccountIdentifierMessage(String identifierName, String identifierValue) {
        if (identifierValue == null) {
            return "No " + identifierName + " available.";
        }
        return identifierValue;
    }
Code review comment: Nope, and this would have failed previously when using the `String.replaceAll`.

Code under review:
public PlaybackClient(RecordedData recordedData, Map<String, String> textReplacementRules) {
        Objects.requireNonNull(recordedData, "'recordedData' cannot be null.");

        this.recordedData = recordedData;
        this.textReplacementRules = new HashMap<>();
        if (textReplacementRules != null) {
            
            
            for (Map.Entry<String, String> kvp : textReplacementRules.entrySet()) {
                this.textReplacementRules.put(Pattern.compile(kvp.getKey()), kvp.getValue());
            }
        }
    }

Line commented on: this.textReplacementRules.put(Pattern.compile(kvp.getKey()), kvp.getValue());

Revised code:
public PlaybackClient(RecordedData recordedData, Map<String, String> textReplacementRules) {
        Objects.requireNonNull(recordedData, "'recordedData' cannot be null.");

        this.recordedData = recordedData;
        this.textReplacementRules = new HashMap<>();
        if (textReplacementRules != null) {
            
            
            for (Map.Entry<String, String> kvp : textReplacementRules.entrySet()) {
                this.textReplacementRules.put(Pattern.compile(kvp.getKey()), kvp.getValue());
            }
        }
    }
Code review comment: Do we need to create new container for all 3 exec tests?

Code under review:
public void testContainerExecHounorsTimeout() throws IOException, InterruptedException, ExecutionException {
        final ContainerName containerName = new ContainerName("docker-test-foo");
        final String containerHostname = "hostName1";

        docker.createContainerCommand(dockerImage, containerName, containerHostname).withManagedBy(MANAGER_NAME).create();
        Optional<Container> container = docker.getContainer(containerName);
        assertTrue(container.isPresent());
        assertEquals(container.get().state, Container.State.CREATED);

        docker.startContainer(containerName);
        container = docker.getContainer(containerName);
        assertTrue(container.isPresent());
        assertEquals(container.get().state, Container.State.RUNNING);

        docker.executeInContainerAsRoot(containerName, Optional.of(1L), "sh", "-c", "sleep 5");
    }

Line commented on: final ContainerName containerName = new ContainerName("docker-test-foo");

Revised code:
public void testContainerExecHounorsTimeout() throws IOException, InterruptedException, ExecutionException {
        final ContainerName containerName = new ContainerName("docker-test-foo");
        final String containerHostname = "hostName1";

        docker.createContainerCommand(dockerImage, containerName, containerHostname).withManagedBy(MANAGER_NAME).create();
        docker.startContainer(containerName);
        docker.executeInContainerAsRoot(containerName, 1L, "sh", "-c", "sleep 5");
    }
Code review comment: I think I can and we should.   Only user actively set this method in their 2.59.0 pipeline will be affected. Users do not explicitly set this method, and upgrade from <=2.58.0 are unaffected. For those indeed use this method in 2.59.0 they have good reason to do so. We are removing a tested and functioning feature on request, make it no-op or warning then user won't aware this feature is gone in the next release.  In the past Beam has an "Experimental" annotation but voted to remove them (#26490). Now "new code is changeable/evolving by default" (see discussion link in that PR) especially true for a new API in single version not enabled by default.

Code under review:
public WriteWithResults withWriteResults() {
      return new WriteWithResults(
          getBigtableConfig(),
          getBigtableWriteOptions(),
          getServiceFactory(),
          getBadRecordErrorHandler(),
          getBadRecordRouter());
    }

Line commented on: getBadRecordErrorHandler(),

Revised code:
public WriteWithResults withWriteResults() {
      return new WriteWithResults(
          getBigtableConfig(),
          getBigtableWriteOptions(),
          getServiceFactory(),
          getBadRecordErrorHandler(),
          getBadRecordRouter());
    }
Code review comment: As is stands this is a bit redundant (albeit with safer defaults) as `TestingHighAvailabilityServices` could be used in a similar manner. Do you intend to change this later on to pass everything through a `TestingHighAvailabilityServices` constructor?

Code under review:
public TestingHighAvailabilityServices build() {
		final TestingHighAvailabilityServices testingHighAvailabilityServices = new TestingHighAvailabilityServices();

		testingHighAvailabilityServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
		testingHighAvailabilityServices.setDispatcherLeaderRetriever(dispatcherLeaderRetriever);
		testingHighAvailabilityServices.setWebMonitorEndpointLeaderRetriever(webMonitorEndpointLeaderRetriever);

		testingHighAvailabilityServices.setJobMasterLeaderRetrieverFunction(jobMasterLeaderRetrieverFunction);
		testingHighAvailabilityServices.setJobMasterLeaderElectionServiceFunction(jobMasterLeaderElectionServiceFunction);

		testingHighAvailabilityServices.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService);
		testingHighAvailabilityServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);
		testingHighAvailabilityServices.setWebMonitorEndpointLeaderElectionService(webMonitorEndpointLeaderElectionService);

		testingHighAvailabilityServices.setCheckpointRecoveryFactory(checkpointRecoveryFactory);
		testingHighAvailabilityServices.setSubmittedJobGraphStore(submittedJobGraphStore);
		testingHighAvailabilityServices.setRunningJobsRegistry(runningJobsRegistry);

		return testingHighAvailabilityServices;
	}

Line commented on: testingHighAvailabilityServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);

Revised code:
public TestingHighAvailabilityServices build() {
		final TestingHighAvailabilityServices testingHighAvailabilityServices = new TestingHighAvailabilityServices();

		testingHighAvailabilityServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
		testingHighAvailabilityServices.setDispatcherLeaderRetriever(dispatcherLeaderRetriever);
		testingHighAvailabilityServices.setWebMonitorEndpointLeaderRetriever(webMonitorEndpointLeaderRetriever);

		testingHighAvailabilityServices.setJobMasterLeaderRetrieverFunction(jobMasterLeaderRetrieverFunction);
		testingHighAvailabilityServices.setJobMasterLeaderElectionServiceFunction(jobMasterLeaderElectionServiceFunction);

		testingHighAvailabilityServices.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService);
		testingHighAvailabilityServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);
		testingHighAvailabilityServices.setWebMonitorEndpointLeaderElectionService(webMonitorEndpointLeaderElectionService);

		testingHighAvailabilityServices.setCheckpointRecoveryFactory(checkpointRecoveryFactory);
		testingHighAvailabilityServices.setSubmittedJobGraphStore(submittedJobGraphStore);
		testingHighAvailabilityServices.setRunningJobsRegistry(runningJobsRegistry);

		return testingHighAvailabilityServices;
	}
Code review comment: What's this for? To fix bug?

Code under review:
private void materializeSlotForEmptyMaterializedTableRef(BaseTableRef tblRef, Analyzer analyzer) {
        if (tblRef.getDesc().getMaterializedSlots().isEmpty()) {
            Column minimuColumn = null;
            for (Column col : tblRef.getTable().getBaseSchema()) {
                if (minimuColumn == null || col.getDataType().getSlotSize() < minimuColumn
                        .getDataType().getSlotSize()) {
                    minimuColumn = col;
                }
            }
            if (minimuColumn != null) {
                SlotDescriptor slot = tblRef.getDesc().getColumnSlot(minimuColumn.getName());
                if (slot != null) {
                    slot.setIsMaterialized(true);
                } else {
                    slot = analyzer.getDescTbl().addSlotDescriptor(tblRef.getDesc());
                    slot.setColumn(minimuColumn);
                    slot.setIsMaterialized(true);
                    slot.setIsNullable(minimuColumn.isAllowNull());
                }
            }
        }
    }

Line commented on: slot.setIsNullable(minimuColumn.isAllowNull());

Revised code:
private void materializeSlotForEmptyMaterializedTableRef(BaseTableRef tblRef, Analyzer analyzer) {
        if (tblRef.getDesc().getMaterializedSlots().isEmpty()) {
            Column minimuColumn = null;
            for (Column col : tblRef.getTable().getBaseSchema()) {
                if (minimuColumn == null || col.getDataType().getSlotSize() < minimuColumn
                        .getDataType().getSlotSize()) {
                    minimuColumn = col;
                }
            }
            if (minimuColumn != null) {
                SlotDescriptor slot = tblRef.getDesc().getColumnSlot(minimuColumn.getName());
                if (slot != null) {
                    slot.setIsMaterialized(true);
                } else {
                    slot = analyzer.getDescTbl().addSlotDescriptor(tblRef.getDesc());
                    slot.setColumn(minimuColumn);
                    slot.setIsMaterialized(true);
                    slot.setIsNullable(minimuColumn.isAllowNull());
                }
            }
        }
    }
Code review comment: The most risky bug in this code is: Concurrency issues due to non-thread-safe data structure access.  You can modify the code like this: Replace `HashSet` with a thread-safe set implementation such as `ConcurrentHashMap.newKeySet()` or synchronize access to `visistedIndexSet`. ``` // Change the type of visistedIndexSet to a concurrent collection private Set<Long> visistedIndexSet = ConcurrentHashMap.newKeySet(); ```

Code under review:
public void gsonPostProcess() throws IOException {
        visistedIndexSet = new HashSet<>();
    }

Line commented on: visistedIndexSet = new HashSet<>();

Revised code:
public void gsonPostProcess() throws IOException {
        visitedIndexSet = new HashSet<>();
    }
Code review comment: Now fixed to `return ResourceManagerUtils.toPrimitiveBoolean(this.innerModel().allowCrossTenantReplication());`.  The another one also had the same fix.

Code under review:
public boolean isAllowCrossTenantReplication() {
        if (this.innerModel().allowCrossTenantReplication() == null) {
            return true;
        }
        return this.innerModel().allowCrossTenantReplication();
    }

Line commented on: return true;

Revised code:
public boolean isAllowCrossTenantReplication() {
        if (this.innerModel().allowCrossTenantReplication() == null) {
            return true;
        }
        return this.innerModel().allowCrossTenantReplication();
    }
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 under 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 commented on: Long port = attributes.get(SemanticAttributes.SERVER_PORT);

Revised code:
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: Well, you have to write it :-D It's a pattern I used a long time ago (with callbacks).

Code under review:
private CompletableResultCode export(TraceRequestMarshaler marshaler, int numItems) {
        if (isShutdown.get()) {
            return CompletableResultCode.ofFailure();
        }

        exporterMetrics.addSeen(numItems);

        var result = new CompletableResultCode();
        var onSuccessHandler = new ClientRequestOnSuccessHandler(headers, compressionEnabled, exporterMetrics, marshaler,
                loggedUnimplemented, logger, type, numItems, result);
        client.request(server)
                .onSuccess(onSuccessHandler)
                .onFailure(new Handler<>() {
                    @Override
                    public void handle(Throwable t) {
                        
                        

                        client.request(server)
                                .onSuccess(onSuccessHandler)
                                .onFailure(new Handler<>() {
                                    @Override
                                    public void handle(Throwable event) {
                                        failOnClientRequest(numItems, t, result);
                                    }
                                });
                    }
                });

        return result;
    }

Line commented on: public void handle(Throwable event) {

Revised code:
private CompletableResultCode export(TraceRequestMarshaler marshaler, int numItems) {
        if (isShutdown.get()) {
            return CompletableResultCode.ofFailure();
        }

        exporterMetrics.addSeen(numItems);

        var result = new CompletableResultCode();
        var onSuccessHandler = new ClientRequestOnSuccessHandler(headers, compressionEnabled, exporterMetrics, marshaler,
                loggedUnimplemented, logger, type, numItems, result);
        client.request(server)
                .onSuccess(onSuccessHandler)
                .onFailure(new Handler<>() {
                    @Override
                    public void handle(Throwable t) {
                        
                        

                        client.request(server)
                                .onSuccess(onSuccessHandler)
                                .onFailure(new Handler<>() {
                                    @Override
                                    public void handle(Throwable event) {
                                        failOnClientRequest(numItems, t, result);
                                    }
                                });
                    }
                });

        return result;
    }
Code review comment: `isNodeWithSyntaxKindInList` is used / can be used in the places other than checking for duplicate qualifiers. Changing the name would be a problem in such scenario.   In fact in duplicate check we have "ERROR_DUPLICATE_QUALIFIER" in the next line. So keeping the name as it is, would not affect readability I think. WDYT?

Code under review:
private STNode createFuncDefNodeList(List<STNode> qualifierList) {
        
        
        List<STNode> validatedList = new ArrayList<>();

        for (int i = 0; i < qualifierList.size(); i++) {
            STNode qualifier = qualifierList.get(i);
            int nextIndex = i + 1;

            if (isNodeWithSyntaxKindInList(validatedList, qualifier.kind)) {
                updateLastNodeInListWithInvalidNode(validatedList, qualifier,
                        DiagnosticErrorCode.ERROR_DUPLICATE_QUALIFIER, ((STToken) qualifier).text());
            } else if (isValidFuncDefQualifier(qualifier.kind)) {
                validatedList.add(qualifier);
            } else if (qualifierList.size() != nextIndex) {
                updateANodeInListWithInvalidNode(qualifierList, nextIndex, qualifier,
                        DiagnosticErrorCode.ERROR_QUALIFIER_NOT_ALLOWED, ((STToken) qualifier).text());
            }
        }

        return STNodeFactory.createNodeList(validatedList);
    }

Line commented on: if (isNodeWithSyntaxKindInList(validatedList, qualifier.kind)) {

Revised code:
private STNode createFuncDefNodeList(List<STNode> qualifierList) {
        
        
        List<STNode> validatedList = new ArrayList<>();

        for (int i = 0; i < qualifierList.size(); i++) {
            STNode qualifier = qualifierList.get(i);
            int nextIndex = i + 1;

            if (isDuplicate(validatedList, qualifier.kind)) {
                updateLastNodeInListWithInvalidNode(validatedList, qualifier,
                        DiagnosticErrorCode.ERROR_DUPLICATE_QUALIFIER, ((STToken) qualifier).text());
            } else if (isValidFuncDefQualifier(qualifier.kind)) {
                validatedList.add(qualifier);
            } else if (qualifierList.size() != nextIndex) {
                updateANodeInListWithInvalidNode(qualifierList, nextIndex, qualifier,
                        DiagnosticErrorCode.ERROR_QUALIFIER_NOT_ALLOWED, ((STToken) qualifier).text());
            }
        }

        return STNodeFactory.createNodeList(validatedList);
    }
Code review comment: here, "value" should be casted to BBoolean and the booleanValue() must be called to get the boolean value.

Code under review:
private void setDataSourceProperties(BMap options, HikariConfig config) {
        Set<String> keySet = options.keySet();
        for (String key : keySet) {
            BValue value = options.get(key);
            if (value instanceof BString) {
                config.addDataSourceProperty(key, value.stringValue());
            } else if (value instanceof BInteger) {
                config.addDataSourceProperty(key, ((BInteger) value).intValue());
            } else if (value instanceof BBoolean) {
                config.addDataSourceProperty(key, Boolean.parseBoolean(value.stringValue()));
            }
        }
    }

Line commented on: config.addDataSourceProperty(key, Boolean.parseBoolean(value.stringValue()));

Revised code:
private void setDataSourceProperties(BMap options, HikariConfig config) {
        Set<String> keySet = options.keySet();
        for (String key : keySet) {
            BValue value = options.get(key);
            if (value instanceof BString) {
                config.addDataSourceProperty(key, value.stringValue());
            } else if (value instanceof BInteger) {
                config.addDataSourceProperty(key, ((BInteger) value).intValue());
            } else if (value instanceof BBoolean) {
                config.addDataSourceProperty(key, ((BBoolean) value).booleanValue());
            } else if (value instanceof BFloat) {
                config.addDataSourceProperty(key, ((BFloat) value).floatValue());
            }
        }
    }
Code review comment: I prefer 1. I think which is unnecessarily to persist the orderByElements.

Code under review:
public int hashCode() {
        int result = 31 * Boolean.hashCode(isStar) + Boolean.hashCode(isDistinct);
        if (exprs != null) {
            for (Expr expr : exprs) {
                result = 31 * result + Objects.hashCode(expr);
            }
        }
        if(orderByElements != null) {
            for(OrderByElement order : orderByElements) {
                result = 31 * result + Objects.hashCode(order);
            }
        }
        return result;
    }

Line commented on: result = 31 * result + Objects.hashCode(expr);

Revised code:
public int hashCode() {
        int result = 31 * Boolean.hashCode(isStar) + Boolean.hashCode(isDistinct);
        if (exprs != null) {
            for (Expr expr : exprs) {
                result = 31 * result + Objects.hashCode(expr);
            }
        }
        if(orderByElements != null) {
            for(OrderByElement order : orderByElements) {
                result = 31 * result + Objects.hashCode(order);
            }
        }
        return result;
    }
Code review comment: I think we'll have to add a Reshuffle before cleanup here to make sure that cleanup doesn't run till previous step is finished (including retries).

Code under review:
public void populateDisplayData(DisplayData.Builder builder) {
      super.populateDisplayData(builder);
      builder
          .addIfNotNull(
              DisplayData.item("table", BigQueryHelpers.displayTable(getTableProvider()))
                  .withLabel("Table"))
          .addIfNotNull(DisplayData.item("query", getQuery()).withLabel("Query"))
          .addIfNotNull(
              DisplayData.item("flattenResults", getFlattenResults())
                  .withLabel("Flatten Query Results"))
          .addIfNotNull(
              DisplayData.item("useLegacySql", getUseLegacySql())
                  .withLabel("Use Legacy SQL Dialect"))
          .addIfNotDefault(
              DisplayData.item("validation", getValidate()).withLabel("Validation Enabled"), true);
    }

Line commented on: super.populateDisplayData(builder);

Revised code:
public void populateDisplayData(DisplayData.Builder builder) {
      this.inner.populateDisplayData(builder);
    }
Code review comment: Alter Stmt write job to alterJobsV2，MaterializedViewHandler read the alterJobsV2; So this is concurrent access; To avoid unnecessary concurrent issue,I think better to read a alter job snapshot;

Code under review:
private void runAlterJobV2() {
        replayJobDependencyAfterCatalogReady();
        Iterator<Map.Entry<Long, AlterJobV2>> iterator = getAlterJobsCopy().entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<Long, AlterJobV2> entry = iterator.next();
            RollupJobV2 alterJob = (RollupJobV2)entry.getValue();
            if (alterJob.isDone()) {
                removeJobFromRunningQueue(alterJob);

                int ret = removeAlterJobV2FromTableNotFinalStateJobMap(alterJob);
                if (ret == 0) {
                    changeTableStatus(alterJob.getDbId(), alterJob.getTableId(), OlapTableState.NORMAL);
                }
                continue;
            }

            
            if (!checkRollupJobDependency(alterJob)) {
                continue;
            }

            
            runAlterJobWithConcurrencyLimit(alterJob);
        }
    }

Line commented on: Iterator<Map.Entry<Long, AlterJobV2>> iterator = getAlterJobsCopy().entrySet().iterator();

Revised code:
private void runAlterJobV2() {
        Iterator<Map.Entry<Long, AlterJobV2>> iterator = getAlterJobsCopy().entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<Long, AlterJobV2> entry = iterator.next();
            RollupJobV2 alterJob = (RollupJobV2)entry.getValue();
            if (alterJob.isDone()) {
                removeJobFromRunningQueue(alterJob);

                boolean tableIsNormal = removeAlterJobV2FromTableNotFinalStateJobMap(alterJob);
                if (tableIsNormal) {
                    changeTableStatus(alterJob.getDbId(), alterJob.getTableId(), OlapTableState.NORMAL);
                }
                continue;
            }
            
            runAlterJobWithConcurrencyLimit(alterJob);
        }
    }
Code review comment: That looks like the list is not useful, and it feels weird that if the exception has no cause it's not considered the root cause, since `null` will be returned.

Code under review:
public static Throwable getRootCause(Throwable exception) {
        final List<Throwable> exceptionChain = new ArrayList<>();
        Throwable curr = exception;
        while (curr != null) {
            exceptionChain.add(curr);
            curr = curr.getCause();
        }
        return exceptionChain.isEmpty() ? null : exceptionChain.get(exceptionChain.size() - 1);
    }

Line commented on: Throwable curr = exception;

Revised code:
public static Throwable getRootCause(Throwable exception) {
        final List<Throwable> chain = new ArrayList<>();
        Throwable curr = exception;
        while (curr != null && !chain.contains(curr)) {
            chain.add(curr);
            curr = curr.getCause();
        }
        return chain.isEmpty() ? null : chain.get(chain.size() - 1);
    }
Code review comment: null is passed when connection is suspended, lost, or on (re)connected, or when cache is initialized(?)  So I think the correct thing to do is to duplicate the current statement to within each `case` in the below switch (and document getData may be null on some other event types)

Code under review:
private void childEvent(CuratorFramework ignored, PathChildrenCacheEvent event) {
        zkWatcherExecutor.execute(() -> {
            ChildData data = event.getData();
            if (data == null) return; 
            ApplicationId applicationId = ApplicationId.fromSerializedForm(Path.fromString(data.getPath()).getName());
            switch (event.getType()) {
                case CHILD_ADDED:
                    /* A new application is added when a session is added, @see
                    {@link com.yahoo.vespa.config.server.session.SessionRepository
                    log.log(Level.FINE, TenantRepository.logPre(applicationId) + "Application added: " + applicationId);
                    break;
                
                case CHILD_REMOVED:
                    removeApplication(applicationId);
                    break;
                case CHILD_UPDATED:
                    
                    break;
                default:
                    break;
            }
            
            removeUnusedApplications();
        });
    }

Line commented on: if (data == null) return;

Revised code:
private void childEvent(CuratorFramework ignored, PathChildrenCacheEvent event) {
        zkWatcherExecutor.execute(() -> {
            
            switch (event.getType()) {
                case CHILD_ADDED:
                    /* A new application is added when a session is added, @see
                    {@link com.yahoo.vespa.config.server.session.SessionRepository
                    ApplicationId applicationId = ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName());
                    log.log(Level.FINE, TenantRepository.logPre(applicationId) + "Application added: " + applicationId);
                    break;
                
                case CHILD_REMOVED:
                    removeApplication(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
                    break;
                case CHILD_UPDATED:
                    
                    break;
                default:
                    break;
            }
            
            removeUnusedApplications();
        });
    }
Code review comment: ok thanks I understand now, sorry for the confusion.  I think we'd normally do such a thing with a different build item, but I won't slow you down.

Code under review:
public void doInit() {
        try {
            this.context = createContext();
            this.context.setRegistry(registry);

            
            
            
            
            RuntimeSupport.bindProperties(properties, context, PFX_CAMEL_CONTEXT);

            context.setLoadTypeConverters(false);

            
            
            
            if (ImageInfo.inImageBuildtimeCode()) {
                context.getModelJAXBContextFactory().newJAXBContext();
            }
        } catch (Exception e) {
            throw RuntimeCamelException.wrapRuntimeCamelException(e);
        }
    }

Line commented on: if (ImageInfo.inImageBuildtimeCode()) {

Revised code:
public void doInit() {
        try {
            this.context = createContext();
            this.context.setRegistry(registry);

            
            
            
            
            RuntimeSupport.bindProperties(properties, context, PFX_CAMEL_CONTEXT);

            context.setLoadTypeConverters(false);

            
            
            
            if (ImageInfo.inImageBuildtimeCode()) {
                context.getModelJAXBContextFactory().newJAXBContext();
            }
        } catch (Exception e) {
            throw RuntimeCamelException.wrapRuntimeCamelException(e);
        }
    }
Code review comment: Let's check `!node.rightDoubleArrow().isMissing()` as well

Code under review:
private boolean onSuggestionsAfterDoubleArrow(BallerinaCompletionContext context, MatchClauseNode node) {
        return context.getCursorPositionInTree() >= node.rightDoubleArrow().textRange().endOffset();
    }

Line commented on: return context.getCursorPositionInTree() >= node.rightDoubleArrow().textRange().endOffset();

Revised code:
private boolean onSuggestionsAfterDoubleArrow(BallerinaCompletionContext context, MatchClauseNode node) {
        Token rightDoubleArrow = node.rightDoubleArrow();
        return !rightDoubleArrow.isMissing() 
                && context.getCursorPositionInTree() >= rightDoubleArrow.textRange().endOffset();
    }
Code review comment: The body type is always data, you can return the enum rather than creating a new field variable for it for every instance.

Code under review:
public AmqpBodyType getBodyType() {
        return bodyType;
    }

Line commented on: return bodyType;

Revised code:
public AmqpBodyType getBodyType() {
        return AmqpBodyType.DATA;
    }
Code review comment: No idea. I don't have access to any mac hw, so I tested this PR only on Windows and Linux. This bit hasn't been changed though.

Code under review:
protected List<String> getContainerRuntimeBuildArgs() {
        final List<String> containerRuntimeArgs = super.getContainerRuntimeBuildArgs();
        final String volumeOutputPath;
        if (SystemUtils.IS_OS_WINDOWS) {
            volumeOutputPath = FileUtil.translateToVolumePath(outputPath);
        } else {
            volumeOutputPath = outputPath;
        }

        final String selinuxBindOption;
        if (SystemUtils.IS_OS_MAC && containerRuntime == PODMAN) {
            selinuxBindOption = "";
        } else {
            selinuxBindOption = ":z";
        }

        Collections.addAll(containerRuntimeArgs, "-v",
                volumeOutputPath + ":" + NativeImageBuildStep.CONTAINER_BUILD_VOLUME_PATH + selinuxBindOption);
        return containerRuntimeArgs;
    }

Line commented on: selinuxBindOption = "";

Revised code:
protected List<String> getContainerRuntimeBuildArgs() {
        final List<String> containerRuntimeArgs = super.getContainerRuntimeBuildArgs();
        final String volumeOutputPath;
        if (SystemUtils.IS_OS_WINDOWS) {
            volumeOutputPath = FileUtil.translateToVolumePath(outputPath);
        } else {
            volumeOutputPath = outputPath;
        }

        final String selinuxBindOption;
        if (SystemUtils.IS_OS_MAC && containerRuntime == PODMAN) {
            selinuxBindOption = "";
        } else {
            selinuxBindOption = ":z";
        }

        Collections.addAll(containerRuntimeArgs, "-v",
                volumeOutputPath + ":" + NativeImageBuildStep.CONTAINER_BUILD_VOLUME_PATH + selinuxBindOption);
        return containerRuntimeArgs;
    }
Code review comment: Is this thread safe? even though dbIdToBackupOrRestoreJob is a concurrent hash map

Code under review:
public void removeOldJobs() {
        long currentTimeMs = System.currentTimeMillis();
        Iterator<Map.Entry<Long, AbstractJob>> iterator = dbIdToBackupOrRestoreJob.entrySet().iterator();
        while (iterator.hasNext()) {
            AbstractJob job = iterator.next().getValue();
            if (isJobExpired(job, currentTimeMs)) {
                LOG.warn("discard expired job {}", job);
                iterator.remove();
            }
        }
    }

Line commented on: Iterator<Map.Entry<Long, AbstractJob>> iterator = dbIdToBackupOrRestoreJob.entrySet().iterator();

Revised code:
public void removeOldJobs() throws DdlException {
        tryLock();
        try {
            long currentTimeMs = System.currentTimeMillis();
            Iterator<Map.Entry<Long, AbstractJob>> iterator = dbIdToBackupOrRestoreJob.entrySet().iterator();
            while (iterator.hasNext()) {
                AbstractJob job = iterator.next().getValue();
                if (isJobExpired(job, currentTimeMs)) {
                    LOG.warn("discard expired job {}", job);
                    iterator.remove();
                }
            }
        } finally {
            seqlock.unlock();
        }
    }
Code review comment: add comment on why you rebuffer here

Code under review:
public CheckpointMarkImpl getCheckpointMark() {
    subscriber.rebuffer();
    return new CheckpointMarkImpl(fetchOffset, committer);
  }

Line commented on: subscriber.rebuffer();

Revised code:
public CheckpointMarkImpl getCheckpointMark() {
    
    
    
    subscriber.rebuffer();
    return new CheckpointMarkImpl(fetchOffset, committer);
  }
Code review comment: Oh, I see. I think we should find expressions that satisfy a one-to-one mapping and enhance the logic further.

Code under review:
public Rule build() {
        return logicalFilter(logicalAggregate()).then(filter -> {
            LogicalAggregate<GroupPlan> aggregate = filter.child();
            Set<Slot> groupBySlots = new HashSet<>();
            for (Expression groupByExpression : aggregate.getGroupByExpressionList()) {
                if (groupByExpression instanceof Slot) {
                    groupBySlots.add((Slot) groupByExpression);
                }
            }
            List<Expression> pushDownPredicates = Lists.newArrayList();
            List<Expression> filterPredicates = Lists.newArrayList();
            ExpressionUtils.extractConjunct(filter.getPredicates()).forEach(conjunct -> {
                Set<Slot> conjunctSlots = SlotExtractor.extractSlot(conjunct);
                if (groupBySlots.containsAll(conjunctSlots)) {
                    pushDownPredicates.add(conjunct);
                } else {
                    
                    filterPredicates.add(conjunct);
                }
            });

            return pushDownPredicate(filter, aggregate, pushDownPredicates, filterPredicates);
        }).toRule(RuleType.PUSH_DOWN_PREDICATE_THROUGH_AGGREGATION);
    }

Line commented on: if (groupByExpression instanceof Slot) {

Revised code:
public Rule build() {
        return logicalFilter(logicalAggregate()).then(filter -> {
            LogicalAggregate<GroupPlan> aggregate = filter.child();
            Set<Slot> groupBySlots = new HashSet<>();
            for (Expression groupByExpression : aggregate.getGroupByExpressionList()) {
                if (groupByExpression instanceof Slot) {
                    groupBySlots.add((Slot) groupByExpression);
                }
            }
            List<Expression> pushDownPredicates = Lists.newArrayList();
            List<Expression> filterPredicates = Lists.newArrayList();
            ExpressionUtils.extractConjunct(filter.getPredicates()).forEach(conjunct -> {
                Set<Slot> conjunctSlots = SlotExtractor.extractSlot(conjunct);
                if (groupBySlots.containsAll(conjunctSlots)) {
                    pushDownPredicates.add(conjunct);
                } else {
                    filterPredicates.add(conjunct);
                }
            });

            return pushDownPredicate(filter, aggregate, pushDownPredicates, filterPredicates);
        }).toRule(RuleType.PUSH_DOWN_PREDICATE_THROUGH_AGGREGATION);
    }
Code review comment: I didn't want to break existing code. Also `setValue()` is taking an object.

Code under review:
public CreateProject name(String name) {
        if (name == null || name.isBlank()) {
            return this;
        }
        setValue(PROJECT_NAME, name);
        return this;
    }

Line commented on: setValue(PROJECT_NAME, name);

Revised code:
public CreateProject name(String name) {
        if (name == null || name.isBlank()) {
            return this;
        }
        setValue(PROJECT_NAME, name);
        return this;
    }
Code review comment: Got confused. It should be `remaining` under read mode. Code modified.

Code under review:
private void writeBuffer(ByteBuffer buffer) throws IOException {
        if (null == sendBuffer) {
            return;
        }
        
        if (sendBuffer.remaining() < buffer.position()) {
            
            flush();
        }
        
        if (buffer.position() > sendBuffer.remaining()) {
            realNetSend(buffer);
            return;
        }
        
        sendBuffer.put(buffer);
    }

Line commented on: if (sendBuffer.remaining() < buffer.position()) {

Revised code:
private void writeBuffer(ByteBuffer buffer) throws IOException {
        if (null == sendBuffer) {
            return;
        }
        
        if (sendBuffer.remaining() < buffer.remaining()) {
            
            flush();
        }
        
        if (buffer.remaining() > sendBuffer.remaining()) {
            realNetSend(buffer);
            return;
        }
        
        sendBuffer.put(buffer);
    }
Code review comment: We should verify that it is possible to open a database multiple times.

Code under review:
public CloseSafeDatabase openDatabase(String dbName) {
        return new CloseSafeDatabase(replicatedEnvironment.openDatabase(null, dbName, dbConfig));
    }

Line commented on: return new CloseSafeDatabase(replicatedEnvironment.openDatabase(null, dbName, dbConfig));

Revised code:
public CloseSafeDatabase openDatabase(String dbName) {
        return new CloseSafeDatabase(replicatedEnvironment.openDatabase(null, dbName, dbConfig));
    }
Code review comment: @michalvavrik Oh indeed, I see the Mail client uses the same technique, so it must be good, I'll wait for a bit for Clement to comment and will merge later, thanks

Code under review:
public static Uni<HttpResponse<Buffer>> sendRequest(Vertx vertx, HttpRequest<Buffer> request, boolean blockingDnsLookup) {
        if (blockingDnsLookup) {
            return vertx.executeBlocking(new Callable<Void>() {
                @Override
                public Void call() {
                    try {
                        
                        InetAddress.getByName(request.host());
                    } catch (UnknownHostException e) {
                        throw new RuntimeException(e);
                    }
                    return null;
                }
            }).flatMap(new Function<Void, Uni<? extends HttpResponse<Buffer>>>() {
                @Override
                public Uni<? extends HttpResponse<Buffer>> apply(Void unused) {
                    return request.send();
                }
            });
        } else {
            return request.send();
        }
    }

Line commented on: return vertx.executeBlocking(new Callable<Void>() {

Revised code:
Override
                public Void call() {
                    try {
                        
                        InetAddress.getByName(request.host());
                    } catch (UnknownHostException e) {
                        throw new RuntimeException(e);
                    }
                    return null;
                }
Code review comment: > There's indeed nothing in the spec (to the best of my knowledge) that covers what exactly should happen when looking up `InjectionPoint` when instantiating a non-`@Dependent` synthetic bean bean, but it IMHO follows from the above that it is invalid as well.  And _invalid_ means exactly what? I mean an _invalid_ injection point is a definition error. But for lookup we would have to throw some exception or something like that...

Code under review:
public MyPojo produce(InjectionPoint injectionPoint, Instance<Object> lookup) {
            Field field = ((AnnotatedField<?>) injectionPoint.getAnnotated()).getJavaMember();
            String f = field.getDeclaringClass().getSimpleName() + "." + field.getName();

            
            
            InjectionPoint lookupInjectionPoint = lookup.select(InjectionPoint.class).get();
            AnnotatedParameter<?> parameter = (AnnotatedParameter<?>) lookupInjectionPoint.getAnnotated();
            Executable method = parameter.getJavaParameter().getDeclaringExecutable();
            String m = method.getDeclaringClass().getSimpleName() + "." + method.getName()
                    + "(" + parameter.getPosition() + ")";

            return new MyPojo(f + "|" + m);
        }

Line commented on: InjectionPoint lookupInjectionPoint = lookup.select(InjectionPoint.class).get();

Revised code:
public MyPojo produce(InjectionPoint injectionPoint, Instance<Object> lookup) {
            Field field = ((AnnotatedField<?>) injectionPoint.getAnnotated()).getJavaMember();
            String f = field.getDeclaringClass().getSimpleName() + "." + field.getName();

            
            
            InjectionPoint lookupInjectionPoint = lookup.select(InjectionPoint.class).get();
            AnnotatedParameter<?> parameter = (AnnotatedParameter<?>) lookupInjectionPoint.getAnnotated();
            Executable method = parameter.getJavaParameter().getDeclaringExecutable();
            String m = method.getDeclaringClass().getSimpleName() + "." + method.getName()
                    + "(" + parameter.getPosition() + ")";

            return new MyPojo(f + "|" + m);
        }
Code review comment: Repeat with above. maybe we can add a function in `PrimitiveType ` or this class?

Code under review:
private static boolean checkUserVariableType(Type type) {
        if (type.isArrayType()) {
            ArrayType arrayType = (ArrayType) type;
            PrimitiveType itemPrimitiveType = arrayType.getItemType().getPrimitiveType();
            if (itemPrimitiveType.isDateType() || itemPrimitiveType.isNumericType() ||
                    itemPrimitiveType.isCharFamily() || itemPrimitiveType.isJsonType()) {
                return true;
            }
        } else if (type.isScalarType()) {
            PrimitiveType primitiveType = type.getPrimitiveType();
            if (primitiveType.isDateType() || primitiveType.isNumericType() ||
                    primitiveType.isCharFamily() || primitiveType.isJsonType()) {
                return true;
            }
        }

        return false;
    }

Line commented on: if (primitiveType.isDateType() || primitiveType.isNumericType() ||

Revised code:
private static boolean checkUserVariableType(Type type) {
        if (type.isArrayType()) {
            ArrayType arrayType = (ArrayType) type;
            PrimitiveType itemPrimitiveType = arrayType.getItemType().getPrimitiveType();
            if (itemPrimitiveType.isDateType() || itemPrimitiveType.isNumericType() ||
                    itemPrimitiveType.isCharFamily()) {
                return true;
            }
        } else if (type.isScalarType()) {
            PrimitiveType primitiveType = type.getPrimitiveType();
            if (primitiveType.isDateType() || primitiveType.isNumericType() ||
                    primitiveType.isCharFamily() || primitiveType.isJsonType()) {
                return true;
            }
        }

        return false;
    }
Code review comment: I'm not sure I understand why pdf is special cased?

Code under review:
private ContentHandler createContentHandlerForMetadataOnly(String contentType) {
        if (this.appendEmbeddedContent) {
            return contentType != null && contentType.contains("pdf") ? null : new DefaultHandler();
        } else {
            
            return new RecursiveParserWrapperHandler(
                    new BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE.IGNORE, -1));
        }
    }

Line commented on: return new RecursiveParserWrapperHandler(

Revised code:
private ContentHandler createContentHandlerForMetadataOnly(String contentType) {
        if (this.appendEmbeddedContent) {
            
            return contentType != null && contentType.contains("pdf") ? null : new DefaultHandler();
        } else {
            
            return new RecursiveParserWrapperHandler(
                    new BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE.IGNORE, -1));
        }
    }