muttakin2301/ccr2000 huggingface dataset:
Code review comment: Hm, this way you swallow the info about supported index versions, or?

Code under review:
public static Index indexJar(File file, Set<String> removed) throws IOException {
        try (JarFile jarFile = new JarFile(file)) {
            ZipEntry existing = jarFile.getEntry(JANDEX_INDEX);
            if (existing != null && removed == null) {
                try (InputStream in = jarFile.getInputStream(existing)) {
                    IndexReader reader = new IndexReader(in);
                    if (reader.getIndexVersion() < REQUIRED_INDEX_VERSION) {
                        log.warnf(
                                "Re-indexing %s - at least Jandex 2.1 must be used to index an application dependency",
                                file);
                        return indexJar(jarFile, removed);
                    } else {
                        try {
                            return reader.read();
                        } catch (UnsupportedVersion e) {
                            throw new UnsupportedVersion("Can't read Jandex index from " + file + ": " + e.getMessage());
                        }
                    }
                }
            }
            return indexJar(jarFile, removed);
        }
    }

Line commented on: throw new UnsupportedVersion("Can't read Jandex index from " + file + ": " + e.getMessage());

Revised code:
public static Index indexJar(File file, Set<String> removed) throws IOException {
        try (JarFile jarFile = new JarFile(file)) {
            ZipEntry existing = jarFile.getEntry(JANDEX_INDEX);
            if (existing != null && removed == null) {
                try (InputStream in = jarFile.getInputStream(existing)) {
                    IndexReader reader = new IndexReader(in);
                    if (reader.getIndexVersion() < REQUIRED_INDEX_VERSION) {
                        log.warnf(
                                "Re-indexing %s - at least Jandex 2.1 must be used to index an application dependency",
                                file);
                        return indexJar(jarFile, removed);
                    } else {
                        try {
                            return reader.read();
                        } catch (UnsupportedVersion e) {
                            throw new UnsupportedVersion("Can't read Jandex index from " + file + ": " + e.getMessage());
                        }
                    }
                }
            }
            return indexJar(jarFile, removed);
        }
    }
Code review comment: Consider an empty description, which would mean it would be absent in the report.

Code under review:
private List<Node> decommission(String hostname, DecommissionOperation op, Agent agent, Instant instant) {
        Optional<NodeMutex> nodeMutex = lockAndGet(hostname);
        if (nodeMutex.isEmpty()) return List.of();
        Node host = nodeMutex.get().node();
        if (!host.type().isHost()) throw new IllegalArgumentException("Cannot " + op + " non-host " + host);
        List<Node> result;
        boolean wantToDeprovision = op == DecommissionOperation.deprovision;
        boolean wantToRebuild = op == DecommissionOperation.rebuild;
        try (NodeMutex lock = nodeMutex.get(); Mutex allocationLock = lockUnallocated()) {
            
            host = lock.node();
            result = performOn(list(allocationLock).childrenOf(host),
                               (node, nodeLock) -> write(node.withWantToRetire(true, wantToDeprovision, wantToRebuild, agent, instant),
                                                         nodeLock));
            Node newHost = host.withWantToRetire(true, wantToDeprovision, wantToRebuild, agent, instant);
            if (op == DecommissionOperation.encrypt) {
                Report report = Report.basicReport(Report.WANT_TO_ENCRYPT_ID, Report.Type.UNSPECIFIED, instant, "Host should be encrypted");
                newHost = newHost.with(newHost.reports().withReport(report));
            }
            result.add(write(newHost, lock));
        }
        return result;
    }

Line commented on: Report report = Report.basicReport(Report.WANT_TO_ENCRYPT_ID, Report.Type.UNSPECIFIED, instant, "Host should be encrypted");

Revised code:
private List<Node> decommission(String hostname, DecommissionOperation op, Agent agent, Instant instant) {
        Optional<NodeMutex> nodeMutex = lockAndGet(hostname);
        if (nodeMutex.isEmpty()) return List.of();
        Node host = nodeMutex.get().node();
        if (!host.type().isHost()) throw new IllegalArgumentException("Cannot " + op + " non-host " + host);
        List<Node> result;
        boolean wantToDeprovision = op == DecommissionOperation.deprovision;
        boolean wantToRebuild = op == DecommissionOperation.rebuild;
        try (NodeMutex lock = nodeMutex.get(); Mutex allocationLock = lockUnallocated()) {
            
            host = lock.node();
            result = performOn(list(allocationLock).childrenOf(host),
                               (node, nodeLock) -> write(node.withWantToRetire(true, wantToDeprovision, wantToRebuild, agent, instant),
                                                         nodeLock));
            Node newHost = host.withWantToRetire(true, wantToDeprovision, wantToRebuild, agent, instant);
            if (op == DecommissionOperation.encrypt) {
                Report report = Report.basicReport(Report.WANT_TO_ENCRYPT_ID, Report.Type.UNSPECIFIED, instant, "");
                newHost = newHost.with(newHost.reports().withReport(report));
            }
            result.add(write(newHost, lock));
        }
        return result;
    }
Code review comment: yeah, this can be done, added it.

