muttakin2301/ccr2000 huggingface dataset:
Code review comment: Thanks @xstefank - I'll add those. W.r.t experimental paths, I am easy, I do not really have an opinion on that. Maybe @knutwannheden can comment here as this is requested by him.

Code under review:
private APIResponses createAPIResponses() {
        APIResponses responses = new APIResponsesImpl();
        responses.addAPIResponse("200", createAPIResponse());
        return responses;
    }

Line commented on: responses.addAPIResponse("200", createAPIResponse());

Revised code:
private APIResponses createAPIResponses() {
        APIResponses responses = new APIResponsesImpl();
        responses.addAPIResponse("200", createAPIResponse());
        responses.addAPIResponse("503", createAPIResponse());
        responses.addAPIResponse("500", createAPIResponse());
        return responses;
    }
Code review comment: Something we should report, and not only in gRPC is when @Blocking and @NonBlocking are used at the same time on the same element. It's clearly illegal, and should be reported properly.  CC @geoand

Code under review:
private Set<MethodInfo> gatherBlockingMethods(ClassInfo service) {
        Set<MethodInfo> result = new HashSet<>();
        
        boolean blockingClass = service.classAnnotation(BLOCKING) != null
                || (service.classAnnotation(TRANSACTIONAL) != null &&
                        service.classAnnotation(NON_BLOCKING) == null);
        for (MethodInfo method : service.methods()) {
            if (BLOCKING_SKIPPED_METHODS.contains(method.name())) {
                continue;
            }
            if ((method.hasAnnotation(BLOCKING) || (method.hasAnnotation(TRANSACTIONAL) && !method.hasAnnotation(NON_BLOCKING)))
                    || (blockingClass && !method.hasAnnotation(NON_BLOCKING))) {
                result.add(method);
            }
        }
        return result;
    }

Line commented on: service.classAnnotation(NON_BLOCKING) == null);

Revised code:
private Set<MethodInfo> gatherBlockingMethods(ClassInfo service) {
        Set<MethodInfo> result = new HashSet<>();
        boolean blockingClass = service.classAnnotation(GrpcDotNames.BLOCKING) != null;
        if (blockingClass && service.classAnnotation(GrpcDotNames.NON_BLOCKING) != null) {
            throw new DeploymentException("Class '" + service.name()
                    + "' contains both @Blocking and @NonBlocking annotations.");
        }
        
        blockingClass |= service.classAnnotation(TRANSACTIONAL) != null &&
                service.classAnnotation(NON_BLOCKING) == null;

        for (MethodInfo method : service.methods()) {
            if (BLOCKING_SKIPPED_METHODS.contains(method.name())) {
                continue;
            }

            if (method.hasAnnotation(BLOCKING)) {
                if (method.hasAnnotation(NON_BLOCKING)) {
                    throw new DeploymentException("Method '" + method.declaringClass().name() + "
                            "' contains both @Blocking and @NonBlocking annotations.");
                } else {
                    result.add(method);
                }
            } else if ((method.hasAnnotation(TRANSACTIONAL) || blockingClass) && !method.hasAnnotation(NON_BLOCKING)) {
                result.add(method);
            }
        }
        return result;
    }
Code review comment: Fair point. It is true that accepting this default is what hurt one the customer who filed the issue and why we're making this change. But that also seems like a fairly rare case so far? And I'm not sure what a more idiomatic value for Storage would be. It feels like anything we choose would just be a guess.

Code under review:
public static ParallelTransferOptions populateAndApplyDefaults(ParallelTransferOptions other) {
        other = other == null ? new ParallelTransferOptions(null, null, null, null) : other;

        
        if (other.getBlockSize() != null) {
            StorageImplUtils.assertInBounds("ParallelTransferOptions.blockSize", other.getBlockSize(), 1,
                MAX_APPEND_FILE_BYTES);
        }

        if (other.getMaxSingleUploadSize() != null) {
            StorageImplUtils.assertInBounds("ParallelTransferOptions.maxSingleUploadSize",
                other.getMaxSingleUploadSize(), 1, MAX_APPEND_FILE_BYTES);
        }

        return new ParallelTransferOptions(
            other.getBlockSize() == null ? Integer.valueOf(FILE_DEFAULT_UPLOAD_BLOCK_SIZE)
                : other.getBlockSize(),
            other.getNumBuffers() == null ? Integer.valueOf(FILE_DEFAULT_NUMBER_OF_BUFFERS)
                : other.getNumBuffers(),
            other.getProgressReceiver(),
            other.getMaxSingleUploadSize() == null ? Integer.valueOf(MAX_APPEND_FILE_BYTES)
                : other.getMaxSingleUploadSize(),
            
            other.getMaxConcurrency() == null ? Integer.valueOf(Queues.SMALL_BUFFER_SIZE) : other.getMaxConcurrency());
    }

Line commented on: other.getMaxConcurrency() == null ? Integer.valueOf(Queues.SMALL_BUFFER_SIZE) : other.getMaxConcurrency());

