muttakin2301/ccr2000 huggingface dataset:
Code review comment: please add a unit test for the change. See `PartitionKeyInternalTest` for existing tests.

Code under review:
public void serialize(PartitionKeyInternal partitionKey, JsonGenerator writer, SerializerProvider serializerProvider) {
            try {
                if (partitionKey.equals(PartitionKeyInternal.getExclusiveMaximum())) {
                    writer.writeString(INFINITY);
                    return;
                }

                
                if (partitionKey.getComponents() != null) {
                    writer.writeStartArray();
                    for (IPartitionKeyComponent componentValue : partitionKey.getComponents()) {
                        componentValue.jsonEncode(writer);
                    }
                    writer.writeEndArray();
                }
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }

Line commented on: writer.writeEndArray();

Revised code:
public void serialize(PartitionKeyInternal partitionKey, JsonGenerator writer, SerializerProvider serializerProvider) {
            try {
                if (partitionKey.equals(PartitionKeyInternal.getExclusiveMaximum())) {
                    writer.writeString(INFINITY);
                    return;
                }

                
                if (partitionKey.getComponents() != null) {
                    writer.writeStartArray();
                    for (IPartitionKeyComponent componentValue : partitionKey.getComponents()) {
                        componentValue.jsonEncode(writer);
                    }
                    writer.writeEndArray();
                }
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
Code review comment: Also an exclusive curator framework per JobMaster will definitely harm the performance and add additional pressure to ZooKeeper.

Code under review:
public void close() throws Exception {
        if (!running) {
            return;
        }

        running = false;

        LOG.info("Closing {}.", this);

        client.getConnectionStateListenable().removeListener(connectionStateListener);

        cache.close();

        try {
            if (client.getZookeeperClient().isConnected()
                    && !connectionInformationPath.contains(RESOURCE_MANAGER_NODE)) {
                client.watchers()
                        .removeAll()
                        .ofType(Watcher.WatcherType.Any)
                        .forPath(connectionInformationPath);
            }
        } catch (KeeperException.NoWatcherException e) {
            
            
        }
    }

Line commented on: && !connectionInformationPath.contains(RESOURCE_MANAGER_NODE)) {

Revised code:
public void close() throws Exception {
        if (!running) {
            return;
        }

        running = false;

        LOG.info("Closing {}.", this);

        client.getConnectionStateListenable().removeListener(connectionStateListener);

        cache.close();

        try {
            if (client.getZookeeperClient().isConnected()
                    && !connectionInformationPath.contains(RESOURCE_MANAGER_NODE)) {
                client.watchers()
                        .removeAll()
                        .ofType(Watcher.WatcherType.Any)
                        .forPath(connectionInformationPath);
            }
        } catch (KeeperException.NoWatcherException e) {
            
            
        }
    }
Code review comment: I think this looks like a bug, why do you increment the counter here?

Code under review:
public boolean triggerCheckpoint(long timestamp, boolean isPeriodic) {
		try {
			triggerCheckpoint(timestamp, checkpointProperties, null, isPeriodic, false);
			return true;
		} catch (CheckpointException e) {
			try {
				long latestGeneratedCheckpointId = getCheckpointIdCounter().getAndIncrement();
				failureManager.handleCheckpointException(e, -1 * latestGeneratedCheckpointId);
			} catch (Exception e1) {
				LOG.warn("Get latest generated checkpoint id error : ", e1);
			}
			return false;
		}
	}

Line commented on: long latestGeneratedCheckpointId = getCheckpointIdCounter().getAndIncrement();

Revised code:
public boolean triggerCheckpoint(long timestamp, boolean isPeriodic) {
		try {
			triggerCheckpoint(timestamp, checkpointProperties, null, isPeriodic, false);
			return true;
		} catch (CheckpointException e) {
			long latestGeneratedCheckpointId = getCheckpointIdCounter().get();
			
			
			failureManager.handleCheckpointException(e, -1 * latestGeneratedCheckpointId);
			return false;
		}
	}
Code review comment: The base class' ChangeFeedStartFromInternal.populatePropertyBag is a no-op as is its baseclass JsonSerializable's populatePropertyBag method.

Code under review:
public void populatePropertyBag() {
        
            super.populatePropertyBag();

        synchronized(this) {
            setProperty(
                this,
                Constants.Properties.CHANGE_FEED_START_FROM_TYPE,
                ChangeFeedStartFromTypes.NOW);
        }
    }

Line commented on: super.populatePropertyBag();

Revised code:
public void populatePropertyBag() {
        
            super.populatePropertyBag();

        synchronized(this) {
            setProperty(
                this,
                Constants.Properties.CHANGE_FEED_START_FROM_TYPE,
                ChangeFeedStartFromTypes.NOW);
        }
    }
Code review comment: please update the `convertToRowData` method based on the values of `remainingPartitions`

Code under review:
public ChangelogMode getChangelogMode(ChangelogMode requestedMode) {
			if (isInsertOnly) {
				return ChangelogMode.insertOnly();
			} else {
				ChangelogMode.Builder builder = ChangelogMode.newBuilder();
				if (schema.getPrimaryKey().isPresent()) {
					
					for (RowKind kind : requestedMode.getContainedKinds()) {
						if (kind != RowKind.UPDATE_BEFORE) {
							builder.addContainedKind(kind);
						}
					}
					return builder.build();
				} else {
					
					return requestedMode;
				}
			}
		}

Line commented on: builder.addContainedKind(kind);

Revised code:
public ChangelogMode getChangelogMode(ChangelogMode requestedMode) {
			if (isInsertOnly) {
				return ChangelogMode.insertOnly();
			} else {
				ChangelogMode.Builder builder = ChangelogMode.newBuilder();
				if (schema.getPrimaryKey().isPresent()) {
					
					for (RowKind kind : requestedMode.getContainedKinds()) {
						if (kind != RowKind.UPDATE_BEFORE) {
							builder.addContainedKind(kind);
						}
					}
					return builder.build();
				} else {
					
					return requestedMode;
				}
			}
		}
Code review comment: In the mv rewrite case, there are only join and scan operator.

Code under review:
private OptExpression pushdownPredicatesForJoin(OptExpression optExpression, ScalarOperator predicate) {
        if (!(optExpression.getOp() instanceof LogicalJoinOperator)) {
            if (predicate != null) {
                
                Operator.Builder builder = OperatorBuilderFactory.build(optExpression.getOp());
                builder.withOperator(optExpression.getOp());
                builder.setPredicate(predicate);
                Operator newQueryOp = builder.build();
                return OptExpression.create(newQueryOp, optExpression.getInputs());
            } else {
                return optExpression;
            }
        }
        OptExpression newJoin = doPushdownPredicate(optExpression, predicate);
        
        List<OptExpression> children = Lists.newArrayList();
        for (int i = 0; i < 2; i++) {
            if (optExpression.inputAt(i).getOp() instanceof LogicalJoinOperator) {
                children.add(pushdownPredicatesForJoin(optExpression.inputAt(i), null));
            } else {
                children.add(optExpression.inputAt(i));
            }
        }
        return OptExpression.create(newJoin.getOp(), children);
    }

Line commented on: if (optExpression.inputAt(i).getOp() instanceof LogicalJoinOperator) {

Revised code:
private OptExpression pushdownPredicatesForJoin(OptExpression optExpression, ScalarOperator predicate) {
        if (!(optExpression.getOp() instanceof LogicalJoinOperator)) {
            if (predicate != null) {
                
                Operator.Builder builder = OperatorBuilderFactory.build(optExpression.getOp());
                builder.withOperator(optExpression.getOp());
                builder.setPredicate(Utils.compoundAnd(predicate, optExpression.getOp().getPredicate()));
                Operator newQueryOp = builder.build();
                return OptExpression.create(newQueryOp, optExpression.getInputs());
            } else {
                return optExpression;
            }
        }
        OptExpression newJoin = doPushdownPredicate(optExpression, predicate);
        
        List<OptExpression> children = Lists.newArrayList();
        for (int i = 0; i < 2; i++) {
            if (optExpression.inputAt(i).getOp() instanceof LogicalJoinOperator) {
                children.add(pushdownPredicatesForJoin(optExpression.inputAt(i), null));
            } else {
                children.add(optExpression.inputAt(i));
            }
        }
        return OptExpression.create(newJoin.getOp(), children);
    }
Code review comment: I think that this implies that we have to take better care of allowed lateness here. Elements that are more late than allowed lateness are dropped by any stateful dofn, this is no new behavior.

Code under review:
private boolean isLate(BoundedWindow window) {
    Instant gcTime = LateDataUtils.garbageCollectionTime(window, windowingStrategy);
    Instant inputWM = stepContext.timerInternals().currentInputWatermarkTime();
    return gcTime.isBefore(inputWM);
  }

Line commented on: return gcTime.isBefore(inputWM);

Revised code:
private boolean isLate(BoundedWindow window) {
    Instant gcTime = LateDataUtils.garbageCollectionTime(window, windowingStrategy);
    Instant inputWM = stepContext.timerInternals().currentInputWatermarkTime();
    return gcTime.isBefore(inputWM);
  }
Code review comment: Since we only create a new strand when we hit a worker or start, enough to check the current parent.

Code under review:
public boolean lockedBySameContext(Strand ctx) {
        return this.current.getLast() == ctx;
    }

Line commented on: return this.current.getLast() == ctx;

Revised code:
public boolean lockedBySameContext(Strand ctx) {
        return this.current.getLast() == ctx;
    }
Code review comment: > It also doesn't really make sense for the maxParallelism to only be settable if it was previously autoConfigured by the system.  👍🏼 I was able to remove the concept of "auto-configured" into SchedulerBase, the only place it makes sense.

Code under review:
public void setMaxParallelism(int maxParallelism) {

        Preconditions.checkState(
                isMaxParallelismAutoConfigured(),
                "Attempt to override a configured max parallelism. Configured: "
                        + this.maxParallelism
                        + ", argument: "
                        + maxParallelism);

        if (maxParallelism == ExecutionConfig.PARALLELISM_AUTO_MAX) {
            maxParallelism = KeyGroupRangeAssignment.UPPER_BOUND_MAX_PARALLELISM;
        }

        Preconditions.checkArgument(
                maxParallelism > 0
                        && maxParallelism <= KeyGroupRangeAssignment.UPPER_BOUND_MAX_PARALLELISM,
                "Overriding max parallelism is not in valid bounds (1..%s), found: %s",
                KeyGroupRangeAssignment.UPPER_BOUND_MAX_PARALLELISM,
                maxParallelism);

        this.maxParallelism = maxParallelism;
    }

Line commented on: isMaxParallelismAutoConfigured(),

Revised code:
public void setMaxParallelism(int maxParallelism) {
        parallelismInfo.setMaxParallelism(maxParallelism);
    }
Code review comment: As before I would create the method `restoreDefaultConfig` and also call it here.

Code under review:
protected void after() {
		try {
			stopFlinkCluster();
		} catch (IOException e) {
			LOG.error("Failure while shutting down Flink cluster.", e);
		}

		final Path originalConfig = conf.resolve(FLINK_CONF_YAML);
		final Path backupConfig = conf.resolve(FLINK_CONF_YAML_BACKUP);

		try {
			Files.move(backupConfig, originalConfig, StandardCopyOption.REPLACE_EXISTING);
		} catch (IOException e) {
			LOG.error("Failed to restore flink-conf.yaml", e);
		}

		for (AutoCloseable fileToDelete : filesToDelete) {
			try {
				fileToDelete.close();
			} catch (Exception e) {
				LOG.error("Failure while cleaning up file.", e);
			}
		}
	}

Line commented on: final Path originalConfig = conf.resolve(FLINK_CONF_YAML);

Revised code:
protected void after() {
		try {
			stopFlinkCluster();
		} catch (IOException e) {
			LOG.error("Failure while shutting down Flink cluster.", e);
		}

		final Path originalConfig = conf.resolve(FLINK_CONF_YAML);
		final Path backupConfig = conf.resolve(FLINK_CONF_YAML_BACKUP);

		try {
			Files.move(backupConfig, originalConfig, StandardCopyOption.REPLACE_EXISTING);
		} catch (IOException e) {
			LOG.error("Failed to restore flink-conf.yaml", e);
		}

		for (AutoCloseable fileToDelete : filesToDelete) {
			try {
				fileToDelete.close();
			} catch (Exception e) {
				LOG.error("Failure while cleaning up file.", e);
			}
		}
	}
Code review comment: Actually, it was wrong. The async connection must happen during the actual subscription and not during the initialization. So during the initialization, the connector should not do anything "network related". The code changed in SmallRye Reactive Messaging.

Code under review:
void onApplicationStart(@Observes StartupEvent event) {
        try {
            mediatorManager.initializeAndRun();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

Line commented on: throw new RuntimeException(e);

Revised code:
void onApplicationStart(@Observes StartupEvent event) {
        try {
            mediatorManager.initializeAndRun();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
Code review comment: Should be better for perf since we don't create new flux every iteration.

Code under review:
public Mono<Void> runAsync() {
        return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
    }

Line commented on: return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();

Revised code:
public Mono<Void> runAsync() {
        return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
    }
Code review comment: @cescoffier thanks for the review.  > Same comments: >  > * how to handle when there are several Pools  In the meantime multiple reactive datasources are not handled, once added we will for sure need to handle them the same way we have handled them for the Agroal connection healthcheck.   > * you need to be sure to not block the IO Thread.  Okay,  are there constructs (a bean that I can inject ) that I can use to check if in IO Thread?  And if in IO Thread case, what should be done?

Code under review:
public HealthCheckResponse call() {
        HealthCheckResponseBuilder builder = HealthCheckResponse.named("Reactive PostgreSQL connection health check").up();

        try {
            CompletableFuture<Void> databaseConnectionAttempt = new CompletableFuture<>();
            pgPool.query("SELECT 1", ar -> {
                if (ar.failed()) {
                    builder.down();
                }
                databaseConnectionAttempt.complete(null);
            });
            databaseConnectionAttempt.join();
        } catch (Exception exception) {
            builder.down();
        }

        return builder.build();
    }

Line commented on: databaseConnectionAttempt.join();

Revised code:
public HealthCheckResponse call() {
        HealthCheckResponseBuilder builder = HealthCheckResponse.named("Reactive PostgreSQL connection health check").up();

        try {
            CompletableFuture<Void> databaseConnectionAttempt = new CompletableFuture<>();
            pgPool.query("SELECT 1")
                    .execute(ar -> {
                        if (ar.failed()) {
                            builder.down();
                        }
                        databaseConnectionAttempt.complete(null);
                    });
            databaseConnectionAttempt.get(10, TimeUnit.SECONDS);
        } catch (Exception exception) {
            builder.down();
        }

        return builder.build();
    }
Code review comment: Noting that the return value is not `@Nullable`. Suggest re-enabling nullness checking here since it would have caught this. (you could perhaps suppress it for other parts of the file you don't want to fix.

Code under review:
public Progress getProgress() {
        if (currentReader == null) {
          return null;
        }
        Double consumedFraction = currentReader.getFractionConsumed();
        if (consumedFraction == null) {
          return null;
        }
        return RestrictionTracker.Progress.from(
            consumedFraction.doubleValue(), 1 - consumedFraction.doubleValue());
      }

Line commented on: return null;

Revised code:
public Progress getProgress() {
        
        if (currentReader == null) {
          return Progress.NONE;
        }
        Double consumedFraction = currentReader.getFractionConsumed();
        if (consumedFraction == null) {
          return Progress.NONE;
        }
        return Progress.from(consumedFraction, 1 - consumedFraction);
      }
Code review comment: Is this ability to add filters documented somewhere?

Code under review:
public void init(@Observes Filters filters) {
        filters.register(rc -> {
            rc.response().putHeader("X-Header", "AAAA");
            rc.next();
        }, 100);
    }

Line commented on: filters.register(rc -> {

Revised code:
public void init(@Observes Filters filters) {
        filters.register(rc -> {
            rc.response().putHeader("X-Header", "AAAA");
            rc.next();
        }, 100);
    }
Code review comment: Do we need to allow this? The debug port won't be reachable in any case.

Code under review:
public void requireThatJvmOptionsAreLogged()  throws IOException, SAXException {
        verifyLoggingOfJvmOptions(true,
                                  "options",
                                  "-Xms2G foo     bar",
                                  "foo", "bar");
        verifyLoggingOfJvmOptions(true,
                                  "options",
                                  "$(touch /tmp/hello-from-gc-options)",
                                  "$(touch", "/tmp/hello-from-gc-options)");

        verifyLoggingOfJvmOptions(false,
                                  "options",
                                  "$(touch /tmp/hello-from-gc-options)",
                                  "$(touch", "/tmp/hello-from-gc-options)");

        
        verifyLoggingOfJvmOptions(true, "options", "-Xms2G");
        verifyLoggingOfJvmOptions(true, "options", "-verbose:gc");
        verifyLoggingOfJvmOptions(true, "options", "-Djava.library.path=/opt/vespa/lib64:/home/y/lib64 -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005");
        verifyLoggingOfJvmOptions(false, "options", "-Xms2G");
    }

Line commented on: verifyLoggingOfJvmOptions(true, "options", "-Djava.library.path=/opt/vespa/lib64:/home/y/lib64 -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005");

Revised code:
public void requireThatJvmOptionsAreLogged()  throws IOException, SAXException {
        verifyLoggingOfJvmOptions(true,
                                  "options",
                                  "-Xms2G foo     bar",
                                  "foo", "bar");
        verifyLoggingOfJvmOptions(true,
                                  "options",
                                  "$(touch /tmp/hello-from-gc-options)",
                                  "$(touch", "/tmp/hello-from-gc-options)");

        verifyLoggingOfJvmOptions(true,
                                  "options",
                                  "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
                                  "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005");

        verifyLoggingOfJvmOptions(false,
                                  "options",
                                  "$(touch /tmp/hello-from-gc-options)",
                                  "$(touch", "/tmp/hello-from-gc-options)");

        
        verifyLoggingOfJvmOptions(true, "options", "-Xms2G");
        verifyLoggingOfJvmOptions(true, "options", "-verbose:gc");
        verifyLoggingOfJvmOptions(true, "options", "-Djava.library.path=/opt/vespa/lib64:/home/y/lib64");
        verifyLoggingOfJvmOptions(false, "options", "-Xms2G");
    }
Code review comment: Sounds like a pragmatic solution to me

Code under review:
private Optional<RunStatus> deployTester(RunId id, DualLogger logger) {
        Version targetPlatform = controller.jobController().run(id).get().versions().targetPlatform();
        
        
        final Version platform = targetPlatform.equals(Version.fromString("7.220.14"))
                ? targetPlatform
                : controller.systemVersion();
        logger.log("Deploying the tester container on platform " + platform + " ...");
        return deploy(id.tester().id(),
                      id.type(),
                      () -> controller.applications().deployTester(id.tester(),
                                                                   testerPackage(id),
                                                                   id.type().zone(controller.system()),
                                                                   platform),
                      controller.jobController().run(id).get()
                                .stepInfo(deployTester).get()
                                .startTime().get(),
                      logger);
    }

Line commented on: final Version platform = targetPlatform.equals(Version.fromString("7.220.14"))

Revised code:
private Optional<RunStatus> deployTester(RunId id, DualLogger logger) {
        Version targetPlatform = controller.jobController().run(id).get().versions().targetPlatform();
        
        
        final Version platform = targetPlatform.equals(Version.fromString("7.220.14"))
                ? targetPlatform
                : controller.systemVersion();
        logger.log("Deploying the tester container on platform " + platform + " ...");
        return deploy(id.tester().id(),
                      id.type(),
                      () -> controller.applications().deployTester(id.tester(),
                                                                   testerPackage(id),
                                                                   id.type().zone(controller.system()),
                                                                   platform),
                      controller.jobController().run(id).get()
                                .stepInfo(deployTester).get()
                                .startTime().get(),
                      logger);
    }
Code review comment: Why sleep here or how can be know how long to sleep?

Code under review:
private TaskDeploymentDescriptor createReceiver(NettyShuffleDescriptor shuffleDescriptor) throws IOException {
		InputGateDeploymentDescriptor inputGateDeploymentDescriptor = new InputGateDeploymentDescriptor(
			new IntermediateDataSetID(),
			ResultPartitionType.PIPELINED,
			0,
			new ShuffleDescriptor[] {shuffleDescriptor});
		return createTestTaskDeploymentDescriptor(
			"Receiver",
			new ExecutionAttemptID(),
			TestingAbstractInvokables.Receiver.class,
			1,
			Collections.emptyList(),
			Collections.singletonList(inputGateDeploymentDescriptor));
	}

Line commented on: ResultPartitionType.PIPELINED,

Revised code:
private TaskDeploymentDescriptor createReceiver(NettyShuffleDescriptor shuffleDescriptor) throws IOException {
		InputGateDeploymentDescriptor inputGateDeploymentDescriptor = new InputGateDeploymentDescriptor(
			new IntermediateDataSetID(),
			ResultPartitionType.PIPELINED,
			0,
			new ShuffleDescriptor[] {shuffleDescriptor});
		return createTestTaskDeploymentDescriptor(
			"Receiver",
			new ExecutionAttemptID(),
			TestingAbstractInvokables.Receiver.class,
			1,
			Collections.emptyList(),
			Collections.singletonList(inputGateDeploymentDescriptor));
	}
Code review comment: Removes the use of a Supplier function to store the TableSchema and simply uses a class property to hold the TableSchema.

Code under review:
public T read(T reuse, Decoder in) throws IOException {
      GenericRecord record = (GenericRecord) this.reader.read(reuse, in);
      return parseFn.apply(new SchemaAndRecord(record, this.tableSchema));
    }

Line commented on: return parseFn.apply(new SchemaAndRecord(record, this.tableSchema));

Revised code:
public T read(T reuse, Decoder in) throws IOException {
      GenericRecord record = (GenericRecord) this.reader.read(reuse, in);
      return parseFn.apply(new SchemaAndRecord(record, this.tableSchema));
    }
Code review comment: I didn't get it... for the case of one array `arrays.length == 1` and it will not enter this `if`. Also having just one array is ok, in that case we can just return it back.  Why are we talking about `"need at least two arrays"` ?

Code under review:
private InType[] convertToArrays(InType[] arrays) {
        if (arrays == null || arrays.length < 1) {
            throw new ValidationException("need at least two arrays");
        }
        int numberOfNull = 0;
        InType notNullArray = null;
        for (int i = 0; i < arrays.length; ++i) {
            if (arrays[i] == null) {
                numberOfNull++;
            } else {
                notNullArray = arrays[i];
            }
        }
        if (numberOfNull == arrays.length) {
            return (InType[]) new Object[] {arrays};
        }
        if (!(notNullArray instanceof Object[])) {
            return (InType[]) new Object[] {arrays};
        } else {
            return arrays;
        }
    }

Line commented on: throw new ValidationException("need at least two arrays");

Revised code:
private InType[] convertToArrays(InType[] arrays) {
        if (arrays == null || arrays.length == 0) {
            return arrays;
        }
        InType notNullArray = null;
        for (int i = 0; i < arrays.length; ++i) {
            if (arrays[i] != null) {
                notNullArray = arrays[i];
            }
        }
        if (!(notNullArray instanceof Object[])) {
            return (InType[]) new Object[] {arrays};
        } else {
            return arrays;
        }
    }
Code review comment: Also make sure to rename the `Build` variable to `build` to follow the Java coding guidelines for variables :wink:

Code under review:
public void testAddAndRemoveExtension() throws IOException, URISyntaxException, InterruptedException {

        final File projectDir = getProjectDir("add-remove-extension-single-module");

        runGradleWrapper(projectDir, ":addExtension", "--extensions=hibernate-orm");

        final Path Build = projectDir.toPath().resolve("build.gradle");
        assertThat(Build).exists();
        assertThat(Files.readString(Build)).contains("implementation 'io.quarkus:quarkus-hibernate-orm'");

        runGradleWrapper(projectDir, ":removeExtension", "--extensions=hibernate-orm");
        assertThat(Files.readString(Build)).doesNotContain("implementation 'io.quarkus:quarkus-hibernate-orm'");

    }

Line commented on: assertThat(Files.readString(Build)).contains("implementation 'io.quarkus:quarkus-hibernate-orm'");

Revised code:
public void testAddAndRemoveExtension() throws IOException, URISyntaxException, InterruptedException {

        final File projectDir = getProjectDir("add-remove-extension-single-module");

        runGradleWrapper(projectDir, ":addExtension", "--extensions=hibernate-orm");

        final Path build = projectDir.toPath().resolve("build.gradle");
        assertThat(build).exists();
        assertThat(new String(Files.readAllBytes(build))).contains("implementation 'io.quarkus:quarkus-hibernate-orm'");

        runGradleWrapper(projectDir, ":removeExtension", "--extensions=hibernate-orm");
        assertThat(new String(Files.readAllBytes(build))).doesNotContain("implementation 'io.quarkus:quarkus-hibernate-orm'");

    }
Code review comment: Actually, that's not the same thing due to the behavior of `NodeFilter#nextMatches`.  Your suggestion would be fine if `NodeFilter#nextMatches` method didn't return `true` for the last filter in the chain. I think the intention is that filters should match a given node if no filters in the chain actively reject it (a bit strange, but other code depends on this behavior).

Code under review:
public boolean matches(Node node) {
        if (!version.isEmpty() && !node.status().osVersion().filter(v -> v.equals(version)).isPresent()) {
            return false;
        }
        return nextMatches(node);
    }

Line commented on: if (!version.isEmpty() && !node.status().osVersion().filter(v -> v.equals(version)).isPresent()) {

Revised code:
public boolean matches(Node node) {
        if (!version.isEmpty() && !node.status().osVersion().filter(v -> v.equals(version)).isPresent()) {
            return false;
        }
        return nextMatches(node);
    }
Code review comment: @srnagar `String eventHubName()` is not renamed.

Code under review:
private static String getExpression(EventPosition eventPosition) {
        final String isInclusiveFlag = eventPosition.isInclusive() ? "=" : "";

        
        if (eventPosition.getOffset() != null) {
            return String.format(
                AmqpConstants.AMQP_ANNOTATION_FORMAT, OFFSET_ANNOTATION_NAME.getValue(),
                isInclusiveFlag,
                eventPosition.getOffset());
        }

        if (eventPosition.getSequenceNumber() != null) {
            return String.format(
                AmqpConstants.AMQP_ANNOTATION_FORMAT,
                SEQUENCE_NUMBER_ANNOTATION_NAME.getValue(),
                isInclusiveFlag,
                eventPosition.getSequenceNumber());
        }

        if (eventPosition.getEnqueuedDateTime() != null) {
            String ms;
            try {
                ms = Long.toString(eventPosition.getEnqueuedDateTime().toEpochMilli());
            } catch (ArithmeticException ex) {
                ms = Long.toString(Long.MAX_VALUE);
            }

            return String.format(
                AmqpConstants.AMQP_ANNOTATION_FORMAT,
                ENQUEUED_TIME_UTC_ANNOTATION_NAME.getValue(),
                isInclusiveFlag,
                ms);
        }

        throw new IllegalArgumentException("No starting position was set.");
    }

Line commented on: ms = Long.toString(Long.MAX_VALUE);

Revised code:
private static String getExpression(EventPosition eventPosition) {
        final String isInclusiveFlag = eventPosition.isInclusive() ? "=" : "";

        
        if (eventPosition.getOffset() != null) {
            return String.format(
                AmqpConstants.AMQP_ANNOTATION_FORMAT, OFFSET_ANNOTATION_NAME.getValue(),
                isInclusiveFlag,
                eventPosition.getOffset());
        }

        if (eventPosition.getSequenceNumber() != null) {
            return String.format(
                AmqpConstants.AMQP_ANNOTATION_FORMAT,
                SEQUENCE_NUMBER_ANNOTATION_NAME.getValue(),
                isInclusiveFlag,
                eventPosition.getSequenceNumber());
        }

        if (eventPosition.getEnqueuedDateTime() != null) {
            String ms;
            try {
                ms = Long.toString(eventPosition.getEnqueuedDateTime().toEpochMilli());
            } catch (ArithmeticException ex) {
                ms = Long.toString(Long.MAX_VALUE);
            }

            return String.format(
                AmqpConstants.AMQP_ANNOTATION_FORMAT,
                ENQUEUED_TIME_UTC_ANNOTATION_NAME.getValue(),
                isInclusiveFlag,
                ms);
        }

        throw new IllegalArgumentException("No starting position was set.");
    }
Code review comment: Why do you close again if the session is already closed? Shouldn't the condition be negation?

Code under review:
public static void closeIfAnonymousSession(BMap<String, BValue> obj) throws ActiveMQException {
        boolean anonymousSession = ((BBoolean) obj.get("anonymousSession")).booleanValue();
        if (anonymousSession) {
            ClientSession session = ArtemisUtils.getClientSessionFromBMap(obj);
            if (session.isClosed()) {
                session.close();
            }
        }
    }

Line commented on: if (session.isClosed()) {

Revised code:
public static void closeIfAnonymousSession(BMap<String, BValue> obj) throws ActiveMQException {
        boolean anonymousSession = ((BBoolean) obj.get("anonymousSession")).booleanValue();
        if (anonymousSession) {
            ClientSession session = ArtemisUtils.getClientSessionFromBMap(obj);
            if (!session.isClosed()) {
                session.close();
            }
        }
    }
Code review comment: Please remove this useless blank line.

Code under review:
public void assertNewInstanceForSQLServer() {
        
        SQLStatement statement = new SQLServerDropSchemaStatement();
        Optional<SingleTableMetadataValidator> actual = SingleTableMetadataValidatorFactory.newInstance(statement);
        assertTrue(actual.isPresent());
        
    }


Revised code:
public void assertNewInstanceForSQLServer() {
        SQLStatement statement = new SQLServerDropSchemaStatement();
        Optional<SingleTableMetadataValidator> actual = SingleTableMetadataValidatorFactory.newInstance(statement);
        assertTrue(actual.isPresent());
    }
Code review comment: Do we need a separate param for useSeparateMetadataDb? We could just check if (isRbac) here. Right?

Code under review:
protected void before() throws Throwable {
    final ChangeStreamTestPipelineOptions options =
        IOITHelper.readIOTestPipelineOptions(ChangeStreamTestPipelineOptions.class);

    projectId =
        Optional.ofNullable(options.getProjectId())
            .orElseGet(() -> options.as(GcpOptions.class).getProject());
    instanceId = options.getInstanceId();
    generateDatabaseIds(options);
    spanner =
        SpannerOptions.newBuilder().setProjectId(projectId).setHost(host).build().getService();
    databaseAdminClient = spanner.getDatabaseAdminClient();
    metadataTableName = generateTableName(METADATA_TABLE_NAME_PREFIX);

    databases = new ArrayList<>();
    recreateDatabase(databaseAdminClient, instanceId, databaseId, isPostgres);
    databaseClient = spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));
    databases.add(databaseId);

    if (createRbacDatabase) {
      recreateDatabase(databaseAdminClient, instanceId, rbacDatabaseId, isPostgres);
      rbacDatabaseClient =
          spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, rbacDatabaseId));
      databases.add(rbacDatabaseId);
    }
    if (useSeparateMetadataDb) {
      recreateDatabase(databaseAdminClient, instanceId, metadataDatabaseId, isPostgres);
    }

    changeStreams = new ArrayList<>();
    tables = new ArrayList<>();
  }

Line commented on: if (useSeparateMetadataDb) {

Revised code:
protected void before() throws Throwable {
    final ChangeStreamTestPipelineOptions options =
        IOITHelper.readIOTestPipelineOptions(ChangeStreamTestPipelineOptions.class);

    projectId =
        Optional.ofNullable(options.getProjectId())
            .orElseGet(() -> options.as(GcpOptions.class).getProject());
    instanceId = options.getInstanceId();
    generateDatabaseIds(options);
    spanner =
        SpannerOptions.newBuilder().setProjectId(projectId).setHost(host).build().getService();
    databaseAdminClient = spanner.getDatabaseAdminClient();
    metadataTableName = generateTableName(METADATA_TABLE_NAME_PREFIX);

    recreateDatabase(databaseAdminClient, instanceId, databaseId, isPostgres);
    databaseClient = spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));

    changeStreams = new ArrayList<>();
    tables = new ArrayList<>();
  }
Code review comment: Probably not because for `Cache#get()` we only wrap the checked exceptions.

Code under review:
public CompletableFuture<Object> apply(Object key) {
                        return (CompletableFuture<Object>) valueLoader.apply((K) key)
                                .map(i -> NullValueConverter.toCacheValue(i))
                                .subscribeAsCompletionStage();
                    }

Line commented on: return (CompletableFuture<Object>) valueLoader.apply((K) key)

Revised code:
public CompletableFuture<Object> apply(Object key) {
                        return valueLoader.apply((K) key)
                                .map(TO_CACHE_VALUE)
                                .subscribeAsCompletionStage();
                    }
Code review comment: not really, the destination is an address. It can be seen as a _classic_ queue or topic depending on the method used (send / request vs. publish)

Code under review:
protected String destinationKind(final Message message) {
            return "topic";
        }

Line commented on: return "topic";

Revised code:
protected String destinationKind(final Message message) {
            return message.isSend() ? "queue" : "topic";
        }
Code review comment: @pedroigor @boosey Hi. I think there should be some code followed by a custom header indicating it is to do with the XHR. Otherwise SPA will try to reload even if it is a genuine `401` (whenever we decide to return `401`, example, we return `401` in case the code flow fails to complete).  To be honest I'm not sure it should be `401`. At the quarkus OIDC level  we want to redirect, right ? But such that if it is XHR and the option is set, then let XHR fail. Can we set `399`, at least it in the `3xx` redirect space ? That would also fit better with the fact we throw `AuthenticationRedirectException`  But in any case, it should be accompanied by something like `XHR-Location: redirect_uri...` or something simpler. This can be done by adding a custom header to the response context and then throwing `AuthenticationRedirectException`

Code under review:
public AuthenticationRedirectException(Boolean autoRedirect, String redirectUri) {
        this(autoRedirect ? 302 : 444, redirectUri);
    }

Line commented on: this(autoRedirect ? 302 : 444, redirectUri);

Revised code:
public AuthenticationRedirectException(Boolean autoRedirect, String redirectUri) {
        this(autoRedirect ? 302 : 444, redirectUri);
    }
Code review comment: @challengeof Can we rename `c` to `firstChar`? And put constant on the left condition?

Code under review:
private static Object convertBooleanValue(final Object value) {
        if (value instanceof Boolean) {
            return value;
        }
        String stringVal = value.toString();
        if (stringVal.length() > 0) {
            int c = Character.toLowerCase(stringVal.charAt(0));
            return c == 't' || c == 'y' || c == '1' || "-1".equals(stringVal);
        } else {
            return false;
        }
    }

Line commented on: return c == 't' || c == 'y' || c == '1' || "-1".equals(stringVal);

Revised code:
private static Object convertBooleanValue(final Object value) {
        if (value instanceof Boolean) {
            return value;
        }
        String stringVal = value.toString();
        if (stringVal.length() > 0) {
            int firstChar = Character.toLowerCase(stringVal.charAt(0));
            return 't' == firstChar || 'y' == firstChar || '1' == firstChar || "-1".equals(stringVal);
        } else {
            return false;
        }
    }
Code review comment: Can this method call the method on L204

Code under review:
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) {
        return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context));
    }

Line commented on: return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context));

Revised code:
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) {
        return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context));
    }