Code under review:
private WorkloadIdentityCredential getWorkloadIdentityCredentialIfAvailable() {
        Configuration configuration = identityClientOptions.getConfiguration() == null
            ? Configuration.getGlobalConfiguration().clone() : identityClientOptions.getConfiguration();

        String tenantId = configuration.get(Configuration.PROPERTY_AZURE_TENANT_ID);
        String federatedTokenFilePath = configuration.get(AZURE_FEDERATED_TOKEN_FILE);
        String azureAuthorityHost = configuration.get(Configuration.PROPERTY_AZURE_AUTHORITY_HOST);
        if (!(CoreUtils.isNullOrEmpty(tenantId)
            || CoreUtils.isNullOrEmpty(federatedTokenFilePath)
            || CoreUtils.isNullOrEmpty(managedIdentityClientId)
            || CoreUtils.isNullOrEmpty(azureAuthorityHost))) {
            return new WorkloadIdentityCredential(managedIdentityClientId, tenantId, federatedTokenFilePath,
                azureAuthorityHost, identityClientOptions.clone());
        }
        return null;
    }

Line commented on: || CoreUtils.isNullOrEmpty(managedIdentityClientId)

Revised code:
private WorkloadIdentityCredential getWorkloadIdentityCredentialIfAvailable() {
        Configuration configuration = identityClientOptions.getConfiguration() == null
            ? Configuration.getGlobalConfiguration().clone() : identityClientOptions.getConfiguration();

        String tenantId = configuration.get(Configuration.PROPERTY_AZURE_TENANT_ID);
        String federatedTokenFilePath = configuration.get(AZURE_FEDERATED_TOKEN_FILE);
        String azureAuthorityHost = configuration.get(Configuration.PROPERTY_AZURE_AUTHORITY_HOST);
        String clientId = CoreUtils.isNullOrEmpty(workloadIdentityClientId) ? managedIdentityClientId : workloadIdentityClientId;
        if (!(CoreUtils.isNullOrEmpty(tenantId)
            || CoreUtils.isNullOrEmpty(federatedTokenFilePath)
            || CoreUtils.isNullOrEmpty(clientId)
            || CoreUtils.isNullOrEmpty(azureAuthorityHost))) {
            return new WorkloadIdentityCredential(tenantId, clientId, federatedTokenFilePath, identityClientOptions.setAuthorityHost(azureAuthorityHost).clone());
        }
        return null;
    }
Code review comment: Why change the version?  Should just leave the version as it is.  IMO, We only do these version checks when a spec version ends up not being implemented by us and is not backward compatible

Code under review:
public String specVersion() {
        if (specVersion == null) {
            JsonNode specVersion = event.get("specversion");
            if (specVersion != null && isKnownSpecVersion(specVersion.asText())) {
                this.specVersion = specVersion.asText();
            } else {
                this.specVersion = "1.0";
            }
        }

        return specVersion;
    }

Line commented on: this.specVersion = "1.0";

Revised code:
public String specVersion() {
        if (specVersion == null) {
            JsonNode specVersion = event.get("specversion");
            if (specVersion != null) {
                this.specVersion = specVersion.asText();
            }
        }

        return specVersion;
    }
Code review comment: `this.externalTreeNode()` can be extracted to separate varaible as it is repeated.

Code under review:
public boolean isMissingNode() {
        if (this.externalTreeNode().kind() == SyntaxKind.STRING_LITERAL) {
            StringLiteralNode stringLiteralNode = (StringLiteralNode) this.externalTreeNode();
            if (stringLiteralNode.isMissing()) {
                return true;
            }
            return stringLiteralNode.startDoubleQuote().isMissing() || stringLiteralNode.endDoubleQuote().isMissing();
        }
        if (this.externalTreeNode().kind() == SyntaxKind.LITERAL_STRING) {
            LiteralStringLiteralNode literalStringNode = (LiteralStringLiteralNode) this.externalTreeNode();
            if (literalStringNode.isMissing()) {
                return true;
            }
            return literalStringNode.startSingleQuote().isMissing() || literalStringNode.startSingleQuote().isMissing();
        }
        return false;
    }