Revised code:
public static ParallelTransferOptions populateAndApplyDefaults(ParallelTransferOptions other) {
        other = other == null ? new ParallelTransferOptions(null, null, null, null) : other;

        
        if (other.getBlockSize() != null) {
            StorageImplUtils.assertInBounds("ParallelTransferOptions.blockSize", other.getBlockSize(), 1,
                MAX_APPEND_FILE_BYTES);
        }

        if (other.getMaxSingleUploadSize() != null) {
            StorageImplUtils.assertInBounds("ParallelTransferOptions.maxSingleUploadSize",
                other.getMaxSingleUploadSize(), 1, MAX_APPEND_FILE_BYTES);
        }

        return new ParallelTransferOptions(
            other.getBlockSize() == null ? Integer.valueOf(FILE_DEFAULT_UPLOAD_BLOCK_SIZE)
                : other.getBlockSize(),
            other.getMaxConcurrency() == null ? Integer.valueOf(FILE_DEFAULT_NUMBER_OF_BUFFERS)
                : other.getMaxConcurrency(),
            other.getProgressReceiver(),
            other.getMaxSingleUploadSize() == null ? Integer.valueOf(MAX_APPEND_FILE_BYTES)
                : other.getMaxSingleUploadSize());
    }
Code review comment: Yeah, so this was the only place where there's no `CreationalContext`. Fortunately, all the methods obtain the `InjectionPoint` as their first (and only) parameter, so it's alright, we can just lookup the parameter from the `InvocationContext`. If we cannot do that, we cannot remove the thread-local, which would be unfortunate.  This interceptor only intercepts the `@Produces @ConfigProperty` methods  on `io.smallrye.config.inject.ConfigProducer`, which looks like a fairly niche use case and shouldn't really affect anyone IMHO.

Code under review:
Object aroundInvoke(InvocationContext context) throws Exception {
        InjectionPoint injectionPoint = (InjectionPoint) context.getParameters()[0];
        recordConfigValue(injectionPoint, configValues);
        return context.proceed();
    }

Line commented on: InjectionPoint injectionPoint = (InjectionPoint) context.getParameters()[0];

Revised code:
Object aroundInvoke(InvocationContext context) throws Exception {
        InjectionPoint injectionPoint = null;
        for (Object parameter : context.getParameters()) {
            if (parameter instanceof InjectionPoint) {
                injectionPoint = (InjectionPoint) parameter;
                break;
            }
        }
        recordConfigValue(injectionPoint, configValues);
        return context.proceed();
    }
Code review comment: nitpick: We could maybe have an import of `DOTNAME_OBJECT ` and avoid this long line

Code under review:
private void extractMappings(Map<String, String> classPropertyMapping, ClassInfo target, CombinedIndexBuildItem index) {
        for (FieldInfo fieldInfo : target.fields()) {
            if (fieldInfo.hasAnnotation(DOTNAME_BSON_PROPERTY)) {
                AnnotationInstance bsonProperty = fieldInfo.annotation(DOTNAME_BSON_PROPERTY);
                classPropertyMapping.put(fieldInfo.name(), bsonProperty.value().asString());
            }
        }
        for (MethodInfo methodInfo : target.methods()) {
            if (methodInfo.hasAnnotation(DOTNAME_BSON_PROPERTY)) {
                AnnotationInstance bsonProperty = methodInfo.annotation(DOTNAME_BSON_PROPERTY);
                classPropertyMapping.put(methodInfo.name(), bsonProperty.value().asString());
            }
        }

        
        if (!target.superClassType().name().equals(io.quarkus.panache.common.deployment.JandexUtil.DOTNAME_OBJECT)) {
            Type superType = target.superClassType();
            ClassInfo superClass = index.getIndex().getClassByName(superType.name());
            extractMappings(classPropertyMapping, superClass, index);
        }
    }

