muttakin2301/ccr2000 huggingface dataset:
Code review comment: Not totally understanding this, would you please kindly talk about it more clearly?

Code under review:
public void testIODirectoryNotWritable() throws Exception {
		File nonWritable = tempFolder.newFolder();
		Assume.assumeTrue("Cannot create non-writable temporary file directory. Skipping test.",
			nonWritable.setWritable(false, false));

		try {
			Configuration cfg = new Configuration();
			cfg.setString(CoreOptions.TMP_DIRS, nonWritable.getAbsolutePath());

			try {
				TaskManagerRunner.startTaskManager(
					cfg,
					ResourceID.generate(),
					rpcService,
					mock(HighAvailabilityServices.class),
					mock(HeartbeatServices.class),
					NoOpMetricRegistry.INSTANCE,
					mock(BlobCacheService.class),
					false,
					mock(FatalErrorHandler.class));

				fail("Should fail synchronously with an exception");
			} catch (IOException e) {
				
			}
		} catch (Exception e) {
			e.printStackTrace();
			fail(e.getMessage());
		} finally {
			
			nonWritable.setWritable(true, false);
			try {
				FileUtils.deleteDirectory(nonWritable);
			} catch (IOException e) {
				
			}
		}
	}

Line commented on: mock(FatalErrorHandler.class));

Revised code:
public void testIODirectoryNotWritable() throws Exception {
		File nonWritable = tempFolder.newFolder();
		Assume.assumeTrue("Cannot create non-writable temporary file directory. Skipping test.",
			nonWritable.setWritable(false, false));

		try {
			Configuration cfg = new Configuration();
			cfg.setString(CoreOptions.TMP_DIRS, nonWritable.getAbsolutePath());

			try {

				startTaskManager(
					cfg,
					rpcService,
					highAvailabilityServices);

				fail("Should fail synchronously with an IOException");
			} catch (IOException e) {
				
			}
		} finally {
			
			nonWritable.setWritable(true, false);
			try {
				FileUtils.deleteDirectory(nonWritable);
			} catch (IOException e) {
				
			}
		}
	}
Code review comment: Do we need this codepath at all - can we just always use path from line 163?  It also looks like this method is called quite often, so it'd be good to avoid a FileSystems.match() call every time it's called.

Code under review:
private ResourceId getJobDirResourceId(String stagingSessionToken) throws IOException {
    ResourceId baseResourceId;
    StagingSessionToken parsedToken = decodeStagingSessionToken(stagingSessionToken);
    try {
      baseResourceId = FileSystems.matchSingleFileSpec(parsedToken.getBasePath())
          .resourceId();
    } catch (FileNotFoundException fne) {
      
      baseResourceId = FileSystems
          .matchNewResource(parsedToken.getBasePath(), true /* isDirectory */);
    }
    
    return baseResourceId
        .resolve(parsedToken.getSessionId(), StandardResolveOptions.RESOLVE_DIRECTORY);
  }

Line commented on: baseResourceId = FileSystems.matchSingleFileSpec(parsedToken.getBasePath())

Revised code:
private ResourceId getJobDirResourceId(String stagingSessionToken) throws Exception {
    ResourceId baseResourceId;
    StagingSessionToken parsedToken = decodeStagingSessionToken(stagingSessionToken);
    
    baseResourceId = FileSystems
        .matchNewResource(parsedToken.getBasePath(), true /* isDirectory */);
    
    return baseResourceId
        .resolve(parsedToken.getSessionId(), StandardResolveOptions.RESOLVE_DIRECTORY);
  }
Code review comment: Nit: spelling/grammar  ```suggestion           // to Calc nodes before merging with other Project/Filter/Calc nodes. Thus we should not add ```

Code under review:
private static RuleSet[] modifyRuleSetsForZetaSql(RuleSet[] ruleSets) {
    RuleSet[] ret = new RuleSet[ruleSets.length];
    for (int i = 0; i < ruleSets.length; i++) {
      ImmutableList.Builder<RelOptRule> bd = ImmutableList.builder();
      for (RelOptRule rule : ruleSets[i]) {
        
        
        if (rule instanceof JoinCommuteRule) {
          continue;
        } else if (rule instanceof FilterCalcMergeRule || rule instanceof ProjectCalcMergeRule) {
          
          
          
          
          
          continue;
        } else if (rule instanceof BeamCalcRule) {
          bd.add(BeamZetaSqlCalcRule.INSTANCE);
        } else {
          bd.add(rule);
        }
      }
      ret[i] = RuleSets.ofList(bd.build());
    }
    return ret;
  }


Revised code:
private static RuleSet[] modifyRuleSetsForZetaSql(RuleSet[] ruleSets) {
    RuleSet[] ret = new RuleSet[ruleSets.length];
    for (int i = 0; i < ruleSets.length; i++) {
      ImmutableList.Builder<RelOptRule> bd = ImmutableList.builder();
      for (RelOptRule rule : ruleSets[i]) {
        
        
        if (rule instanceof JoinCommuteRule) {
          continue;
        } else if (rule instanceof FilterCalcMergeRule || rule instanceof ProjectCalcMergeRule) {
          
          
          
          
          
          
          continue;
        } else if (rule instanceof BeamCalcRule) {
          bd.add(BeamZetaSqlCalcRule.INSTANCE);
        } else {
          bd.add(rule);
        }
      }
      ret[i] = RuleSets.ofList(bd.build());
    }
    return ret;
  }