Line commented on: if (this.externalTreeNode().kind() == SyntaxKind.STRING_LITERAL) {

Revised code:
public boolean isMissingNode() {
        if (this.externalTreeNode().kind() == SyntaxKind.STRING_LITERAL) {
            StringLiteralNode stringLiteralNode = (StringLiteralNode) this.externalTreeNode();
            if (stringLiteralNode.isMissing()) {
                return true;
            }
            return stringLiteralNode.startDoubleQuote().isMissing() || stringLiteralNode.endDoubleQuote().isMissing();
        }
        if (this.externalTreeNode().kind() == SyntaxKind.LITERAL_STRING) {
            LiteralStringLiteralNode literalStringNode = (LiteralStringLiteralNode) this.externalTreeNode();
            if (literalStringNode.isMissing()) {
                return true;
            }
            return literalStringNode.startSingleQuote().isMissing() || literalStringNode.startSingleQuote().isMissing();
        }
        return false;
    }
Code review comment: Added a comment to explain the rationale.

Code under review:
public void snapshotState(StateSnapshotContext context) throws Exception {
		super.snapshotState(context);

		ListState<StreamElement> partitionableState =
			getOperatorStateBackend().getListState(new ListStateDescriptor<>(STATE_NAME, inStreamElementSerializer));
		partitionableState.clear();

		try {
			partitionableState.addAll(queue.values());

			
			if (pendingStreamElement != null) {
				partitionableState.add(pendingStreamElement);
			}
		} catch (Exception e) {
			partitionableState.clear();

			throw new Exception("Could not add stream element queue entries to operator state " +
				"backend of operator " + getOperatorName() + '.', e);
		}
	}


Revised code:
public void snapshotState(StateSnapshotContext context) throws Exception {
		super.snapshotState(context);

		ListState<StreamElement> partitionableState =
			getOperatorStateBackend().getListState(new ListStateDescriptor<>(STATE_NAME, inStreamElementSerializer));
		partitionableState.clear();

		try {
			partitionableState.addAll(queue.values());
		} catch (Exception e) {
			partitionableState.clear();

			throw new Exception("Could not add stream element queue entries to operator state " +
				"backend of operator " + getOperatorName() + '.', e);
		}
	}
Code review comment: 看了下 commit 记录，c8cadfba 这个 bugfix 的 commit 改到了这个地方，添加了 fileds 字段，直接去掉是否会导致之前修复的 bug 复发呢？

Code under review:
public JiraIssue getIssues(String issuesId) {
        LogUtil.info("getIssues: " + issuesId);
        ResponseEntity<String> responseEntity;
        responseEntity = restTemplate.exchange(getBaseUrl() + "/issue/" + issuesId, HttpMethod.GET, getAuthHttpEntity(), String.class);
        return  (JiraIssue) getResultForObject(JiraIssue.class, responseEntity);
    }

Line commented on: responseEntity = restTemplate.exchange(getBaseUrl() + "/issue/" + issuesId, HttpMethod.GET, getAuthHttpEntity(), String.class);

Revised code:
public JiraIssue getIssues(String issuesId) {
        LogUtil.info("getIssues: " + issuesId);
        ResponseEntity<String> responseEntity;
        responseEntity = restTemplate.exchange(getBaseUrl() + "/issue/" + issuesId, HttpMethod.GET, getAuthHttpEntity(), String.class);
        return  (JiraIssue) getResultForObject(JiraIssue.class, responseEntity);
    }
Code review comment: What does this validation get us actually? What vector are we protecting against here?

Code under review:
private String resolve(URL from, Path to) throws IOException {
    if (from.toString().startsWith(GITHUB_DOWNLOAD_PREFIX)) {
      URL shaSumReference = new URL(from + "." + SHA512_EXT);
      validateShaSum512(shaSumReference, from);
    }

    BiConsumer<URL, Path> downloadFn = PrismLocator::download;
    if (from.getPath().endsWith(ZIP_EXT)) {
      downloadFn = PrismLocator::unzip;
    }
    downloadFn.accept(from, to);

    Files.setPosixFilePermissions(to, PERMS);

    return to.toString();
  }

Line commented on: validateShaSum512(shaSumReference, from);

Revised code:
private String resolve(URL from, Path to) throws IOException {
    BiConsumer<URL, Path> downloadFn = PrismLocator::download;
    if (from.getPath().endsWith(ZIP_EXT)) {
      downloadFn = PrismLocator::unzip;
    }
    downloadFn.accept(from, to);

    Files.setPosixFilePermissions(to, PERMS);

    return to.toString();
  }
Code review comment: this doesn't seem right, why does !valuesCached indicate there is nothing to delete in windmill?

Code under review:
public void remove(K key) {
      final Object structuralKey = keyCoder.structuralValue(key);
      KeyState keyState = keyStateMap.computeIfAbsent(structuralKey, k -> new KeyState(key));
      if (keyState.existence == KeyExistence.KNOWN_NONEXISTENT
          || (allKeysKnown && keyState.existence == KeyExistence.UNKNOWN_EXISTENCE)) {
        return;
      }
      if (!keyState.valuesCached || (keyState.valuesCached && keyState.valuesSize > 0)) {
        
        hasLocalRemovals = true;
        keyState.removedLocally = true;
        keyState.values = new ConcatIterables<>();
        keyState.valuesSize = 0;
        keyState.existence = KeyExistence.KNOWN_NONEXISTENT;
      } else {
        
        keyStateMap.remove(structuralKey);
      }
      if (!keyState.localAdditions.isEmpty()) {
        keyState.localAdditions = Lists.newArrayList();
      }
      keyState.valuesCached = true;
    }


Revised code:
public void remove(K key) {
      if (localRemovals.add(key)) {
        cachedValues.remove(key);
        localAdditions.remove(key);
      }
    }
Code review comment: We have `subscription.request(n)` when downstream request, do we still need to `request(1L)` here?

Code under review:
public void onNext(EventData eventData) {
            updateOrPublishBatch(eventData, false);
            eventSink.emitNext(1L, Sinks.EmitFailureHandler.FAIL_FAST);

            final long left = REQUESTED.get(this);
            if (left > 0) {
                subscription.request(1L);
            }
        }

Line commented on: subscription.request(1L);

Revised code:
public void onNext(EventData eventData) {
            updateOrPublishBatch(eventData, false);

            eventSink.emitNext(1L, Sinks.EmitFailureHandler.FAIL_FAST);

            
            
            
            final long left = REQUESTED.get(this);
            if (left > 0) {
                subscription.request(1L);
            }
        }
Code review comment: There are many other places in the same place is without error cause. Should I also need to include the error cause in these places?

Code under review:
public E previous() {
            int i = this.nextIndex - 1;
            if (i < 0) {
                logger.logAndThrow(new NoSuchElementException());
                return null;
            } else if (i >= items.size()) {
                logger.logAndThrow(new ConcurrentModificationException());
                return null;
            } else {
                try {
                    this.nextIndex = i;
                    this.lastRetIndex = i;
                    return items.get(this.lastRetIndex);
                } catch (IndexOutOfBoundsException ex) {
                    logger.logAndThrow(new ConcurrentModificationException());
                    return null;
                }
            }
        }

Line commented on: logger.logAndThrow(new ConcurrentModificationException());

Revised code:
public E previous() {
            int i = this.nextIndex - 1;
            if (i < 0) {
                throw logger.logExceptionAsError(new NoSuchElementException());
            } else if (i >= items.size()) {
                throw logger.logExceptionAsError(new ConcurrentModificationException());
            } else {
                try {
                    this.nextIndex = i;
                    this.lastRetIndex = i;
                    return items.get(this.lastRetIndex);
                } catch (IndexOutOfBoundsException ex) {
                    throw logger.logExceptionAsError(new ConcurrentModificationException(ex));
                }
            }
        }
Code review comment: Yes that was my intent: have it reproducible without changing anything by just checking out the particular commit that failed on AZP.  I'm double-checking that `EnvironmentInformation.getGitCommitId()` works as expected or try a different approach to inject commit id.

Code under review:
public static PseudoRandomValueSelector create(Object entryPointSeed) {
		final long commitSeed = new BigInteger(EnvironmentInformation.getGitCommitId(), 16).hashCode();
		final long combinedSeed = commitSeed << 32 | entryPointSeed.hashCode();
		final Random random = new Random(combinedSeed);
		return new PseudoRandomValueSelector(random::nextInt);
	}

Line commented on: final long combinedSeed = commitSeed << 32 | entryPointSeed.hashCode();

Revised code:
public static PseudoRandomValueSelector create(Object entryPointSeed) {
        final long combinedSeed = GLOBAL_SEED | entryPointSeed.hashCode();
        final Random random = new Random(combinedSeed);
        return new PseudoRandomValueSelector(random::nextInt);
    }
Code review comment: Lets make this method call the other `createObjectValue`, that way we can remove most of the body in this method. see default parameter pattern here : https://www.baeldung.com/java-default-parameters-method-overloading

Code under review:
public static ObjectValue createObjectValue(BPackage packageId, String objectTypeName, Object... fieldValues) {
        ValueCreator valueCreator = ValueCreator.getValueCreator(packageId.toString());
        Object[] fields = new Object[fieldValues.length * 2];
        Strand currentStrand = getStrand();
        
        for (int i = 0, j = 0; i < fieldValues.length; i++) {
            fields[j++] = fieldValues[i];
            fields[j++] = true;
        }
        return valueCreator.createObjectValue(objectTypeName, getScheduler(currentStrand), currentStrand, null, fields);
    }

Line commented on: return valueCreator.createObjectValue(objectTypeName, getScheduler(currentStrand), currentStrand, null, fields);

Revised code:
public static ObjectValue createObjectValue(BPackage packageId, String objectTypeName, Object... fieldValues) {
        return createObjectValue(packageId, objectTypeName, getStrand(), fieldValues);
    }
Code review comment: @mcruzdev you should be able to use something like this: https://vertx.io/docs/apidocs/io/vertx/core/http/HttpServerResponse.html#send-io.vertx.core.streams.ReadStream-

Code under review:
private byte[] getClasspathResourceContent(String name) {
        String resourceName = GeneratedStaticResourcesRecorder.META_INF_RESOURCES + name;
        URL resource = getClassLoader().getResource(resourceName);
        if (resource == null) {
            LOG.warnf("The resource '%s' does not exist on classpath", resourceName);
            return null;
        }
        try {
            try (InputStream inputStream = resource.openStream()) {
                return inputStream.readAllBytes();
            }
        } catch (IOException e) {
            LOG.error("Error while reading file from Classpath for path " + resourceName, e);
            return null;
        }
    }

Line commented on: return inputStream.readAllBytes();

Revised code:
private byte[] getClasspathResourceContent(String name) {
        String resourceName = GeneratedStaticResourcesRecorder.META_INF_RESOURCES + name;
        URL resource = getClassLoader().getResource(resourceName);
        if (resource == null) {
            LOG.warnf("The resource '%s' does not exist on classpath", resourceName);
            return null;
        }
        try {
            try (InputStream inputStream = resource.openStream()) {
                return inputStream.readAllBytes();
            }
        } catch (IOException e) {
            LOG.error("Error while reading file from Classpath for path " + resourceName, e);
            return null;
        }
    }
Code review comment: according to https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#timestamp, we support 3 types of Timestamp in PARQUET(MILLIS(int64), MICROS(int64) and NANOS(int96)).

Code under review:
public SqlTimestamp getTimestamp(int rowId, int colId, int precision) {
		if (isNullAt(rowId, colId)) {
			return null;
		}

		if (SqlTimestamp.isCompact(precision)) {
			return SqlTimestamp.fromEpochMillis(getLong(rowId, colId));
		} else {
			byte[] bytes = getBytes(rowId, colId);
			assert bytes.length == 12;
			long l = 0;
			for (int i = 0; i < 8; i++) {
				l <<= 8;
				l |= (bytes[i] & (0xff));
			}
			int n = 0;
			for (int i = 8; i < 12; i++) {
				n <<= 8;
				n |= (bytes[i] & (0xff));
			}
			return SqlTimestamp.fromEpochMillis(l, n);
		}
	}

Line commented on: if (SqlTimestamp.isCompact(precision)) {

Revised code:
public SqlTimestamp getTimestamp(int rowId, int colId, int precision) {
		return ((TimestampColumnVector) (columns[colId])).getTimestamp(rowId, precision);
	}
Code review comment: I'm wondering whether it's possible that different key has different value types. If that's the case, how can you create different type of sketch from your init.perkey API?

Code under review:
public void testMergePartialPerKey() {
    PCollection<KV<String, byte[]>> result =
        p.apply(
                Create.of(
                    KV.of("k1", INTS1_SKETCH),
                    KV.of("k2", STRINGS_SKETCH),
                    KV.of("k1", INTS2_SKETCH)))
            .apply(HllCount.MergePartial.perKey());

    PAssert.that(result)
        .containsInAnyOrder(
            Arrays.asList(KV.of("k1", INTS1_INTS2_SKETCH), KV.of("k2", STRINGS_SKETCH)));
    p.run();
  }

Line commented on: KV.of("k1", INTS1_SKETCH),

Revised code:
public void testMergePartialPerKey() {
    PCollection<KV<String, byte[]>> result =
        p.apply(
                Create.of(
                    KV.of("k1", INTS1_SKETCH),
                    KV.of("k2", STRINGS_SKETCH),
                    KV.of("k1", INTS2_SKETCH)))
            .apply(HllCount.MergePartial.perKey());

    PAssert.that(result)
        .containsInAnyOrder(
            Arrays.asList(KV.of("k1", INTS1_INTS2_SKETCH), KV.of("k2", STRINGS_SKETCH)));
    p.run();
  }
Code review comment: I don't understand it how is it working right now. Where are the non last buffers recycled? And why do you have to handle the last buffer differently? As I mentioned before, I think: > The ownership of the buffers returned from the iterator should belong to the caller of next() method.  so buffers' ownership should be handed over, and owner should be always responsible to recycle it when it's done using it. For in memory collections, all of the remaining buffers should be recycled via closing the iterator (as he would be the owner of not yet returned buffers).  I guess we are avoiding memory leaks right now, only because the returned Buffers are not pooled and using simple `FreeingBufferRecycler`? If so, that's not how buffers should be used and can brake if someone else would pass buffers with a different recycler.

Code under review:
public void close() throws Exception {
		closeAll(stream, file::release, () -> buffersToClose.forEach(Buffer::recycleBuffer));
	}

Line commented on: closeAll(stream, file::release, () -> buffersToClose.forEach(Buffer::recycleBuffer));

Revised code:
public void close() throws Exception {
		closeAll(stream, file::release);
	}
Code review comment: Sorry to trouble you, but since only the `class` case is covered can you add a `TODO` note here explaining that we should support `@JsonDeserialize` on `methods`, `fields` etc.? That way someone eager to  contribute when looking through the code can pick this up potentially

Code under review:
void register() {
        addReflectiveClass(true, false,
                "com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector",
                "com.fasterxml.jackson.databind.ser.std.SqlDateSerializer");

        IndexView index = combinedIndexBuildItem.getIndex();

        Collection<AnnotationInstance> pojoBuilderInstances = index.getAnnotations(JSON_DESERIALIZE);
        for (AnnotationInstance pojoBuilderInstance : pojoBuilderInstances) {
            addReflectiveClassInheritanceTree(pojoBuilderInstance.target().asClass());

            AnnotationValue annotationValue = pojoBuilderInstance.value(JSON_DESERIALIZE_FIELD_BUILDER);
            if (null != annotationValue && AnnotationValue.Kind.CLASS.equals(annotationValue.kind())) {
                DotName builderClassName = annotationValue.asClass().name();
                if (!BUILDER_VOID.equals(builderClassName)) {
                    ClassInfo builderClass = combinedIndexBuildItem.getIndex().getClassByName(builderClassName);
                    addReflectiveClassInheritanceTree(builderClass);
                }
            }
        }
    }

Line commented on: addReflectiveClassInheritanceTree(pojoBuilderInstance.target().asClass());

Revised code:
void register() {
        addReflectiveClass(true, false,
                "com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector",
                "com.fasterxml.jackson.databind.ser.std.SqlDateSerializer");

        IndexView index = combinedIndexBuildItem.getIndex();

        
        
        
        
        

        Collection<AnnotationInstance> pojoBuilderInstances = index.getAnnotations(JSON_DESERIALIZE);
        for (AnnotationInstance pojoBuilderInstance : pojoBuilderInstances) {
            if (AnnotationTarget.Kind.CLASS.equals(pojoBuilderInstance.target().kind())) {
                addReflectiveHierarchyClass(pojoBuilderInstance.target().asClass().name());

                AnnotationValue annotationValue = pojoBuilderInstance.value("builder");
                if (null != annotationValue && AnnotationValue.Kind.CLASS.equals(annotationValue.kind())) {
                    DotName builderClassName = annotationValue.asClass().name();
                    if (!BUILDER_VOID.equals(builderClassName)) {
                        addReflectiveHierarchyClass(builderClassName);
                    }
                }
            }
        }
    }
Code review comment: > However when the @Authenticated annotation is used, anonymous user can keep sending messages that are bound to fail. Instead, user will receive responses from @OnError.  Yes, and it's up to the endpoint author to decide what to do. For example, you can do something like: ```java @OnError void error(ForbiddenException e, WebSocketConnection conn) {   conn.closeAndAwait(); // and possibly specify the close reason } ```  > Situation is similar in case of authorization, if you know that user will be unauthorized because in the initial handshake for that URI he didn't have these roles, how many times should he be allowed to send a message like you do  Until the connection is closed.  > I am asking because there are things I don't know yet, for example if the client.connect(basicAuth("user", "user"), endUri); is opened for certain URI, can we be sure it is only open for that URI?  I'm not sure I'm following. What do you mean?

Code under review:
public void testEndpoint() {
        try (WSClient client = new WSClient(vertx)) {
            client.connect(basicAuth("admin", "admin"), endUri);
            client.sendAndAwait("hello"); 
            client.sendAndAwait("hi"); 
            client.waitForMessages(2);
            assertEquals(Set.of("24", "forbidden"), Set.copyOf(client.getMessages().stream().map(Object::toString).toList()));
        }
        try (WSClient client = new WSClient(vertx)) {
            client.connect(basicAuth("user", "user"), endUri);
            client.sendAndAwait("hello"); 
            client.sendAndAwait("hi"); 
            client.waitForMessages(2);
            assertEquals(Set.of("42", "forbidden"), Set.copyOf(client.getMessages().stream().map(Object::toString).toList()));
        }
    }

Line commented on: assertEquals(Set.of("42", "forbidden"), Set.copyOf(client.getMessages().stream().map(Object::toString).toList()));

Revised code:
public void testEndpoint() {
        try (WSClient client = new WSClient(vertx)) {
            client.connect(basicAuth("admin", "admin"), endUri);
            client.sendAndAwait("hello"); 
            client.sendAndAwait("hi"); 
            client.waitForMessages(2);
            assertEquals(Set.of("24", "forbidden"), Set.copyOf(client.getMessages().stream().map(Object::toString).toList()));
        }
        try (WSClient client = new WSClient(vertx)) {
            client.connect(basicAuth("user", "user"), endUri);
            client.sendAndAwait("hello"); 
            client.sendAndAwait("hi"); 
            client.waitForMessages(2);
            assertEquals(Set.of("42", "forbidden"), Set.copyOf(client.getMessages().stream().map(Object::toString).toList()));
        }
    }
Code review comment: Could you use one check of CoreUtil.isNullOrEmpty() here?

Code under review:
public AzureKeyCredential update(String key) {
        Objects.requireNonNull(key);
        if (key.isEmpty()) {
            throw logger.logExceptionAsError(new IllegalArgumentException("'key' cannot be empty."));
        }

        this.key = key;
        return this;
    }

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

Revised code:
public AzureKeyCredential update(String key) {
        Objects.requireNonNull(key, "'key' cannot be null.");
        if (key.isEmpty()) {
            throw logger.logExceptionAsError(new IllegalArgumentException("'key' cannot be empty."));
        }

        this.key = key;
        return this;
    }
Code review comment: why not just clear the instantiated contents?

Code under review:
public void clear() {
      contents = ArrayListMultimap.create();
    }

Line commented on: contents = ArrayListMultimap.create();

Revised code:
public void clear() {
    inMemoryState.clear();
  }
Code review comment: It is better to pass serializer here

Code under review:
public byte[] serialize(PendingSplitsCheckpoint<HiveSourceSplit> checkpoint) throws IOException {
		Preconditions.checkArgument(checkpoint.getClass() == ContinuousHivePendingSplitsCheckpoint.class,
				"Only supports %s", ContinuousHivePendingSplitsCheckpoint.class.getName());

		ContinuousHivePendingSplitsCheckpoint hiveCheckpoint = (ContinuousHivePendingSplitsCheckpoint) checkpoint;
		PendingSplitsCheckpoint<HiveSourceSplit> superCP = PendingSplitsCheckpoint.fromCollectionSnapshot(
				hiveCheckpoint.getSplits(), hiveCheckpoint.getAlreadyProcessedPaths());
		byte[] superBytes = superSerDe.serialize(superCP);
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		try (ObjectOutputStream outputStream = new ObjectOutputStream(byteArrayOutputStream)) {
			outputStream.writeInt(superBytes.length);
			outputStream.write(superBytes);
			outputStream.writeObject(hiveCheckpoint.getCurrentReadOffset());
			outputStream.writeInt(hiveCheckpoint.getSeenPartitions().size());
			for (List<String> partition : hiveCheckpoint.getSeenPartitions()) {
				outputStream.writeObject(partition);
			}
		}
		return byteArrayOutputStream.toByteArray();
	}

Line commented on: outputStream.writeObject(hiveCheckpoint.getCurrentReadOffset());

Revised code:
public byte[] serialize(PendingSplitsCheckpoint<HiveSourceSplit> checkpoint) throws IOException {
		Preconditions.checkArgument(checkpoint.getClass() == ContinuousHivePendingSplitsCheckpoint.class,
				"Only supports %s", ContinuousHivePendingSplitsCheckpoint.class.getName());

		ContinuousHivePendingSplitsCheckpoint hiveCheckpoint = (ContinuousHivePendingSplitsCheckpoint) checkpoint;
		PendingSplitsCheckpoint<HiveSourceSplit> superCP = PendingSplitsCheckpoint.fromCollectionSnapshot(
				hiveCheckpoint.getSplits(), hiveCheckpoint.getAlreadyProcessedPaths());
		byte[] superBytes = superSerDe.serialize(superCP);
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

		try (DataOutputViewStreamWrapper outputWrapper = new DataOutputViewStreamWrapper(byteArrayOutputStream)) {
			outputWrapper.writeInt(superBytes.length);
			outputWrapper.write(superBytes);
			readOffsetSerDe.serialize(hiveCheckpoint.getCurrentReadOffset(), outputWrapper);
			outputWrapper.writeInt(hiveCheckpoint.getSeenPartitionsSinceOffset().size());
			for (List<String> partition : hiveCheckpoint.getSeenPartitionsSinceOffset()) {
				partitionSerDe.serialize(partition, outputWrapper);
			}
		}
		return byteArrayOutputStream.toByteArray();
	}
Code review comment: I see couple of issues/potential issues here: 1. I'm not sure if I like the `randomTriggered` state field and how it's value affects the logic in different methods. It took quite some time to understand two successive `randomEmit` one after another work correctly (and how they actually work), because `requestNewBufferBuilder` behaves differently for `randomTriggered = true`.  2. I'm not sure, but I think that `BroadcastRecordWriter`'s logic would be actually easier to follow, if it didn't have `bufferBuilders` array, but single `bufferBuilder` field. Maybe it would be worth creating `AbstractRecordWriter` without `bufferBuilders`/`bufferBuilder` field and then have two concrete implementations of `RecordWriter` and `BroadcastRecordWriter` with one two different implementations? 3. `LatencyMarker`s are a bit broken here, since effectively they will be flushed on the very first next emit following the `LatencyMarker`, so they do not measure the actual latency. This might not be the critical issue, but it would be good to have correct metric for that.  Point 1. is not that difficult to address (for 1. `randomEmit()` could flush the current buffer, request a new one for one `randomEmit()` and immediately finish it, so that this special handling of `randomTriggered = true` wouldn't leak outside of the `randomEmit()` method).  Point 2. Might be not worth doing so.  Point 3. is the more problematic one I guess.   a) One way to deal with it, would be to broadcast `LatencyMarker`. Easy to do, but with huge number of output channels and multiple broadcasts channels one after another, would result with gigantic cascade/avalanche of the `LatencyMarkers`.  b) Another idea would be to broadcast the `LatencyMarker` to everybody, but add some kind of marker to let the receiver know, that it should ignore it, because it was targeted to someone else. c) Maybe there are other solutions that I haven't thought about?

