exceptionfactory commented on code in PR #6075: URL: https://github.com/apache/nifi/pull/6075#discussion_r892995458
########## minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/EnvRunner.java: ########## @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.minifi.bootstrap.command; + +import static org.apache.nifi.minifi.bootstrap.RunMiNiFi.CMD_LOGGER; +import static org.apache.nifi.minifi.bootstrap.RunMiNiFi.DEFAULT_LOGGER; +import static org.apache.nifi.minifi.bootstrap.Status.ERROR; +import static org.apache.nifi.minifi.bootstrap.Status.MINIFI_NOT_RUNNING; +import static org.apache.nifi.minifi.bootstrap.Status.OK; + +import java.lang.reflect.Method; +import java.util.Map.Entry; +import java.util.Properties; +import org.apache.nifi.minifi.bootstrap.MiNiFiParameters; +import org.apache.nifi.minifi.bootstrap.MiNiFiStatus; +import org.apache.nifi.minifi.bootstrap.service.MiNiFiStatusProvider; + +public class EnvRunner implements CommandRunner { + private final MiNiFiParameters miNiFiParameters; + private final MiNiFiStatusProvider miNiFiStatusProvider; + + public EnvRunner(MiNiFiParameters miNiFiParameters, MiNiFiStatusProvider miNiFiStatusProvider) { + this.miNiFiParameters = miNiFiParameters; + this.miNiFiStatusProvider = miNiFiStatusProvider; + } + + /** + * Returns information about the MiNiFi's virtual machine. + * @param args the input arguments + * @return status code + */ + @Override + public int runCommand(String[] args) { + return env(); + } + + private int env() { + MiNiFiStatus status = miNiFiStatusProvider.getStatus(miNiFiParameters.getMiNiFiPort(), miNiFiParameters.getMinifiPid()); + if (status.getPid() == null) { + CMD_LOGGER.error("Apache MiNiFi is not running"); + return MINIFI_NOT_RUNNING.getStatusCode(); + } + + Class<?> virtualMachineClass; + try { + virtualMachineClass = Class.forName("com.sun.tools.attach.VirtualMachine"); Review Comment: NiFi and NiFi Registry support Java 17, so MiNiFi should maintain compatibility. Using this approach does not seem maintainable going forward. Is the general purpose of this class to log the System properties from the MiNiFi instance? It seems like some other approach to serialize and transmit the information would be much more maintainable and supported across Java versions. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