Code review comment: Should we use `@RepeatedTest(100)` instead?

Code under review:
void testPost() {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < 100; ++i) {
            
            
            
            given()
                    .header("Authorization", "Basic am9objpqb2hu")
                    .body("Bill")
                    .contentType(ContentType.TEXT)
                    .when()
                    .post("/foo/")
                    .then()
                    .statusCode(200)
                    .body(is("hello Bill"));
        }
    }


Revised code:
void testPost() {
        
        
        
        given()
                .header("Authorization", "Basic am9objpqb2hu")
                .body("Bill")
                .contentType(ContentType.TEXT)
                .when()
                .post("/foo/")
                .then()
                .statusCode(200)
                .body(is("hello Bill"));
    }
Code review comment: Please use `null == name` and `0 == name.length()`

Code under review:
public ShardingSphereSavepoint(final String name) throws SQLException {
        if (name == null || name.length() == 0) {
            throw new SQLException("Savepoint name can not be NULL or empty");
        }
        this.savepointName = name;
    }

Line commented on: if (name == null || name.length() == 0) {

Revised code:
public ShardingSphereSavepoint(final String name) throws SQLException {
        if (null == name || 0 == name.length()) {
            throw new SQLException("Savepoint name can not be NULL or empty");
        }
        savepointName = name;
    }
Code review comment: De-serialization of polymorphic types are handled using Jackson annotations. See this models https://github.com/Azure/azure-sdk-for-java/blob/e6771250bb50c5b38a301afed06afb88c6737a08/eventgrid/data-plane/src/test/java/com/microsoft/azure/eventgrid/customization/models/ShippingInfo.java#L15

Code under review:
public EventGridSubscriber() {
        this.defaultSerializerAdapter = new AzureJacksonAdapter();
        this.eventTypeToEventDataMapping =  new HashMap<>();
    }

Line commented on: this.defaultSerializerAdapter = new AzureJacksonAdapter();

Revised code:
public EventGridSubscriber() {
        this.defaultSerializerAdapter = new AzureJacksonAdapter();
        this.eventTypeToEventDataMapping =  new HashMap<>();
    }
Code review comment: Isn't this null check redundant? There's already one in https://github.com/ballerina-platform/ballerina-lang/pull/36837/files#diff-abafd09e4c17786eb7b550f8eccbeb794ce71bff4e383bdaa9b7ecf203b169aeR1318

Code under review:
public void visit(BLangWorkerFlushExpr workerFlushExpr) {
        
        
        if (workerFlushExpr.workerSymbol == null) {
            return;
        }
        addIfSameSymbol(workerFlushExpr.workerSymbol, workerFlushExpr.workerIdentifier.pos);
    }

Line commented on: if (workerFlushExpr.workerSymbol == null) {

Revised code:
public void visit(BLangWorkerFlushExpr workerFlushExpr) {
        
        
        if (workerFlushExpr.workerIdentifier == null) {
            return;
        }
        addIfSameSymbol(workerFlushExpr.workerSymbol, workerFlushExpr.workerIdentifier.pos);
    }
Code review comment: Ok,  never mind.  I was thinking to avoid copying in and copying out of `memo` multiple times. Let's refactor this when we have more similar cases in the future.

Code under review:
private Memo rewrite(Plan plan) {
        Plan normalizedPlan = PlanRewriter.topDownRewrite(plan, new ConnectContext(), new NormalizeExpressions());
        return PlanRewriter.topDownRewriteMemo(normalizedPlan, new ConnectContext(), new PushPredicateThroughJoin());
    }

Line commented on: Plan normalizedPlan = PlanRewriter.topDownRewrite(plan, new ConnectContext(), new NormalizeExpressions());

Revised code:
private Memo rewrite(Plan plan) {
        Plan normalizedPlan = PlanRewriter.topDownRewrite(plan, new ConnectContext(), new ExpressionNormalization());
        return PlanRewriter.topDownRewriteMemo(normalizedPlan, new ConnectContext(), new PushPredicateThroughJoin());
    }
Code review comment: shoudl we count to show on status page?

Code under review:
private boolean addCommitToStream(Commit commit, CommitWorkStream commitStream) {
    Preconditions.checkNotNull(commit);
    
    if (commit.work().isFailed()) {
      return true;
    }
    final ComputationState state = commit.computationState();
    final Windmill.WorkItemCommitRequest request = commit.request();
    final int size = commit.getSize();
    commit.work().setState(Work.State.COMMITTING);
    activeCommitBytes.addAndGet(size);
    if (commitStream.commitWorkItem(
        state.getComputationId(),
        request,
        (Windmill.CommitStatus status) -> {
          if (status != Windmill.CommitStatus.OK) {
            readerCache.invalidateReader(
                WindmillComputationKey.create(
                    state.getComputationId(), request.getKey(), request.getShardingKey()));
            stateCache
                .forComputation(state.getComputationId())
                .invalidate(request.getKey(), request.getShardingKey());
          }
          activeCommitBytes.addAndGet(-size);
          
          
          state.completeWorkAndScheduleNextWorkForKey(
              ShardedKey.create(request.getKey(), request.getShardingKey()),
              request.getWorkToken());
        })) {
      return true;
    } else {
      
      commit.work().setState(Work.State.COMMIT_QUEUED);
      activeCommitBytes.addAndGet(-size);
      return false;
    }
  }

Line commented on: return true;

Revised code:
private boolean addCommitToStream(Commit commit, CommitWorkStream commitStream) {
    Preconditions.checkNotNull(commit);
    
    if (commit.work().isFailed()) {
      return true;
    }
    final ComputationState state = commit.computationState();
    final Windmill.WorkItemCommitRequest request = commit.request();
    final int size = commit.getSize();
    commit.work().setState(Work.State.COMMITTING);
    activeCommitBytes.addAndGet(size);
    if (commitStream.commitWorkItem(
        state.getComputationId(),
        request,
        (Windmill.CommitStatus status) -> {
          if (status != Windmill.CommitStatus.OK) {
            readerCache.invalidateReader(
                WindmillComputationKey.create(
                    state.getComputationId(), request.getKey(), request.getShardingKey()));
            stateCache
                .forComputation(state.getComputationId())
                .invalidate(request.getKey(), request.getShardingKey());
          }
          activeCommitBytes.addAndGet(-size);
          
          
          state.completeWorkAndScheduleNextWorkForKey(
              ShardedKey.create(request.getKey(), request.getShardingKey()),
              request.getWorkToken());
        })) {
      return true;
    } else {
      
      commit.work().setState(Work.State.COMMIT_QUEUED);
      activeCommitBytes.addAndGet(-size);
      return false;
    }
  }