Code review comment: Something like this  ````java @ProcessElement public void processElement(@Element T input, ProcessContext context) {   try {     publishMessage(input);   } catch (JMSException | JmsIOException | IOException | InterruptedException exception) {     LOG.error("Error while publishing the message", exception);     context.output(this.failedMessagesTags, input);     if (exception instanceof InterruptedException) {       Thread.currentThread().interrupt();     }   } }  private void publishMessage(T input)     throws JMSException, JmsIOException, IOException, InterruptedException {   Sleeper sleeper = Sleeper.DEFAULT;   BackOff backoff = checkStateNotNull(retryBackOff).backoff();   while (true) {     try {       this.jmsConnection.publishMessage(input);       break;     } catch (JMSException | JmsIOException exception) {       if (!BackOffUtils.next(sleeper, backoff)) {         throw exception;       } else {         publicationRetries.inc();       }     }   } } ````

Code under review:
public void processElement(@Element T input, ProcessContext context) {
        try {
          publishMessage(input, context);
        } catch (IOException | InterruptedException exception) {
          LOG.error("Error while publishing the message", exception);
          context.output(this.failedMessagesTags, input);
          if (exception instanceof InterruptedException) {
            Thread.currentThread().interrupt();
          }
        }
      }

Line commented on: LOG.error("Error while publishing the message", exception);

Revised code:
public void processElement(@Element T input, ProcessContext context) {
        try {
          publishMessage(input);
        } catch (JMSException | JmsIOException | IOException | InterruptedException exception) {
          LOG.error("Error while publishing the message", exception);
          context.output(this.failedMessagesTags, input);
          if (exception instanceof InterruptedException) {
            Thread.currentThread().interrupt();
          }
        }
      }
Code review comment: Java `HashMap` and SQL MAP allow null keys and null values. I will add a test for this in `testSerDeMultiRowsWithNullValues`.

Code under review:
private DeserializationRuntimeConverter createMapConverter(MapType mapType) {
		LogicalType keyType = mapType.getKeyType();
		if (!LogicalTypeChecks.hasFamily(keyType, LogicalTypeFamily.CHARACTER_STRING)) {
			throw new UnsupportedOperationException(
				"JSON format doesn't support non-string as key type of map. " +
				"The map type is: " + mapType.asSummaryString());
		}
		final DeserializationRuntimeConverter keyConverter = createConverter(keyType);
		final DeserializationRuntimeConverter valueConverter = createConverter(mapType.getValueType());

		return jsonNode -> {
			Iterator<Map.Entry<String, JsonNode>> fields = jsonNode.fields();
			Map<Object, Object> result = new HashMap<>();
			while (fields.hasNext()) {
				Map.Entry<String, JsonNode> entry = fields.next();
				Object key = keyConverter.convert(TextNode.valueOf(entry.getKey()));
				Object value = valueConverter.convert(entry.getValue());
				result.put(key, value);
			}
			return new GenericMapData(result);
		};
	}

Line commented on: result.put(key, value);

Revised code:
private DeserializationRuntimeConverter createMapConverter(MapType mapType) {
		LogicalType keyType = mapType.getKeyType();
		if (!LogicalTypeChecks.hasFamily(keyType, LogicalTypeFamily.CHARACTER_STRING)) {
			throw new UnsupportedOperationException(
				"JSON format doesn't support non-string as key type of map. " +
				"The map type is: " + mapType.asSummaryString());
		}
		final DeserializationRuntimeConverter keyConverter = createConverter(keyType);
		final DeserializationRuntimeConverter valueConverter = createConverter(mapType.getValueType());

		return jsonNode -> {
			Iterator<Map.Entry<String, JsonNode>> fields = jsonNode.fields();
			Map<Object, Object> result = new HashMap<>();
			while (fields.hasNext()) {
				Map.Entry<String, JsonNode> entry = fields.next();
				Object key = keyConverter.convert(TextNode.valueOf(entry.getKey()));
				Object value = valueConverter.convert(entry.getValue());
				result.put(key, value);
			}
			return new GenericMapData(result);
		};
	}
Code review comment: counter.get() is not correct here as counter is the number of default action executions, not the number of mails. At the moment, the number of mails processed includes only the poison mail and manual the stop mail. So it would be 2. However, if there are changes in future that some house-keeping mails are generated and processed, one would need to adjust this test assertion. The > 0 proves that the counter is working in general. I can change it to > 1 which is IMO here better than =2.

Code under review:
public void testRunDefaultActionAndMails() throws Exception {
        AtomicBoolean stop = new AtomicBoolean(false);
        AtomicInteger counter = new AtomicInteger();
        MailboxThread mailboxThread =
                new MailboxThread() {
                    @Override
                    public void runDefaultAction(Controller controller) throws Exception {
                        counter.incrementAndGet();
                        if (stop.get()) {
                            controller.allActionsCompleted();
                        } else {
                            Thread.sleep(10L);
                        }
                    }
                };

        MailboxProcessor mailboxProcessor = start(mailboxThread);
        mailboxProcessor.getMailboxExecutor(DEFAULT_PRIORITY).execute(() -> stop.set(true), "stop");
        mailboxThread.join();
        Assert.assertTrue(counter.get() > 0);
        Assert.assertTrue(mailboxProcessor.getNumMailsProcessedCounter().getCount() > 0);
    }

Line commented on: Assert.assertTrue(mailboxProcessor.getNumMailsProcessedCounter().getCount() > 0);