Code under review:
public void flushTargetPartition(int targetChannel) {
		if (randomTriggered) {
			super.flushTargetPartition(targetChannel);
		} else {
			flushAll();
		}
	}

Line commented on: if (randomTriggered) {

Revised code:
public void flushTargetPartition(int targetChannel) {
		if (randomTriggered) {
			super.flushTargetPartition(targetChannel);
		} else {
			flushAll();
		}
	}
Code review comment: Does it make sense to return internal server error in this case?

Code under review:
public CloseReason closeReason() {
        WebSocketBase ws = webSocket();
        if (ws.isClosed()) {
            Short code = ws.closeStatusCode();
            if (code == null) {
                
                return CloseReason.INTERNAL_SERVER_ERROR;
            }
            return new CloseReason(code, ws.closeReason());
        }
        return null;
    }

Line commented on: return CloseReason.INTERNAL_SERVER_ERROR;

Revised code:
public CloseReason closeReason() {
        WebSocketBase ws = webSocket();
        if (ws.isClosed()) {
            Short code = ws.closeStatusCode();
            if (code == null) {
                
                return CloseReason.INTERNAL_SERVER_ERROR;
            }
            return new CloseReason(code, ws.closeReason());
        }
        return null;
    }
Code review comment: I will make a task for myself. Would you be able to find any existing API which is doing the same? Is it custom code in Java or does it require the TypeSpec change?

Code under review:
public void translateWithNoTranslateTag() {
        ArrayList<String> targetLanguages = new ArrayList<>();
        targetLanguages.add("en");

        ArrayList<InputTextItem> content = new ArrayList<>();
        content.add(new InputTextItem("<span class=notranslate>今天是怎么回事是</span>非常可怕的"));

        List<TranslatedTextItem> response = getTranslationClient().translate(targetLanguages, content, null, "zh-Hans", TextType.HTML, null, null, null, null, null, null, null, null, null);

        assertEquals(1, response.get(0).getTranslations().size());
        assertTrue(response.get(0).getTranslations().get(0).getText().contains("今天是怎么回事是"));
    }

Line commented on: List<TranslatedTextItem> response = getTranslationClient().translate(targetLanguages, content, null, "zh-Hans", TextType.HTML, null, null, null, null, null, null, null, null, null);

Revised code:
public void translateWithNoTranslateTag() {
        ArrayList<String> targetLanguages = new ArrayList<>();
        targetLanguages.add("en");

        ArrayList<InputTextItem> content = new ArrayList<>();
        content.add(new InputTextItem("<span class=notranslate>今天是怎么回事是</span>非常可怕的"));

        List<TranslatedTextItem> response = getTranslationClient().translate(targetLanguages, content, null, "zh-Hans", TextType.HTML, null, null, null, null, null, null, null, null, null);

        assertEquals(1, response.get(0).getTranslations().size());
        assertTrue(response.get(0).getTranslations().get(0).getText().contains("今天是怎么回事是"));
    }
Code review comment: What this the function of getOtherColumns?

Code under review:
public void loadColumnProperties(final Map<String, Object> context) {
        List<Map<String, Object>> otherColumns = getOtherColumns(context);
        List<Map<String, Object>> allColumns = executeByTemplate(connection, context, "columns/12_plus/properties.ftl");
        for (Map<String, Object> each : allColumns) {
            for (Map<String, Object> otherCol : otherColumns) {
                if (each.get("name").equals(otherCol.get("name"))) {
                    each.put(getInheritedFromTableOrType(context), otherCol.get("inheritedfrom"));
                }
            }
        }
        if (!allColumns.isEmpty()) {
            Map<String, Collection<String>> editTypes = getEditTypes(allColumns);
            for (Map<String, Object> each : allColumns) {
                columnFormatter(each, editTypes.getOrDefault(each.get("atttypid").toString(), new LinkedList<>()));
            }
        }
        context.put("columns", allColumns);
    }

Line commented on: List<Map<String, Object>> otherColumns = getOtherColumns(context);

Revised code:
public void loadColumnProperties(final Map<String, Object> context) {
        Collection<Map<String, Object>> typeAndInheritedColumns = getTypeAndInheritedColumns(context);
        Collection<Map<String, Object>> allColumns = executeByTemplate(context, "columns/12_plus/properties.ftl");
        for (Map<String, Object> each : allColumns) {
            for (Map<String, Object> column : typeAndInheritedColumns) {
                if (each.get("name").equals(column.get("name"))) {
                    each.put(getInheritedFromTableOrType(context), column.get("inheritedfrom"));
                }
            }
        }
        if (!allColumns.isEmpty()) {
            Map<String, Collection<String>> editTypes = getEditTypes(allColumns);
            for (Map<String, Object> each : allColumns) {
                columnFormatter(each, editTypes.getOrDefault(each.get("atttypid").toString(), new LinkedList<>()));
            }
        }
        context.put("columns", allColumns);
    }
Code review comment: I think the comment is not right here, we should use `legacy` mode.

Code under review:
public void testLegacyRestoreModeParsingLongOption() throws Exception {
        
        testRestoreMode("--restoreMode", "legacy", RestoreMode.LEGACY);
    }


Revised code:
public void testLegacyRestoreModeParsingLongOption() throws Exception {
        testRestoreMode("--restoreMode", "legacy", RestoreMode.LEGACY);
    }
Code review comment: To me these checks (especially the longer ones) would look better as [guard statements](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html) instead of `switches`.

Code under review:
private static Object convertIntStrict(Integer value, Schema.FieldType fieldType) {
    switch (fieldType.getTypeName()) {
      case INT32:
        return value;

      default:
        throw new RuntimeException("Can't convert 'int' to " + fieldType.getTypeName());
    }
  }

Line commented on: case INT32:

Revised code:
private static Object convertIntStrict(Integer value, Schema.FieldType fieldType) {
    checkTypeName(fieldType.getTypeName(), Schema.TypeName.INT32, "int");
    return value;
  }
Code review comment: To make it independent of `TestLogger` we could use [RunListener](https://junit.org/junit4/javadoc/4.12/org/junit/runner/notification/RunListener.html) and then have a singleton listener to fetch the name. However, I didn't go fully into this direction as it's quite a bit of fiddling in junit4 and I hope to eventually migrate to junit 5. Then I'd check if it can be done in a better way.

Code under review:
private static void randomize(Configuration conf) {
        if (Randomization) {
            final String testName = TestNameProvider.getCurrentTestName();
            final PseudoRandomValueSelector valueSelector =
                    PseudoRandomValueSelector.create(testName != null ? testName : "unknown");
            valueSelector.select(conf, ExecutionCheckpointingOptions.ENABLE_UNALIGNED, true, false);
        }
    }

Line commented on: PseudoRandomValueSelector.create(testName != null ? testName : "unknown");

Revised code:
private static void randomize(Configuration conf) {
        if (RANDOMIZE_CHECKPOINTING_CONFIG) {
            final String testName = TestNameProvider.getCurrentTestName();
            final PseudoRandomValueSelector valueSelector =
                    PseudoRandomValueSelector.create(testName != null ? testName : "unknown");
            valueSelector.select(conf, ExecutionCheckpointingOptions.ENABLE_UNALIGNED, true, false);
        }
    }
Code review comment: How does the modification to the serialization affect backwards compatibility?

Code under review:
public void serialize(NFA<T> record, DataOutputView target) throws IOException {
			serializeStates(record.states, target);
			target.writeLong(record.windowTime);
			target.writeBoolean(record.handleTimeout);
			
			sharedBufferSerializer.serialize(record.eventSharedBuffer, target);

			target.writeInt(record.computationStates.size());

			StringSerializer stateNameSerializer = StringSerializer.INSTANCE;
			LongSerializer timestampSerializer = LongSerializer.INSTANCE;
			DeweyNumber.DeweyNumberSerializer versionSerializer = new DeweyNumber.DeweyNumberSerializer();

			for (ComputationState<T> computationState: record.computationStates) {
				stateNameSerializer.serialize(computationState.getState().getName(), target);
				stateNameSerializer.serialize(computationState.getPreviousState() == null
						? null : computationState.getPreviousState().getName(), target);

				timestampSerializer.serialize(computationState.getTimestamp(), target);
				versionSerializer.serialize(computationState.getVersion(), target);
				timestampSerializer.serialize(computationState.getStartTimestamp(), target);
				target.writeInt(computationState.getCounter());

				if (computationState.getEvent() == null) {
					target.writeBoolean(false);
				} else {
					target.writeBoolean(true);
					eventSerializer.serialize(computationState.getEvent(), target);
				}
			}
		}

Line commented on: target.writeInt(computationState.getCounter());

Revised code:
public void serialize(NFA<T> record, DataOutputView target) throws IOException {
			serializeStates(record.states, target);
			target.writeLong(record.windowTime);
			target.writeBoolean(record.handleTimeout);
			
			sharedBufferSerializer.serialize(record.eventSharedBuffer, target);

			target.writeInt(record.computationStates.size());

			StringSerializer stateNameSerializer = StringSerializer.INSTANCE;
			LongSerializer timestampSerializer = LongSerializer.INSTANCE;
			DeweyNumber.DeweyNumberSerializer versionSerializer = new DeweyNumber.DeweyNumberSerializer();

			for (ComputationState<T> computationState: record.computationStates) {
				stateNameSerializer.serialize(computationState.getState().getName(), target);
				stateNameSerializer.serialize(computationState.getPreviousState() == null
						? null : computationState.getPreviousState().getName(), target);

				timestampSerializer.serialize(computationState.getTimestamp(), target);
				versionSerializer.serialize(computationState.getVersion(), target);
				timestampSerializer.serialize(computationState.getStartTimestamp(), target);
				target.writeInt(computationState.getCounter());

				if (computationState.getEvent() == null) {
					target.writeBoolean(false);
				} else {
					target.writeBoolean(true);
					eventSerializer.serialize(computationState.getEvent(), target);
				}
			}
		}