Line commented on: if (!target.superClassType().name().equals(io.quarkus.panache.common.deployment.JandexUtil.DOTNAME_OBJECT)) {

Revised code:
private void extractMappings(Map<String, String> classPropertyMapping, ClassInfo target, CombinedIndexBuildItem index) {
        for (FieldInfo fieldInfo : target.fields()) {
            if (fieldInfo.hasAnnotation(DOTNAME_BSON_PROPERTY)) {
                AnnotationInstance bsonProperty = fieldInfo.annotation(DOTNAME_BSON_PROPERTY);
                classPropertyMapping.put(fieldInfo.name(), bsonProperty.value().asString());
            }
        }
        for (MethodInfo methodInfo : target.methods()) {
            if (methodInfo.hasAnnotation(DOTNAME_BSON_PROPERTY)) {
                AnnotationInstance bsonProperty = methodInfo.annotation(DOTNAME_BSON_PROPERTY);
                classPropertyMapping.put(methodInfo.name(), bsonProperty.value().asString());
            }
        }

        
        if (!target.superClassType().name().equals(io.quarkus.panache.common.deployment.JandexUtil.DOTNAME_OBJECT)) {
            Type superType = target.superClassType();
            ClassInfo superClass = index.getIndex().getClassByName(superType.name());
            extractMappings(classPropertyMapping, superClass, index);
        }
    }
Code review comment: retryPolicy cannot be null , it get created during client init. If this is null nothing will work for the request

Code under review:
public RetryContext getRetryContext() {
        return retryPolicy.getRetryContext();
    }

Line commented on: return retryPolicy.getRetryContext();

Revised code:
public RetryContext getRetryContext() {
        if (this.retryPolicy != null) {
            return this.retryPolicy.getRetryContext();
        } else {
            return null;
        }
    }
Code review comment: Fixed by returning an empty Variable[].

Code under review:
protected Variable[] fetchDebugHitVariables(StoppedEventArguments args) throws BallerinaTestException {
        if (!DebugHitListener.connector.isConnected()) {
            return null;
        }
        StackTraceArguments stackTraceArgs = new StackTraceArguments();
        VariablesArguments variableArgs = new VariablesArguments();
        ScopesArguments scopeArgs = new ScopesArguments();
        stackTraceArgs.setThreadId(args.getThreadId());

        try {
            StackTraceResponse stackTraceResp = DebugHitListener.connector.getRequestManager().stackTrace(stackTraceArgs);
            StackFrame[] stackFrames = stackTraceResp.getStackFrames();
            if (stackFrames.length == 0) {
                return null;
            }

            scopeArgs.setFrameId(stackFrames[0].getId());
            ScopesResponse scopesResp = DebugHitListener.connector.getRequestManager().scopes(scopeArgs);
            variableArgs.setVariablesReference(scopesResp.getScopes()[0].getVariablesReference());
            VariablesResponse variableResp = DebugHitListener.connector.getRequestManager().variables(variableArgs);
            return variableResp.getVariables();

        } catch (Exception e) {
            LOGGER.warn("Error occurred when fetching debug hit variables", e);
            throw new BallerinaTestException("Error occurred when fetching debug hit variables", e);
        }
    }

Line commented on: return null;

Revised code:
protected Variable[] fetchDebugHitVariables(StoppedEventArguments args) throws BallerinaTestException {
        if (!DebugHitListener.connector.isConnected()) {
            return new Variable[0];
        }
        StackTraceArguments stackTraceArgs = new StackTraceArguments();
        VariablesArguments variableArgs = new VariablesArguments();
        ScopesArguments scopeArgs = new ScopesArguments();
        stackTraceArgs.setThreadId(args.getThreadId());

        try {
            StackTraceResponse stackTraceResp = DebugHitListener.connector.getRequestManager()
                    .stackTrace(stackTraceArgs);
            StackFrame[] stackFrames = stackTraceResp.getStackFrames();
            if (stackFrames.length == 0) {
                return new Variable[0];
            }

            scopeArgs.setFrameId(stackFrames[0].getId());
            ScopesResponse scopesResp = DebugHitListener.connector.getRequestManager().scopes(scopeArgs);
            variableArgs.setVariablesReference(scopesResp.getScopes()[0].getVariablesReference());
            VariablesResponse variableResp = DebugHitListener.connector.getRequestManager().variables(variableArgs);
            return variableResp.getVariables();

        } catch (Exception e) {
            LOGGER.warn("Error occurred when fetching debug hit variables", e);
            throw new BallerinaTestException("Error occurred when fetching debug hit variables", e);
        }
    }
Code review comment: Here we should extract the bootstrap server. (I'm assuming now that the external resources are running or we can easily force it while calling this factory)

Code under review:
public ExternalContext<String> createExternalContext() {
            return new KafkaMultipleTopicExternalContext(bootstrapServers);
        }

Line commented on: return new KafkaMultipleTopicExternalContext(bootstrapServers);

Revised code:
public ExternalContext<String> createExternalContext() {
            return new KafkaMultipleTopicExternalContext(getBootstrapServer());
        }
Code review comment: Add a comment to clarify why you are using `containerClassName.length() - 6` as the end index.

Code under review:
private void checkLoggerInstantiation(DetailAST literalNewToken) {
        final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
        
        if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
            return;
        }
        
        final DetailAST elistToken = literalNewToken.findFirstToken(TokenTypes.ELIST);
        final DetailAST exprToken = elistToken.findFirstToken(TokenTypes.EXPR);
        if (exprToken.getFirstChild().getType() != TokenTypes.DOT) {
            return;
        }
        
        String containerClassName = FullIdent.createFullIdentBelow(exprToken).getText();
        containerClassName = containerClassName.substring(0, containerClassName.length() - 6);
        if (!containerClassName.equals(className)) {
            log(literalNewToken, String.format("Not newing a ClientLogger with matching class name. Use ''%s.class'' instead of ''%s.class''", className, containerClassName));
        }
    }

Line commented on: containerClassName = containerClassName.substring(0, containerClassName.length() - 6);

Revised code:
private void checkLoggerInstantiation(DetailAST literalNewToken) {
        final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
        
        if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
            return;
        }
        
        TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprToken -> {
            
            if (exprToken.getType() != TokenTypes.EXPR || exprToken.getFirstChild().getType() != TokenTypes.DOT) {
                return false;
            }
            
            final String containerClassName = FullIdent.createFullIdent(exprToken.getFirstChild()).getText();
            
            final String className = classNameDeque.peekFirst();
            if (!containerClassName.equals(className + ".class")) {
                log(exprToken, String.format("Not newing a ClientLogger with matching class name. Use ''%s.class'' instead of ''%s''", className, containerClassName));
            }
            return true;
        });
    }
Code review comment: Can we get rid of this method since toByteArray() does a copy?

Code under review:
public static byte[] getPosition(@Nullable ShufflePosition shufflePosition) {
    if (shufflePosition == null) {
      return null;
    }
    Preconditions.checkArgument(shufflePosition instanceof ByteArrayShufflePosition);
    ByteArrayShufflePosition adapter = (ByteArrayShufflePosition) shufflePosition;
    return adapter.getPosition().toByteArray();
  }

Line commented on: return adapter.getPosition().toByteArray();

Revised code:
public static byte[] getPosition(@Nullable ShufflePosition shufflePosition) {
    if (shufflePosition == null) {
      return null;
    }
    Preconditions.checkArgument(shufflePosition instanceof ByteArrayShufflePosition);
    ByteArrayShufflePosition adapter = (ByteArrayShufflePosition) shufflePosition;
    return adapter.getPosition().toByteArray();
  }
Code review comment: Got it, you wrap all the methods.

Code under review:
public void handle(Promise<Object> event) {
        final Context previous = Context.current();
        grpcContext.attach();
        try {
            requestContext.activate(state);
            try {
                consumer.accept(delegate);
            } finally {
                requestContext.deactivate();
            }
            event.complete();
        } finally {
            grpcContext.detach(previous);
        }
    }