Revised code:
public void testRunDefaultActionAndMails() throws Exception {
        AtomicBoolean stop = new AtomicBoolean(false);
        AtomicInteger counter = new AtomicInteger();
        MailboxThread mailboxThread =
                new MailboxThread() {
                    @Override
                    public void runDefaultAction(Controller controller) throws Exception {
                        counter.incrementAndGet();
                        if (stop.get()) {
                            controller.allActionsCompleted();
                        } else {
                            Thread.sleep(10L);
                        }
                    }
                };

        MailboxProcessor mailboxProcessor = start(mailboxThread);
        mailboxProcessor.getMailboxExecutor(DEFAULT_PRIORITY).execute(() -> stop.set(true), "stop");
        mailboxThread.join();
        assertThat(counter.get(), greaterThan(0));
        assertThat(mailboxProcessor.getNumMailsProcessedCounter().getCount(), greaterThan(0L));
    }
Code review comment: `IntermediateDataSetID` has a param-less ctor I think.

Code under review:
public IntermediateResultPartitionID() {
		this.partitionNum = -1;
		this.intermediateDataSetID = new IntermediateDataSetID(new AbstractID());
	}

Line commented on: this.intermediateDataSetID = new IntermediateDataSetID(new AbstractID());

Revised code:
public IntermediateResultPartitionID() {
		this.partitionNum = -1;
		this.intermediateDataSetID = new IntermediateDataSetID();
	}
Code review comment: This check excludes the decimal value zero (whole set of decimal zero values with different precision) from the set of values covered by the check `bd.abs(MathContext.DECIMAL128).compareTo(MIN_DECIMAL_MAGNITUDE) < 0`.

Code under review:
private static BigDecimal getValidDecimalValue(BigDecimal bd) {
        if (bd.compareTo(DECIMAL_MAX) > 0 || bd.compareTo(DECIMAL_MIN) < 0) {
            throw ErrorCreator.createError(BallerinaErrorReasons.NUMBER_OVERFLOW,
                    BLangExceptionHelper.getErrorDetails(RuntimeErrors.DECIMAL_VALUE_OUT_OF_RANGE));
        } else if (bd.abs(MathContext.DECIMAL128).compareTo(MIN_DECIMAL_MAGNITUDE) < 0 &&
                bd.abs(MathContext.DECIMAL128).compareTo(BigDecimal.ZERO) > 0) {
            return BigDecimal.ZERO;
        }
        return bd;
    }

Line commented on: bd.abs(MathContext.DECIMAL128).compareTo(BigDecimal.ZERO) > 0) {

Revised code:
private static BigDecimal getValidDecimalValue(BigDecimal bd) {
        if (bd.compareTo(DECIMAL_MAX) > 0 || bd.compareTo(DECIMAL_MIN) < 0) {
            throw ErrorCreator.createError(BallerinaErrorReasons.NUMBER_OVERFLOW,
                    BLangExceptionHelper.getErrorDetails(RuntimeErrors.DECIMAL_VALUE_OUT_OF_RANGE));
        } else if (bd.abs(MathContext.DECIMAL128).compareTo(MIN_DECIMAL_MAGNITUDE) < 0 &&
                bd.abs(MathContext.DECIMAL128).compareTo(BigDecimal.ZERO) > 0) {
            return BigDecimal.ZERO;
        }
        return bd;
    }
Code review comment: You are right. Avoiding creating many instances of DataFormat is a big optimization.

Code under review:
private long convertTimestampToMillis(String timestamp) throws ParseException {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    return dateFormat.parse(timestamp).getTime();
  }

Line commented on: SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Revised code:
private long convertTimestampToMillis(String timestamp) throws ParseException {
    return dateFormat.parse(timestamp).getTime();
  }
Code review comment: This is required because we dont have access to the created `LeaderElection`? Shouldn't this use `TestingLeaderElectionService#triggerContenderCleanup`?

Code under review:
public static void teardownClass() throws Exception {
        haService.closeAndCleanupAllData();

        if (rpcService != null) {
            RpcUtils.terminateRpcService(rpcService);
        }
    }

Line commented on: haService.closeAndCleanupAllData();

Revised code:
public static void teardownClass() throws Exception {
        if (rpcService != null) {
            RpcUtils.terminateRpcService(rpcService);
        }
    }
Code review comment: I guess the result is the same but I always favor Objects.equals then I don't have to think too much about NPE (even if in that case it's not the case :p)

Code under review:
DefaultCodestartFileStrategyHandler getSelectedDefaultStrategy() {
        for (CodestartFileStrategy codestartFileStrategy : strategies) {
            if (Objects.equals(codestartFileStrategy.getFilter(), "*")) {
                if (codestartFileStrategy.getHandler() instanceof DefaultCodestartFileStrategyHandler) {
                    return (DefaultCodestartFileStrategyHandler) codestartFileStrategy.getHandler();
                }
                throw new CodestartDefinitionException(
                        codestartFileStrategy.getHandler().name() + " can't be used as '*' file strategy");
            }
        }
        return CodestartFileStrategyHandler.DEFAULT_STRATEGY;
    }

Line commented on: if (Objects.equals(codestartFileStrategy.getFilter(), "*")) {

Revised code:
DefaultCodestartFileStrategyHandler getSelectedDefaultStrategy() {
        for (CodestartFileStrategy codestartFileStrategy : strategies) {
            if (Objects.equals(codestartFileStrategy.getFilter(), "*")) {
                if (codestartFileStrategy.getHandler() instanceof DefaultCodestartFileStrategyHandler) {
                    return (DefaultCodestartFileStrategyHandler) codestartFileStrategy.getHandler();
                }
                throw new CodestartDefinitionException(
                        codestartFileStrategy.getHandler().name() + " can't be used as '*' file strategy");
            }
        }
        return CodestartFileStrategyHandler.DEFAULT_STRATEGY;
    }
Code review comment: Shall we set `symTable.builtinPos` instead since in this case, name is a compiler-generated one?

Code under review:
public BLangNode transform(RequiredParameterNode requiredParameter) {
        BLangSimpleVariable simpleVar = createSimpleVar(requiredParameter.paramName(),
                                                        requiredParameter.typeName(), requiredParameter.annotations());
        simpleVar.pos = getPosition(requiredParameter);
        if (requiredParameter.paramName().isPresent()) {
            simpleVar.name.pos = getPosition(requiredParameter.paramName().get());
        } else if (simpleVar.name.pos == null) {
            
            
            simpleVar.name.pos = simpleVar.pos;
        }
        simpleVar.flagSet.add(Flag.REQUIRED_PARAM);
        return simpleVar;
    }

Line commented on: simpleVar.name.pos = simpleVar.pos;

Revised code:
public BLangNode transform(RequiredParameterNode requiredParameter) {
        BLangSimpleVariable simpleVar = createSimpleVar(requiredParameter.paramName(),
                                                        requiredParameter.typeName(), requiredParameter.annotations());
        simpleVar.pos = getPosition(requiredParameter);
        if (requiredParameter.paramName().isPresent()) {
            simpleVar.name.pos = getPosition(requiredParameter.paramName().get());
        } else if (simpleVar.name.pos == null) {
            
            
            simpleVar.name.pos = symTable.builtinPos;
        }
        simpleVar.flagSet.add(Flag.REQUIRED_PARAM);
        return simpleVar;
    }
Code review comment: This will lose other configs in `configuration`, we can add a private `create(Configuration conf, EnvironmentSettings settings)` method as the basic implementation.

Code under review:
public static TableEnvironmentImpl create(Configuration configuration) {
        return create(EnvironmentSettings.fromConfiguration(configuration));
    }

Line commented on: return create(EnvironmentSettings.fromConfiguration(configuration));

Revised code:
public static TableEnvironmentImpl create(Configuration configuration) {
        return create(EnvironmentSettings.fromConfiguration(configuration), configuration);
    }
Code review comment: feel like the condition should be `lockHolderRequest.locker.equals(this.locker) && !(this.lockType == LockType.READ && lockHolderRequest.lockType == LockType.WRITE)`

Code under review:
boolean isConflict(LockHolder lockHolderRequest) {
        if (lockHolderRequest.locker.equals(this.locker)
                && this.lockType == LockType.WRITE && lockHolderRequest.lockType == LockType.READ) {
            /*
             * If you acquire an exclusive lock first and then request a shared lock, you can successfully acquire the lock.
             * This scenario is generally called "lock downgrade",
             *  but this lock does not actually reduce the original write lock directly to a read lock.
             * In fact, it is still two independent read and write locks, and the two locks still need
             * to be released independently. The actual scenario is that before releasing the write lock,
             * acquire the read lock first, so that there is no gap time to release the lock.
             */
            return false;
        } else {
            return this.lockType.isConflict(lockHolderRequest.getLockType());
        }
    }

Line commented on: if (lockHolderRequest.locker.equals(this.locker)

Revised code:
boolean isConflict(LockHolder lockHolderRequest) {
        return this.lockType.isConflict(lockHolderRequest.getLockType());
    }
Code review comment: Shall we check `future.isSuccess() && cause != null` as in other places?

Code under review:
private static void pingAutomatically(WebSocketControlMessage controlMessage) {
        WebSocketConnection webSocketConnection = controlMessage.getWebSocketConnection();
        webSocketConnection.pong(controlMessage.getPayload()).addListener(future -> {
            Throwable cause = future.cause();
            if (cause != null) {
                ErrorHandlerUtils.printError(cause);
            }
            webSocketConnection.readNextFrame();
        });
    }

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

Revised code:
private static void pingAutomatically(WebSocketControlMessage controlMessage) {
        WebSocketConnection webSocketConnection = controlMessage.getWebSocketConnection();
        webSocketConnection.pong(controlMessage.getPayload()).addListener(future -> {
            Throwable cause = future.cause();
            if (!future.isSuccess() && cause != null) {
                ErrorHandlerUtils.printError(cause);
            }
            webSocketConnection.readNextFrame();
        });
    }
Code review comment: Any doc or evidence to support this behavior(if null, then true)?

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

Line commented on: return true;

Revised code:
public boolean isAllowCrossTenantReplication() {
        if (this.innerModel().allowCrossTenantReplication() == null) {
            return true;
        }
        return this.innerModel().allowCrossTenantReplication();
    }
Code review comment: It seems when a client is CLOSED, it will not start() again. Not sure if we need to make the client reuseable. Or we need to add some comments on closeAsync() API in case they may not release the client after close it?

Code under review:
public Mono<Void> start() {
        if (clientState.get() != WebPubSubClientState.STOPPED) {
            return Mono.error(logger.logExceptionAsError(
                new IllegalStateException("Failed to start. Client is not STOPPED.")));
        }
        return Mono.defer(() -> {
            
            isStoppedByUser.set(false);
            sequenceAckId.clear();

            boolean success = clientState.changeStateOn(WebPubSubClientState.STOPPED, WebPubSubClientState.CONNECTING);
            if (!success) {
                return Mono.error(logger.logExceptionAsError(
                    new IllegalStateException("Failed to start. Client is not STOPPED.")));
            } else {
                return Mono.empty();
            }
        }).then(clientAccessUriProvider.flatMap(uri -> Mono.fromCallable(() -> {
            this.endpoint = new ClientEndpoint();
            ClientEndpointConfig config = ClientEndpointConfig.Builder.create()
                .preferredSubprotocols(Collections.singletonList(webPubSubProtocol.getName()))
                .encoders(Collections.singletonList(MessageEncoder.class))
                .decoders(Collections.singletonList(MessageDecoder.class))
                .build();
            this.session = clientManager.connectToServer(endpoint, config, new URI(uri));
            return (Void) null;
        }).subscribeOn(Schedulers.boundedElastic()))).doOnError(error -> {
            handleClientStop();
        });
    }

Line commented on: if (clientState.get() != WebPubSubClientState.STOPPED) {

Revised code:
public Mono<Void> start() {
        return this.start(null);
    }
Code review comment: It's unfortunate that Jackson doesn't consider this as a breaking change.

Code under review:
public JacksonAdapter() {
        this.simpleMapper = initializeMapperBuilder(JsonMapper.builder())
            .build();

        this.headerMapper = initializeMapperBuilder(JsonMapper.builder())
            .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_VALUES)
            .build();

        this.xmlMapper = initializeMapperBuilder(XmlMapper.builder())
            .defaultUseWrapper(false)
            .enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION)
            /*
             * In Jackson 2.12 the default value of this feature changed from true to false.
             * https:
             */
            .enable(FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL)
            .build();

        ObjectMapper flatteningMapper = initializeMapperBuilder(JsonMapper.builder())
            .addModule(FlatteningSerializer.getModule(simpleMapper()))
            .addModule(FlatteningDeserializer.getModule(simpleMapper()))
            .build();

        this.mapper = initializeMapperBuilder(JsonMapper.builder())
            
            .addModule(AdditionalPropertiesSerializer.getModule(flatteningMapper))
            .addModule(AdditionalPropertiesDeserializer.getModule(flatteningMapper))
            .addModule(FlatteningSerializer.getModule(simpleMapper()))
            .addModule(FlatteningDeserializer.getModule(simpleMapper()))
            .build();
    }

Line commented on: * https:

Revised code:
public JacksonAdapter() {
        this.simpleMapper = initializeMapperBuilder(JsonMapper.builder())
            .build();

        this.headerMapper = initializeMapperBuilder(JsonMapper.builder())
            .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
            .build();

        this.xmlMapper = initializeMapperBuilder(XmlMapper.builder())
            .defaultUseWrapper(false)
            .enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION)
            /*
             * In Jackson 2.12 the default value of this feature changed from true to false.
             * https:
             */
            .enable(FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL)
            .build();

        this.xmlMapper.coercionConfigDefaults()
            .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsNull);

        ObjectMapper flatteningMapper = initializeMapperBuilder(JsonMapper.builder())
            .addModule(FlatteningSerializer.getModule(simpleMapper()))
            .addModule(FlatteningDeserializer.getModule(simpleMapper()))
            .build();

        this.mapper = initializeMapperBuilder(JsonMapper.builder())
            
            .addModule(AdditionalPropertiesSerializer.getModule(flatteningMapper))
            .addModule(AdditionalPropertiesDeserializer.getModule(flatteningMapper))
            .addModule(FlatteningSerializer.getModule(simpleMapper()))
            .addModule(FlatteningDeserializer.getModule(simpleMapper()))
            .build();
    }