Line commented on: consumer.accept(delegate);

Revised code:
public void handle(Promise<Object> event) {
        final Context previous = Context.current();
        grpcContext.attach();
        try {
            requestContext.activate(state);
            try {
                consumer.accept(delegate);
            } catch (Throwable any) {
                event.fail(any);
                return;
            } finally {
                requestContext.deactivate();
            }
            event.complete();
        } finally {
            grpcContext.detach(previous);
        }
    }
Code review comment: Do you have a pointer for this? I remembered I was told your thing was better now but I had a look at the code of the JDK the other day and it wasn't that obvious.  Not asking to justify but if you have a pointer handy, I'll be interested in refreshing my memory.

Code under review:
public ClassPathResourceIndex build() {
            Map<String, ClassPathElement[]> compactedResourceMapping = new HashMap<>(resourceMapping.size());
            for (Entry<String, List<ClassPathElement>> resourceMappingEntry : resourceMapping.entrySet()) {
                compactedResourceMapping.put(resourceMappingEntry.getKey(),
                        resourceMappingEntry.getValue().toArray(EMPTY_CLASSPATH_ELEMENT));
            }

            return new ClassPathResourceIndex(compactedResourceMapping, transformedClasses,
                    reloadableClasses, parentFirstResources, bannedResources);
        }

Line commented on: resourceMappingEntry.getValue().toArray(EMPTY_CLASSPATH_ELEMENT));

Revised code:
public ClassPathResourceIndex build() {
            Map<String, ClassPathElement[]> compactedResourceMapping = new HashMap<>(resourceMapping.size());
            for (Entry<String, List<ClassPathElement>> resourceMappingEntry : resourceMapping.entrySet()) {
                compactedResourceMapping.put(resourceMappingEntry.getKey(),
                        resourceMappingEntry.getValue().toArray(EMPTY_CLASSPATH_ELEMENT));
            }

            return new ClassPathResourceIndex(compactedResourceMapping, transformedClasses,
                    reloadableClasses, parentFirstResources, bannedResources);
        }
Code review comment: This differs from close() in WriteFn, is it intentional?

Code under review:
public void close() throws IOException {
      if (channel != null) {
        try {
          channel.close();
        } catch (Exception e) {
          
        }
      }
      if (connection != null) {
        connection.close();
      }
    }

Line commented on: if (channel != null) {

Revised code:
public void close() throws IOException {
      if (connectionHandler != null) {
        connectionHandler.stop();
      }
    }
Code review comment: @zentol I did a little digging in the rocksdb code. The only place that an exception is explicitly thrown is in the JNI wrapper if the property string is invalid[1].   Otherwise, the value is just pulled from a map here[2]. Since there is already a test validating each property against the current rocksdb version, and this pr only exposes an enum, I don't think there is any reason to believe a RocksDB exception will be thrown in production.   [1] https://github.com/facebook/rocksdb/blob/02dc07491650b0c8d8470a24806ba86d09ea31a4/java/rocksjni/rocksjni.cc#L1757  [2] https://github.com/facebook/rocksdb/blob/189f0c27aaecdf17ae7fc1f826a423a28b77984f/db/internal_stats.cc#L339

Code under review:
private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) {
		if (metricView.isClosed()) {
			return;
		}
		try {
			synchronized (lock) {
				if (rocksDB != null) {
					long value = rocksDB.getLongProperty(handle, property);
					metricView.setValue(value);
				}
			}
		} catch (RocksDBException e) {
			metricView.close();
			LOG.warn("Failed to read native metric %s from RocksDB", property, e);
		}
	}

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

Revised code:
private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) {
		if (metricView.isClosed()) {
			return;
		}
		try {
			synchronized (lock) {
				if (rocksDB != null) {
					long value = rocksDB.getLongProperty(handle, property);
					metricView.setValue(value);
				}
			}
		} catch (RocksDBException e) {
			metricView.close();
			LOG.warn("Failed to read native metric %s from RocksDB", property, e);
		}
	}
Code review comment: I originally also used the end handler in my testing without issues.