Code review comment: I thought about it, but this is a helper class, it's not a "junit" specific class, and I thought we shouldn't use `TemporaryFolder` directly. Another idea is to remove ctors with no `tmpWorkingDir` so it's a mandatory argument, and all consumers should be responsible to pass a directory path there, so all the tests using it could pass a junit `TemporaryFolder.newFolder()`.

Code under review:
public TestingTaskManagerRuntimeInfo() {
        this(
                new Configuration(),
                EnvironmentInformation.getTemporaryFileDirectory()
                        .split(",|" + File.pathSeparator));
    }

Line commented on: EnvironmentInformation.getTemporaryFileDirectory()

Revised code:
public TestingTaskManagerRuntimeInfo() {
        this(
                new Configuration(),
                EnvironmentInformation.getTemporaryFileDirectory()
                        .split(",|" + File.pathSeparator));
    }
Code review comment: Would this possibly happen?  > Thread1: call subpartition.createReadView() - create view1 > Thread2: obtain a reference to view1   It is not possible to access to view1 through a different thread, unless downstream reconnects, meaning either thread1 releases the view upon disconnecting from downstream or a different thread (thread2) reconnects and release the view; that would be guarded by the buffer lock as you suggested.  > Thread1: call subpartition.createReadView() - create view2 > Thread2: call view1.releaseAllResources <-- nulls out subpartition.readView; view2 is now corrupt?  same as above.

Code under review:
void releaseView() {
		LOG.info("Releasing view of subpartition {} of {}.", getSubPartitionIndex(), parent.getPartitionId());
		readView = null;
		isPartialBuffer = true;
		isBlockedByCheckpoint = false;
		sequenceNumber = 0;
	}

Line commented on: readView = null;

Revised code:
void releaseView() {
		assert Thread.holdsLock(buffers);
		if (readView != null) {
			
			LOG.debug("Releasing view of subpartition {} of {}.", getSubPartitionIndex(), parent.getPartitionId());

			readView.releaseAllResources();
			readView = null;

			isPartialBufferCleanupRequired = true;
			isBlockedByCheckpoint = false;
			sequenceNumber = 0;
		}
	}
Code review comment: It'd be good to include the conflicting artifacts into the message.

Code under review:
public AppModel resolveModel(AppArtifact appArtifact) throws AppModelResolverException {
        if (appModel != null) {
            if (appModel.getAppArtifact().equals(appArtifact)) {
                return appModel;
            } else {
                throw new AppModelResolverException("Requested artifact does not match loaded model");
            }
        }
        appModel = QuarkusModelHelper.convert(model, appArtifact);
        return appModel;
    }

Line commented on: throw new AppModelResolverException("Requested artifact does not match loaded model");

Revised code:
public AppModel resolveModel(AppArtifact appArtifact) throws AppModelResolverException {
        if (appModel != null) {
            if (appModel.getAppArtifact().equals(appArtifact)) {
                return appModel;
            } else {
                throw new AppModelResolverException(
                        "Requested artifact : " + appArtifact + ", does not match loaded model " + appModel.getAppArtifact());
            }
        }
        appModel = QuarkusModelHelper.convert(model, appArtifact);
        return appModel;
    }
Code review comment: Not sure if it's important for Undertow but I would have checked if the path ends with `/` before adding a `/`

Code under review:
ServletBuildItem createServlet() {
        ServletBuildItem servletBuildItem = new ServletBuildItem("metrics", SmallRyeMetricsServlet.class.getName());
        servletBuildItem.getMappings().add(metrics.path + "/*");
        return servletBuildItem;
    }

Line commented on: servletBuildItem.getMappings().add(metrics.path + "/*");

Revised code:
ServletBuildItem createServlet() {
        ServletBuildItem servletBuildItem = new ServletBuildItem("metrics", SmallRyeMetricsServlet.class.getName());
        servletBuildItem.getMappings().add(metrics.path + (metrics.path.endsWith("/") ? "*" : "/*"));
        return servletBuildItem;
    }
Code review comment: perhaps? I can't say definitively, but:  it is already in [the `DeprecatedPrimitives` section of the proto](https://github.com/apache/beam/blob/a6897100e34cf2b6f177d261f65678c4ff8c7616/model/pipeline/src/main/proto/beam_runner_api.proto#L238)  is it always implemented as a composite / in terms of other primitives?  we're currently also having a discussion about the other "deprecated primitive", [`CREATE_VIEW`](https://github.com/apache/beam/blob/a6897100e34cf2b6f177d261f65678c4ff8c7616/model/pipeline/src/main/proto/beam_runner_api.proto#L242), which is related to a bunch of the remaining failing Java PVR tests

Code under review:
static Collection<String> getPrimitiveTransformIds(RunnerApi.Components components) {
    Collection<String> ids = new LinkedHashSet<>();

    for (Map.Entry<String, PTransform> transformEntry : components.getTransformsMap().entrySet()) {
      PTransform transform = transformEntry.getValue();
      boolean isPrimitive = isPrimitiveTransform(transform);
      if (isPrimitive) {
        
        
        
        
        
        Deque<String> transforms = new ArrayDeque<>();
        transforms.push(transformEntry.getKey());
        while (!transforms.isEmpty()) {
          String id = transforms.pop();
          PTransform next = components.getTransformsMap().get(id);
          List<String> subtransforms = next.getSubtransformsList();
          if (subtransforms.isEmpty()) {
            ids.add(id);
          } else {
            transforms.addAll(subtransforms);
          }
        }
      }
    }
    return ids;
  }

Line commented on: if (isPrimitive) {

Revised code:
static Collection<String> getPrimitiveTransformIds(RunnerApi.Components components) {
    Collection<String> ids = new LinkedHashSet<>();

    for (Map.Entry<String, PTransform> transformEntry : components.getTransformsMap().entrySet()) {
      PTransform transform = transformEntry.getValue();
      boolean isPrimitive = isPrimitiveTransform(transform);
      if (isPrimitive) {
        
        
        
        
        
        Deque<String> transforms = new ArrayDeque<>();
        transforms.push(transformEntry.getKey());
        while (!transforms.isEmpty()) {
          String id = transforms.pop();
          PTransform next = components.getTransformsMap().get(id);
          List<String> subtransforms = next.getSubtransformsList();
          if (subtransforms.isEmpty()) {
            ids.add(id);
          } else {
            transforms.addAll(subtransforms);
          }
        }
      }
    }
    return ids;
  }
Code review comment: This can return any constructor - you first need to look for `@Inject` constructor and if not present, then for no-args one.

Code under review:
private void addConstructorLevelBindings(ClassInfo classInfo, Collection<AnnotationInstance> bindings) {
        MethodInfo constructor = classInfo.method(Methods.INIT);
        if (constructor == null) {
            Optional<Injection> constructorWithInject = injections.stream().filter(Injection::isConstructor).findAny();
            if (constructorWithInject.isPresent()) {
                constructor = constructorWithInject.get().target.asMethod();
            }
        }
        if (constructor != null) {
            beanDeployment.getAnnotations(constructor).stream()
                    .filter(a -> beanDeployment.getInterceptorBinding(a.name()) != null
                            && bindings.stream().noneMatch(e -> e.name().equals(a.name())))
                    .forEach(a -> bindings.add(a));
        }
    }

Line commented on: MethodInfo constructor = classInfo.method(Methods.INIT);

Revised code:
private void addConstructorLevelBindings(ClassInfo classInfo, Collection<AnnotationInstance> bindings) {
        MethodInfo constructor;
        Optional<Injection> constructorWithInject = getConstructorInjection();
        if (constructorWithInject.isPresent()) {
            constructor = constructorWithInject.get().target.asMethod();
        } else {
            constructor = classInfo.method(Methods.INIT);
        }
        if (constructor != null) {
            beanDeployment.getAnnotations(constructor).stream()
                    .filter(a -> beanDeployment.getInterceptorBinding(a.name()) != null
                            && bindings.stream().noneMatch(e -> e.name().equals(a.name())))
                    .forEach(a -> bindings.add(a));
        }
    }
Code review comment: nit: it would make me happier if this.feeder was initialized before the RemoteBundle is created so we don't have to worry about NPE.

Code under review:
new BundleProgressHandler() {
                    @Override
                    public void onProgress(ProcessBundleProgressResponse progress) {
                      if (progress.hasSplit()) {
                        feeder.split(progress.getSplit());
                      }
                    }

                    @Override
                    public void onCompleted(ProcessBundleResponse response) {
                      if (response.hasSplit()) {
                        feeder.split(response.getSplit());
                      }
                    }
                  });

Line commented on: feeder.split(progress.getSplit());

Revised code:
new BundleProgressHandler() {
                    @Override
                    public void onProgress(ProcessBundleProgressResponse progress) {
                      if (progress.hasSplit()) {
                        feeder.split(progress.getSplit());
                      }
                    }

                    @Override
                    public void onCompleted(ProcessBundleResponse response) {
                      if (response.hasSplit()) {
                        feeder.split(response.getSplit());
                      }
                    }
                  }
Code review comment: > but small costs pile up   You would need a loooot of `return "";` statements to see a very tiny cost but I get your point and the PR is updated now ;-).  > Certainly not worth blocking the PR thus why I approved anyway and let you decide what to do :). > (I wouldn't have asked if it made the code worse or more complex)  :100:

Code under review:
String replacePathParameters(String path) {
        if (path.isEmpty()) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        Matcher m = PATH_PARAM_PATTERN.matcher(path);
        while (m.find()) {
            
            String match = m.group();
            String paramName = match.substring(1, match.length() - 1);
            String val = pathParams.get(paramName);
            if (val == null) {
                throw new WebSocketClientException("Unable to obtain the path param for: " + paramName);
            }
            m.appendReplacement(sb, URLEncoder.encode(val, StandardCharsets.UTF_8));
        }
        m.appendTail(sb);
        return path.startsWith("/") ? sb.toString() : "/" + sb.toString();
    }

Line commented on: return "";

Revised code:
String replacePathParameters(String path) {
        if (path.isEmpty()) {
            return path;
        }
        StringBuilder sb = new StringBuilder();
        Matcher m = PATH_PARAM_PATTERN.matcher(path);
        while (m.find()) {
            
            String match = m.group();
            String paramName = match.substring(1, match.length() - 1);
            String val = pathParams.get(paramName);
            if (val == null) {
                throw new WebSocketClientException("Unable to obtain the path param for: " + paramName);
            }
            m.appendReplacement(sb, URLEncoder.encode(val, StandardCharsets.UTF_8));
        }
        m.appendTail(sb);
        return path.startsWith("/") ? sb.toString() : "/" + sb.toString();
    }
Code review comment: In order to get the flag value for a particular application, you need to tell the flag what application this is for before value() with a call to `with(Dimension.APPLICATION_ID, anApplicationId.serializedForm())`

Code under review:
private NodesSpecification createNodesSpecificationForLogserver() {
        
        DeployState deployState = context.getDeployState();
        if (deployState.getProperties().useDedicatedNodeForLogserver() &&
                context.getApplicationType() == ConfigModelContext.ApplicationType.DEFAULT &&
                deployState.isHosted() &&
                Flags.ENABLE_LOGSERVER.bindTo(deployState.flagSource()).value())
            return NodesSpecification.dedicated(1, context);
        else
            return NodesSpecification.nonDedicated(1, context);
    }

Line commented on: Flags.ENABLE_LOGSERVER.bindTo(deployState.flagSource()).value())