Code under review:
private void doHandle(RoutingContext ctx, ManagedContext requestContext) {
        QuarkusHttpUser user = (QuarkusHttpUser) ctx.user();
        if (user != null) {
            Arc.container().instance(CurrentIdentityAssociation.class).get().setIdentity(user.getSecurityIdentity());
        }
        SmallRyeHealthReporter reporter = Arc.container().instance(SmallRyeHealthReporter.class).get();
        Context context = Vertx.currentContext();
        getHealth(reporter, ctx).emitOn(MutinyHelper.executor(context))
                .subscribe().with(health -> {
                    if (requestContext != null) {
                        requestContext.terminate();
                    }
                    HttpServerResponse resp = ctx.response();
                    if (health.isDown()) {
                        resp.setStatusCode(503);
                    }
                    resp.headers().set(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
                    Buffer buffer = Buffer.buffer(256); 
                    try (BufferOutputStream outputStream = new BufferOutputStream(buffer);) {
                        reporter.reportHealth(outputStream, health);
                        resp.end(buffer);
                    } catch (IOException e) {
                        throw new UncheckedIOException(e);
                    }
                });
    }

Line commented on: if (requestContext != null) {

Revised code:
private void doHandle(RoutingContext ctx, ManagedContext requestContext) {
        QuarkusHttpUser user = (QuarkusHttpUser) ctx.user();
        if (user != null) {
            Arc.container().instance(CurrentIdentityAssociation.class).get().setIdentity(user.getSecurityIdentity());
        }
        SmallRyeHealthReporter reporter = Arc.container().instance(SmallRyeHealthReporter.class).get();
        Context context = Vertx.currentContext();
        getHealth(reporter, ctx).emitOn(MutinyHelper.executor(context))
                .subscribe().with(health -> {
                    if (requestContext != null) {
                        requestContext.terminate();
                    }
                    HttpServerResponse resp = ctx.response();
                    if (health.isDown()) {
                        resp.setStatusCode(503);
                    }
                    resp.headers().set(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
                    Buffer buffer = Buffer.buffer(256); 
                    try (BufferOutputStream outputStream = new BufferOutputStream(buffer);) {
                        reporter.reportHealth(outputStream, health);
                        resp.end(buffer);
                    } catch (IOException e) {
                        throw new UncheckedIOException(e);
                    }
                }, failure -> {
                    if (requestContext != null) {
                        requestContext.terminate();
                    }
                });
    }
Code review comment: FYI: before my changes, we can reproduce these two potential issues in my below introduced unit tests stable. One case is throwing NPE exception sometimes, and another case is throwing netty stack exception when same buffer recycled twice.

Code under review:
Optional<BufferAndAvailability> getNextBuffer() throws IOException {
		checkState(partitionRequestClient != null, "Queried for a buffer before requesting a queue.");

		checkError();

		final Buffer next;
		final boolean moreAvailable;

		synchronized (receivedBuffers) {
			next = receivedBuffers.poll();
			moreAvailable = !receivedBuffers.isEmpty();
		}

		if (next == null) {
			if (isReleased.get()) {
				throw new CancelTaskException("Queried for a buffer after channel has been released.");
			} else {
				throw new IllegalStateException("There should always have queued buffers for unreleased channel.");
			}
		}

		numBytesIn.inc(next.getSize());
		numBuffersIn.inc();
		return Optional.of(new BufferAndAvailability(next, moreAvailable, 0));
	}

Line commented on: if (next == null) {

Revised code:
Optional<BufferAndAvailability> getNextBuffer() throws IOException {
		checkState(partitionRequestClient != null, "Queried for a buffer before requesting a queue.");

		checkError();

		final Buffer next;
		final boolean moreAvailable;

		synchronized (receivedBuffers) {
			next = receivedBuffers.poll();
			moreAvailable = !receivedBuffers.isEmpty();
		}

		if (next == null) {
			if (isReleased.get()) {
				throw new CancelTaskException("Queried for a buffer after channel has been released.");
			} else {
				throw new IllegalStateException("There should always have queued buffers for unreleased channel.");
			}
		}

		numBytesIn.inc(next.getSize());
		numBuffersIn.inc();
		return Optional.of(new BufferAndAvailability(next, moreAvailable, 0));
	}
Code review comment: Oh I didn't know about this, I've used it, thanks. I really didn't expect `onItem` to lead me to an operation that worked on the completion of ALL items.  I do not see what you mean about `delete` and `flush` though, which don't use streams?

Code under review:
public Uni<Void> persist(Stream<?> entities) {
        return getEntityManager().flatMap(
                em -> Uni.combine().all().unis(entities.map(entity -> persist(em, entity)).collect(Collectors.toList()))
                        .combinedWith(list -> null));
    }

Line commented on: em -> Uni.combine().all().unis(entities.map(entity -> persist(em, entity)).collect(Collectors.toList()))

Revised code:
public Uni<Void> persist(Stream<?> entities) {
        Mutiny.Session session = getSession();
        List<Uni<Void>> uniList = entities.map(entity -> persist(session, entity)).collect(Collectors.toList());
        return Uni.combine().all().unis(uniList).discardItems();
        
        
        
        
    }
Code review comment: Gotcha, didn't notice that this was a sample.

Code under review:
public void setup() throws InvalidKeyException, NoSuchAlgorithmException {
        if (interceptorManager.isPlaybackMode()) {
            connectionString = "Endpoint=http:
            tokenCredential = null;

            String endpoint = new ConfigurationClientCredentials(connectionString).getBaseUri();
            client = new ConfigurationClientBuilder()
                .credential(tokenCredential)
                .endpoint(endpoint)
                .httpClient(interceptorManager.getPlaybackClient())
                .buildClient();
        } else {
            connectionString = Configuration.getGlobalConfiguration().get(AZURE_APPCONFIG_CONNECTION_STRING);
            tokenCredential = new DefaultAzureCredentialBuilder().build();

            String endpoint = new ConfigurationClientCredentials(connectionString).getBaseUri();
            client = new ConfigurationClientBuilder()
                .credential(tokenCredential)
                .endpoint(endpoint)
                .addPolicy(interceptorManager.getRecordPolicy()) 
                .buildClient();
        }
    }

Line commented on: tokenCredential = null;

Revised code:
public void setup() throws InvalidKeyException, NoSuchAlgorithmException {
        if (interceptorManager.isPlaybackMode()) {
            connectionString = "Endpoint=http:

            String endpoint = new ConfigurationClientCredentials(connectionString).getBaseUri();
            
            client = new ConfigurationClientBuilder()
                .connectionString(connectionString)
                .endpoint(endpoint)
                .httpClient(interceptorManager.getPlaybackClient())
                .buildClient();
        } else {
            connectionString = Configuration.getGlobalConfiguration().get(AZURE_APPCONFIG_CONNECTION_STRING);
            tokenCredential = new DefaultAzureCredentialBuilder().build();

            String endpoint = new ConfigurationClientCredentials(connectionString).getBaseUri();
            client = new ConfigurationClientBuilder()
                .credential(tokenCredential)
                .endpoint(endpoint)
                .addPolicy(interceptorManager.getRecordPolicy()) 
                .buildClient();
        }
    }
Code review comment: Yes, this would be interesting. For example having a block size equivalent to the TCP packet size, etc.

Code under review:
public ByteBufferSendTest(PerfStressOptions options) {
        super(options);
        
        
        dataToSend = TestDataCreationHelper.createRandomByteBufferFlux(options.getSize());
        mockHttpReceiveClient = new MockHttpReceiveClient();
        final HttpPipeline pipeline = new HttpPipelineBuilder()
            .httpClient(mockHttpReceiveClient)
            .build();

        service = RestProxy.create(MyRestProxyService.class, pipeline);
    }


Revised code:
public ByteBufferSendTest(PerfStressOptions options) {
        super(options);
        
        
        dataToSend = TestDataCreationHelper.createRandomByteBufferFlux(options.getSize());
        mockHttpReceiveClient = new MockHttpReceiveClient();
        final HttpPipeline pipeline = new HttpPipelineBuilder()
            .httpClient(mockHttpReceiveClient)
            .build();

        service = RestProxy.create(MyRestProxyService.class, pipeline);
    }
Code review comment: This includes connection loss, connection reconnect etc. There should be a full resync on connection reconnect since lots of events may have been lost. Why is removeApplications() not handling additions of applications?  CHILD_ADDED CHILD_REMOVED CHILD_UPDATED CONNECTION_LOST CONNECTION_RECONNECTED CONNECTION_SUSPENDED INITIALIZED

Code under review:
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
        switch (event.getType()) {
            case CHILD_ADDED:
                applicationAdded(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
                break;
            
            case CHILD_REMOVED:
                applicationRemoved(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
                break;
            default:
                
                
                removeApplications();
                break;
        }
    }

Line commented on: default:

Revised code:
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
        switch (event.getType()) {
            case CHILD_ADDED:
                applicationAdded(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
                break;
            
            case CHILD_REMOVED:
                applicationRemoved(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
                break;
            default:
                
                
                removeApplications();
                break;
        }
    }
Code review comment: Can we replace this instance check with a node kind check with this

Code under review:
public void visit(BLangConstPattern constMatchPattern) {
        BLangExpression constPatternExpr = constMatchPattern.expr;
        typeChecker.checkExpr(constPatternExpr, env);
        if (constPatternExpr instanceof BLangSimpleVarRef) {
            BLangSimpleVarRef constRef = (BLangSimpleVarRef) constPatternExpr;
            if (constRef.symbol.kind != SymbolKind.CONSTANT) {
                dlog.error(constMatchPattern.pos, DiagnosticErrorCode.VARIABLE_SHOULD_BE_DECLARED_AS_CONSTANT,
                        constRef.variableName);
            }
        }
        constMatchPattern.type = types.resolvePatternTypeFromMatchExpr(constMatchPattern, constPatternExpr);
    }

Line commented on: if (constPatternExpr instanceof BLangSimpleVarRef) {

Revised code:
public void visit(BLangConstPattern constMatchPattern) {
        BLangExpression constPatternExpr = constMatchPattern.expr;
        typeChecker.checkExpr(constPatternExpr, env);
        if (constPatternExpr.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
            BLangSimpleVarRef constRef = (BLangSimpleVarRef) constPatternExpr;
            if (constRef.symbol.kind != SymbolKind.CONSTANT) {
                dlog.error(constMatchPattern.pos, DiagnosticErrorCode.VARIABLE_SHOULD_BE_DECLARED_AS_CONSTANT,
                        constRef.variableName);
            }
        }
        constMatchPattern.type = types.resolvePatternTypeFromMatchExpr(constMatchPattern, constPatternExpr);
    }
Code review comment: not use all uppercase in error msg, and not use abbreviation, leave a msg with more ditail for easy understand. the legacy planner's error msg is "ordinal exceeds number of items in select list: 3"

Code under review:
private void checkOrd(int ord, int childOutputSize) {
        if (ord < 1 || ord > childOutputSize) {
            throw new IllegalStateException(String.format("INVALID ORD: %s", ord));
        }
    }

Line commented on: throw new IllegalStateException(String.format("INVALID ORD: %s", ord));

Revised code:
private void checkOrd(int ord, int childOutputSize) {
        if (ord < 1 || ord > childOutputSize) {
            throw new IllegalStateException(String.format("ordinal exceeds number of items in select list: %s", ord));
        }
    }
Code review comment: Ok, I think I get it now. Now it's a public method so you are protecting it more.  I think I would prefer:  1. rename `discarded` -> `disposed` or `scheduledForDisacrding` 2. rename `stateDiscarded` -> `discarded`  ?

Code under review:
public void discard() {
		synchronized (lock) {
			if (stateDiscarded) {
				Preconditions.checkState(discarded, "Checkpoint should be disposed before being discarded");
				return;
			} else {
				stateDiscarded = true;
			}
		}
		
		
		try {
			StateUtil.bestEffortDiscardAllStateObjects(operatorStates.values());
			targetLocation.disposeOnFailure();
		} catch (Throwable t) {
			LOG.warn(
				"Could not properly dispose the private states in the pending checkpoint {} of job {}.",
				checkpointId, jobId, t);
		} finally {
			operatorStates.clear();
		}
	}

Line commented on: try {

Revised code:
public void discard() {
		synchronized (lock) {
			if (discarded) {
				Preconditions.checkState(disposed, "Checkpoint should be disposed before being discarded");
				return;
			} else {
				discarded = true;
			}
		}
		
		
		try {
			StateUtil.bestEffortDiscardAllStateObjects(operatorStates.values());
			targetLocation.disposeOnFailure();
		} catch (Throwable t) {
			LOG.warn(
				"Could not properly dispose the private states in the pending checkpoint {} of job {}.",
				checkpointId, jobId, t);
		} finally {
			operatorStates.clear();
		}
	}
Code review comment: Shouldn't we set the inner exception as `databaseRefreshErrorSnapshot`?

Code under review:
private void initializeGatewayConfigurationReader() {
        this.gatewayConfigurationReader = new GatewayServiceConfigurationReader(this.globalEndpointManager);
        DatabaseAccount databaseAccount = this.globalEndpointManager.getLatestDatabaseAccount();
        
        
        
        if (databaseAccount == null) {
            Throwable databaseRefreshErrorSnapshot = this.globalEndpointManager.getLatestDatabaseRefreshError();
            if (databaseRefreshErrorSnapshot != null) {
                logger.error("Client initialization failed. Check if the endpoint is reachable and if your auth token "
                        + "is valid. More info: https:
                    databaseRefreshErrorSnapshot
                );

                throw new RuntimeException("Client initialization failed. Check if the endpoint is reachable and if your auth token "
                    + "is valid. More info: https:
                    this.globalEndpointManager.getLatestDatabaseRefreshError());
            } else {
                logger.error("Client initialization failed."
                    + " Check if the endpoint is reachable and if your auth token is valid. More info: https:
            }
        }

        this.useMultipleWriteLocations = this.connectionPolicy.isMultipleWriteRegionsEnabled() && BridgeInternal.isEnableMultipleWriteLocations(databaseAccount);

        
        
    }

Line commented on: this.globalEndpointManager.getLatestDatabaseRefreshError());

Revised code:
private void initializeGatewayConfigurationReader() {
        this.gatewayConfigurationReader = new GatewayServiceConfigurationReader(this.globalEndpointManager);
        DatabaseAccount databaseAccount = this.globalEndpointManager.getLatestDatabaseAccount();
        
        
        
        if (databaseAccount == null) {
            Throwable databaseRefreshErrorSnapshot = this.globalEndpointManager.getLatestDatabaseRefreshError();
            if (databaseRefreshErrorSnapshot != null) {
                logger.error("Client initialization failed. Check if the endpoint is reachable and if your auth token "
                        + "is valid. More info: https:
                    databaseRefreshErrorSnapshot
                );

                throw new RuntimeException("Client initialization failed. Check if the endpoint is reachable and if your auth token "
                    + "is valid. More info: https:
                    databaseRefreshErrorSnapshot);
            } else {
                logger.error("Client initialization failed."
                    + " Check if the endpoint is reachable and if your auth token is valid. More info: https:

                throw new RuntimeException("Client initialization failed. Check if the endpoint is reachable and if your auth token "
                    + "is valid. More info: https:
            }
        }

        this.useMultipleWriteLocations = this.connectionPolicy.isMultipleWriteRegionsEnabled() && BridgeInternal.isEnableMultipleWriteLocations(databaseAccount);

        
        
    }
Code review comment: Nit: you can call another constructor using `this(tokenRefresher, refreshProactively, initialToken, getDefaultRefreshTimeBeforeTokenExpiry());`

Code under review:
public CommunicationTokenRefreshOptions(Supplier<Mono<String>> tokenRefresher, boolean refreshProactively, String initialToken) {
        this.tokenRefresher = tokenRefresher;
        this.refreshProactively = refreshProactively;
        this.initialToken = initialToken;
        this.refreshTimeBeforeTokenExpiry = getDefaultRefreshTimeBeforeTokenExpiry();
    }

Line commented on: this.refreshTimeBeforeTokenExpiry = getDefaultRefreshTimeBeforeTokenExpiry();

Revised code:
public CommunicationTokenRefreshOptions(Supplier<Mono<String>> tokenRefresher, boolean refreshProactively, String initialToken) {
        this.asyncTokenRefresher = tokenRefresher;
        this.tokenRefresher = null;
        this.refreshProactively = refreshProactively;
        this.initialToken = initialToken;
    }
Code review comment: Why this program cannot depend on other dependencies?  `OperatingSystem.isWindows()` cannot also be used?

Code under review:
public static File extractUdfRunner(String tmpdir) throws IOException, InterruptedException {
		File file;
		
		if (System.getProperty("os.name").startsWith("Windows")) {
			file = new File(tmpdir, PYFLINK_UDF_RUNNER_BAT);
		} else {
			file = new File(tmpdir, PYFLINK_UDF_RUNNER_SH);
		}
		
		
		
		
		String javaExecutable = String.join(File.separator, System.getProperty("java.home"), "bin", "java");
		String classPath = new File(
			ResourceUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
		new ProcessBuilder(
			javaExecutable,
			"-cp",
			classPath,
			ResourceUtil.class.getName(),
			tmpdir,
			file.getName()).inheritIO().start().waitFor();
		return file;
	}


Revised code:
public static File extractUdfRunner(String tmpdir) throws IOException, InterruptedException {
		File file;
		if (OperatingSystem.isWindows()) {
			file = new File(tmpdir, PYFLINK_UDF_RUNNER_BAT);
		} else {
			file = new File(tmpdir, PYFLINK_UDF_RUNNER_SH);
		}
		
		
		
		
		String javaExecutable = String.join(File.separator, System.getProperty("java.home"), "bin", "java");
		String classPath = new File(
			ResourceUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
		new ProcessBuilder(
			javaExecutable,
			"-cp",
			classPath,
			ResourceUtil.class.getName(),
			tmpdir,
			file.getName()).inheritIO().start().waitFor();
		return file;
	}
Code review comment: Predicates refer to `where` instead of `on`.

Code under review:
public static StatsDeriveResult estimate(StatsDeriveResult leftStats, StatsDeriveResult rightStats, Join join) {
        JoinType joinType = join.getJoinType();
        StatsDeriveResult statsDeriveResult = new StatsDeriveResult(leftStats);
        statsDeriveResult.merge(rightStats);
        List<Expression> eqConjunctList = join.getHashJoinPredicates();
        long rowCount = -1;
        if (joinType.isSemiOrAntiJoin()) {
            rowCount = getSemiJoinRowCount(leftStats, rightStats, eqConjunctList, joinType);
        } else if (joinType.isInnerJoin() || joinType.isOuterJoin()) {
            rowCount = getJoinRowCount(leftStats, rightStats, eqConjunctList, joinType);
        } else if (joinType.isCrossJoin()) {
            rowCount = CheckedMath.checkedMultiply(leftStats.getRowCount(),
                    rightStats.getRowCount());
        } else {
            throw new RuntimeException("joinType is not supported");
        }
        statsDeriveResult.setRowCount(rowCount);
        return statsDeriveResult;
    }

Line commented on: List<Expression> eqConjunctList = join.getHashJoinPredicates();

Revised code:
public static StatsDeriveResult estimate(StatsDeriveResult leftStats, StatsDeriveResult rightStats, Join join) {
        JoinType joinType = join.getJoinType();
        StatsDeriveResult statsDeriveResult = new StatsDeriveResult(leftStats);
        statsDeriveResult.merge(rightStats);
        List<Expression> eqConjunctList = join.getHashJoinConjuncts();
        long rowCount = -1;
        if (joinType.isSemiOrAntiJoin()) {
            rowCount = getSemiJoinRowCount(leftStats, rightStats, eqConjunctList, joinType);
        } else if (joinType.isInnerJoin() || joinType.isOuterJoin()) {
            rowCount = getJoinRowCount(leftStats, rightStats, eqConjunctList, joinType);
        } else if (joinType.isCrossJoin()) {
            rowCount = CheckedMath.checkedMultiply(leftStats.getRowCount(),
                    rightStats.getRowCount());
        } else {
            throw new RuntimeException("joinType is not supported");
        }
        statsDeriveResult.setRowCount(rowCount);
        return statsDeriveResult;
    }
Code review comment: Just return the if case statement

Code under review:
private boolean checkKeyPermissions(List<KeyOperation> operations, KeyOperation keyOperation) {
        if (operations.contains(keyOperation)) {
            return true;
        }
        return false;
    }

Line commented on: if (operations.contains(keyOperation)) {

Revised code:
private boolean checkKeyPermissions(List<KeyOperation> operations, KeyOperation keyOperation) {
        return operations.contains(keyOperation);
    }
Code review comment: I would suggest to make this a separate test case.

Code under review:
public void testGetAllVariablesWithExclusions() {
		MetricRegistry registry = NoOpMetricRegistry.INSTANCE;

		AbstractMetricGroup<?> group1 = new ProcessMetricGroup(registry, "host");
		assertThat(group1.getAllVariables(), IsMapContaining.hasKey(ScopeFormat.SCOPE_HOST));

		AbstractMetricGroup<?> group2 = new ProcessMetricGroup(registry, "host");
		assertEquals(group2.getAllVariables(-1, Collections.singleton(ScopeFormat.SCOPE_HOST)).size(), 0);
	}

Line commented on: assertEquals(group2.getAllVariables(-1, Collections.singleton(ScopeFormat.SCOPE_HOST)).size(), 0);

Revised code:
public void testGetAllVariablesWithExclusions() {
		MetricRegistry registry = NoOpMetricRegistry.INSTANCE;

		AbstractMetricGroup<?> group = new ProcessMetricGroup(registry, "host");
		assertEquals(group.getAllVariables(-1, Collections.singleton(ScopeFormat.SCOPE_HOST)).size(), 0);
	}
Code review comment: Sure, I can make it throw instead (in future PR).

Code under review:
private Set<EndpointId> endpointIdsOf(LoadBalancer loadBalancer) {
            if (zone.environment().isManuallyDeployed()) { 
                return Set.of();
            }
            var instanceSpec = deploymentSpec.instance(loadBalancer.application().instance());
            if (instanceSpec.isEmpty()) {
                return Set.of();
            }
            return instanceSpec.get().endpoints().stream()
                               .filter(endpoint -> endpoint.containerId().equals(loadBalancer.cluster().value()))
                               .filter(endpoint -> endpoint.regions().contains(zone.region()))
                               .map(com.yahoo.config.application.api.Endpoint::endpointId)
                               .map(EndpointId::of)
                               .collect(Collectors.toSet());
        }

Line commented on: if (instanceSpec.isEmpty()) {

Revised code:
private Set<EndpointId> endpointIdsOf(LoadBalancer loadBalancer) {
            if (zone.environment().isManuallyDeployed()) { 
                return Set.of();
            }
            var instanceSpec = deploymentSpec.instance(loadBalancer.application().instance());
            if (instanceSpec.isEmpty()) {
                return Set.of();
            }
            return instanceSpec.get().endpoints().stream()
                               .filter(endpoint -> endpoint.containerId().equals(loadBalancer.cluster().value()))
                               .filter(endpoint -> endpoint.regions().contains(zone.region()))
                               .map(com.yahoo.config.application.api.Endpoint::endpointId)
                               .map(EndpointId::of)
                               .collect(Collectors.toSet());
        }