Revised code:
private NodesSpecification createNodesSpecificationForLogserver() {
        
        DeployState deployState = context.getDeployState();
        if (deployState.getProperties().useDedicatedNodeForLogserver() &&
                context.getApplicationType() == ConfigModelContext.ApplicationType.DEFAULT &&
                deployState.isHosted() &&
                logServerFlagValue(deployState))
            return NodesSpecification.dedicated(1, context);
        else
            return NodesSpecification.nonDedicated(1, context);
    }
Code review comment: Use user who create this job?

Code under review:
public void before() throws JobException {
        if (isCanceled.get()) {
            throw new JobException("Export executor has been canceled, task id: {}", getTaskId());
        }
        ctx = new ConnectContext();
        ctx.setEnv(Env.getCurrentEnv());
        ctx.setCluster(SystemInfoService.DEFAULT_CLUSTER);
        ctx.setQualifiedUser(Auth.ADMIN_USER);
        ctx.setCurrentUserIdentity(UserIdentity.ADMIN);
        ctx.getState().reset();
        ctx.setThreadLocalInfo();
        ctx.setDatabase(currentDb);
        TUniqueId queryId = generateQueryId(UUID.randomUUID().toString());
        ctx.getSessionVariable().enableFallbackToOriginalPlanner = false;
        stmtExecutor = new StmtExecutor(ctx, (String) null);
        ctx.setQueryId(queryId);
        NereidsParser parser = new NereidsParser();
        this.command = (InsertIntoTableCommand) parser.parseSingle(sql);
        this.command.setLabelName(Optional.of(getJobId() + "_" + getTaskId()));
        this.command.setJobId(getTaskId());

        super.before();

    }

Line commented on: ctx.setQualifiedUser(Auth.ADMIN_USER);

Revised code:
public void before() throws JobException {
        if (isCanceled.get()) {
            throw new JobException("Export executor has been canceled, task id: {}", getTaskId());
        }
        ctx = new ConnectContext();
        ctx.setEnv(Env.getCurrentEnv());
        ctx.setCluster(SystemInfoService.DEFAULT_CLUSTER);
        ctx.setQualifiedUser(userIdentity.getQualifiedUser());
        ctx.setCurrentUserIdentity(userIdentity);
        ctx.getState().reset();
        ctx.setThreadLocalInfo();
        ctx.setDatabase(currentDb);
        TUniqueId queryId = generateQueryId(UUID.randomUUID().toString());
        ctx.getSessionVariable().enableFallbackToOriginalPlanner = false;
        stmtExecutor = new StmtExecutor(ctx, (String) null);
        ctx.setQueryId(queryId);
        NereidsParser parser = new NereidsParser();
        this.command = (InsertIntoTableCommand) parser.parseSingle(sql);
        this.command.setLabelName(Optional.of(getJobId() + "_" + getTaskId()));
        this.command.setJobId(getTaskId());

        super.before();

    }
Code review comment: I used this format to avoid codecov warnings for the last line in this method.

Code under review:
private BType getMapType(BType type) {
        BType refType = Types.getReferredType(type);
        BType resultantType = symTable.mapType;
        if (refType.tag == TypeTags.UNION) {
            for (BType memberType : ((BUnionType) type).getMemberTypes()) {
                BType resultType = getMapType(memberType);
                if (resultType != symTable.mapType) {
                    resultantType = resultType;
                    break;
                }
            }
        } else if (refType.tag == TypeTags.INTERSECTION) {
            resultantType = getMapType(((BIntersectionType) refType).effectiveType);
        } else if (refType.tag == TypeTags.MAP) {
            resultantType = refType;
        }
        return resultantType;
    }

Line commented on: resultantType = getMapType(((BIntersectionType) refType).effectiveType);

Revised code:
private BType getMapType(BType type) {
        BType resultantType = types.getSafeType(Types.getReferredType(type), false, true);
        if (resultantType.tag == TypeTags.INTERSECTION) {
            return getMapType(((BIntersectionType) resultantType).effectiveType);
        }
        return resultantType;
    }
Code review comment: ```suggestion             String maxDate = DateLiteral.createMaxValue(Type.DATE).getStringValue(); ``` minInt -> maxInt? minDate -> maxDate?

Code under review:
public List<PartitionInfo> getPartitions(Table table, List<String> partitionNames) {
        try (Connection connection = getConnection()) {
            List<Partition> partitions = schemaResolver.getPartitions(connection, table);
            String minInt = IntLiteral.createMaxValue(Type.INT).getStringValue();
            String minDate = DateLiteral.createMaxValue(Type.DATE).getStringValue();

            ImmutableList.Builder<PartitionInfo> list = ImmutableList.builder();
            if (!partitions.isEmpty()) {
                for (Partition partition : partitions) {
                    String partitionName = partition.getPartitionName();
                    if (partitionNames.contains(partitionName)) {
                        list.add(partition);
                    }
                    
                    if (partitionName.equalsIgnoreCase(PartitionUtil.MYSQL_PARTITION_MAXVALUE)) {
                        if (partitionNames.contains(minInt) || partitionNames.contains(minDate)) {
                            list.add(partition);
                        }
                    }
                }
                return list.build();
            } else {
                return Lists.newArrayList();
            }
        } catch (SQLException e) {
            throw new StarRocksConnectorException(e.getMessage());
        }
    }

Line commented on: String minDate = DateLiteral.createMaxValue(Type.DATE).getStringValue();

Revised code:
public List<PartitionInfo> getPartitions(Table table, List<String> partitionNames) {
        try (Connection connection = getConnection()) {
            List<Partition> partitions = schemaResolver.getPartitions(connection, table);
            String maxInt = IntLiteral.createMaxValue(Type.INT).getStringValue();
            String maxDate = DateLiteral.createMaxValue(Type.DATE).getStringValue();

            ImmutableList.Builder<PartitionInfo> list = ImmutableList.builder();
            if (partitions.isEmpty()) {
                return Lists.newArrayList();
            }
            for (Partition partition : partitions) {
                String partitionName = partition.getPartitionName();
                if (partitionNames.contains(partitionName)) {
                    list.add(partition);
                }
                
                if (partitionName.equalsIgnoreCase(PartitionUtil.MYSQL_PARTITION_MAXVALUE)) {
                    if (partitionNames.contains(maxInt) || partitionNames.contains(maxDate)) {
                        list.add(partition);
                    }
                }
            }
            return list.build();
        } catch (SQLException e) {
            throw new StarRocksConnectorException(e.getMessage());
        }
    }
Code review comment: this can be simplified now right? you don't need an intermediate list, but we can start writing to the buf directly from the loop?

Code under review:
private void writeFunctionsGlobalVarDependency(ByteBuf buf, BIRNode.BIRFunction birFunction) {
        List<Integer> globalVarBuf = new LinkedList<>();

        for (BIRNode.BIRVariableDcl var : birFunction.dependentGlobalVars) {
            globalVarBuf.add(addStringCPEntry(var.name.value));
        }

        buf.writeInt(globalVarBuf.size());
        globalVarBuf.forEach(buf::writeInt);
    }

Line commented on: globalVarBuf.forEach(buf::writeInt);

Revised code:
private void writeFunctionsGlobalVarDependency(ByteBuf buf, BIRNode.BIRFunction birFunction) {
        buf.writeInt(birFunction.dependentGlobalVars.size());

        for (BIRNode.BIRVariableDcl var : birFunction.dependentGlobalVars) {
            buf.writeInt(addStringCPEntry(var.name.value));
        }
    }