You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by th...@apache.org on 2022/11/11 02:50:45 UTC
[nifi] branch main updated: NIFI-10798 Added Deprecation Logging for Java 8 on Startup
This is an automated email from the ASF dual-hosted git repository.
thenatog pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 3a536e261f NIFI-10798 Added Deprecation Logging for Java 8 on Startup
3a536e261f is described below
commit 3a536e261f09cb8ff3cd65fed5765120cdc5bca2
Author: exceptionfactory <ex...@apache.org>
AuthorDate: Thu Nov 10 15:23:43 2022 -0600
NIFI-10798 Added Deprecation Logging for Java 8 on Startup
- Added deprecation warnings for NiFi, Registry, and MiNiFi
- Added RuntimeVersionProvider for shared reference to deprecated and minimum versions
Signed-off-by: Nathan Gough <th...@gmail.com>
This closes #6648.
---
README.md | 4 ++
minifi/minifi-bootstrap/pom.xml | 4 ++
.../nifi/minifi/bootstrap/command/StartRunner.java | 10 ++++
.../service/MiNiFiExecCommandProvider.java | 8 ++-
minifi/pom.xml | 5 ++
nifi-bootstrap/pom.xml | 5 ++
.../java/org/apache/nifi/bootstrap/RunNiFi.java | 11 +++-
.../org/apache/nifi/bootstrap/util/OSUtils.java | 2 +-
.../bootstrap/util/RuntimeVersionProvider.java | 58 ++++++++++++++++++++++
.../nifi-registry-bootstrap/pom.xml | 5 ++
.../nifi/registry/bootstrap/RunNiFiRegistry.java | 12 ++++-
11 files changed, 114 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 66f2fba88d..4b17be2e54 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,10 @@ Apache NiFi was made for dataflow. It supports highly configurable directed grap
- Pluggable fine-grained role-based authentication/authorization
- Multiple teams can manage and share specific portions of the flow
+## Minimum Recommendations
+* JDK 11.0.16
+* Apache Maven 3.8.6
+
## Minimum Requirements
* JDK 8 Update 251
* Apache Maven 3.6.0
diff --git a/minifi/minifi-bootstrap/pom.xml b/minifi/minifi-bootstrap/pom.xml
index b2cb78d8d3..c125a2e160 100644
--- a/minifi/minifi-bootstrap/pom.xml
+++ b/minifi/minifi-bootstrap/pom.xml
@@ -49,6 +49,10 @@ limitations under the License.
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-bootstrap-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-deprecation-log</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-expression-language</artifactId>
diff --git a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java
index edea4ca8a0..9b29360d54 100644
--- a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java
+++ b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java
@@ -43,6 +43,9 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.nifi.bootstrap.util.OSUtils;
+import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
+import org.apache.nifi.deprecation.log.DeprecationLogger;
+import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
import org.apache.nifi.minifi.bootstrap.MiNiFiParameters;
import org.apache.nifi.minifi.bootstrap.RunMiNiFi;
import org.apache.nifi.minifi.bootstrap.ShutdownHook;
@@ -60,6 +63,8 @@ import org.apache.nifi.util.Tuple;
public class StartRunner implements CommandRunner {
private static final int STARTUP_WAIT_SECONDS = 60;
+ private static final DeprecationLogger deprecationLogger = DeprecationLoggerFactory.getLogger(StartRunner.class);
+
private final CurrentPortProvider currentPortProvider;
private final BootstrapFileProvider bootstrapFileProvider;
private final PeriodicStatusReporterManager periodicStatusReporterManager;
@@ -110,6 +115,11 @@ public class StartRunner implements CommandRunner {
return;
}
+ final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
+ if (RuntimeVersionProvider.isMajorVersionDeprecated(javaMajorVersion)) {
+ deprecationLogger.warn("Support for Java {} is deprecated. Java {} is the minimum recommended version", javaMajorVersion, RuntimeVersionProvider.getMinimumMajorVersion());
+ }
+
File prevLockFile = bootstrapFileProvider.getLockFile();
if (prevLockFile.exists() && !prevLockFile.delete()) {
CMD_LOGGER.warn("Failed to delete previous lock file {}; this file should be cleaned up manually", prevLockFile);
diff --git a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiExecCommandProvider.java b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiExecCommandProvider.java
index 7c52a99c68..a28deb9497 100644
--- a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiExecCommandProvider.java
+++ b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiExecCommandProvider.java
@@ -18,7 +18,6 @@
package org.apache.nifi.minifi.bootstrap.service;
import static org.apache.nifi.minifi.bootstrap.RunMiNiFi.CONF_DIR_KEY;
-import static org.apache.nifi.minifi.bootstrap.RunMiNiFi.DEFAULT_LOGGER;
import java.io.File;
import java.io.IOException;
@@ -27,7 +26,7 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Properties;
-import org.apache.nifi.bootstrap.util.OSUtils;
+import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
public class MiNiFiExecCommandProvider {
@@ -146,9 +145,8 @@ public class MiNiFiExecCommandProvider {
private List<String> getJava11Files(File libDir) {
List<String> java11Files = new ArrayList();
- String runtimeJavaVersion = System.getProperty("java.version");
- DEFAULT_LOGGER.info("Runtime Java version: {}", runtimeJavaVersion);
- if (OSUtils.parseJavaVersion(runtimeJavaVersion) >= 11) {
+ final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
+ if (javaMajorVersion >= 11) {
/* If running on Java 11 or greater, add the JAXB/activation/annotation libs to the classpath.
*
* TODO: Once the minimum Java version requirement of NiFi is 11, this processing should be removed.
diff --git a/minifi/pom.xml b/minifi/pom.xml
index 0762ae9b41..0ee8a69596 100644
--- a/minifi/pom.xml
+++ b/minifi/pom.xml
@@ -51,6 +51,11 @@ limitations under the License.
<artifactId>nifi-bootstrap-utils</artifactId>
<version>1.19.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-deprecation-log</artifactId>
+ <version>1.19.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.nifi.minifi</groupId>
<artifactId>minifi-bootstrap</artifactId>
diff --git a/nifi-bootstrap/pom.xml b/nifi-bootstrap/pom.xml
index 1caa6f3363..8bbe29f1f6 100644
--- a/nifi-bootstrap/pom.xml
+++ b/nifi-bootstrap/pom.xml
@@ -30,6 +30,11 @@ language governing permissions and limitations under the License. -->
<version>1.19.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-deprecation-log</artifactId>
+ <version>1.19.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-bootstrap-utils</artifactId>
diff --git a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java
index 9894b7fbef..d2b23b388e 100644
--- a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java
+++ b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java
@@ -20,7 +20,10 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.bootstrap.notification.NotificationType;
import org.apache.nifi.bootstrap.util.DumpFileValidator;
import org.apache.nifi.bootstrap.util.OSUtils;
+import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
import org.apache.nifi.bootstrap.util.SecureNiFiConfigUtil;
+import org.apache.nifi.deprecation.log.DeprecationLogger;
+import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
import org.apache.nifi.util.file.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -147,7 +150,7 @@ public class RunNiFi {
private final Logger cmdLogger = LoggerFactory.getLogger("org.apache.nifi.bootstrap.Command");
// used for logging all info. These by default will be written to the log file
private final Logger defaultLogger = LoggerFactory.getLogger(RunNiFi.class);
-
+ private final DeprecationLogger deprecationLogger = DeprecationLoggerFactory.getLogger(RunNiFi.class);
private final ExecutorService loggingExecutor;
private volatile Set<Future<?>> loggingFutures = new HashSet<>(2);
@@ -1203,7 +1206,7 @@ public class RunNiFi {
String runtimeJavaVersion = System.getProperty("java.version");
defaultLogger.info("Runtime Java version: {}", runtimeJavaVersion);
- int javaMajorVersion = OSUtils.parseJavaVersion(runtimeJavaVersion);
+ final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
if (javaMajorVersion >= 11) {
/* If running on Java 11 or greater, add the JAXB/activation/annotation libs to the classpath.
*
@@ -1219,6 +1222,10 @@ public class RunNiFi {
}
}
+ if (RuntimeVersionProvider.isMajorVersionDeprecated(javaMajorVersion)) {
+ deprecationLogger.warn("Support for Java {} is deprecated. Java {} is the minimum recommended version", javaMajorVersion, RuntimeVersionProvider.getMinimumMajorVersion());
+ }
+
final StringBuilder classPathBuilder = new StringBuilder();
for (int i = 0; i < cpFiles.size(); i++) {
final String filename = cpFiles.get(i);
diff --git a/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java b/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java
index 71047a55bb..bb11a25429 100644
--- a/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java
+++ b/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java
@@ -75,7 +75,7 @@ public final class OSUtils {
* @param version the Java version string
* @return the major version as an int
*/
- public static int parseJavaVersion(final String version) {
+ static int parseJavaVersion(final String version) {
String majorVersion;
if (version.startsWith("1.")) {
majorVersion = version.substring(2, 3);
diff --git a/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/RuntimeVersionProvider.java b/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/RuntimeVersionProvider.java
new file mode 100644
index 0000000000..e12dfefd85
--- /dev/null
+++ b/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/RuntimeVersionProvider.java
@@ -0,0 +1,58 @@
+/*
+ * 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.bootstrap.util;
+
+/**
+ * Java Runtime Version Provider with information on supported and deprecated versions
+ */
+public class RuntimeVersionProvider {
+
+ private static final String JAVA_VERSION_PROPERTY = "java.version";
+
+ private static final int DEPRECATED_JAVA_VERSION = 8;
+
+ private static final int MINIMUM_JAVA_VERSION = 11;
+
+ /**
+ * Get major version from java.version System property
+ *
+ * @return Major Version
+ */
+ public static int getMajorVersion() {
+ final String javaVersion = System.getProperty(JAVA_VERSION_PROPERTY);
+ return OSUtils.parseJavaVersion(javaVersion);
+ }
+
+ /**
+ * Get minimum supported major version
+ *
+ * @return Minimum Major Version
+ */
+ public static int getMinimumMajorVersion() {
+ return MINIMUM_JAVA_VERSION;
+ }
+
+ /**
+ * Is major version deprecated
+ *
+ * @param majorVersion Java major version
+ * @return Deprecated status
+ */
+ public static boolean isMajorVersionDeprecated(final int majorVersion) {
+ return majorVersion == DEPRECATED_JAVA_VERSION;
+ }
+}
diff --git a/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/pom.xml b/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/pom.xml
index f1df9e857e..9045459721 100644
--- a/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/pom.xml
+++ b/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/pom.xml
@@ -35,5 +35,10 @@
<artifactId>nifi-bootstrap-utils</artifactId>
<version>1.19.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-deprecation-log</artifactId>
+ <version>1.19.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
diff --git a/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java b/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java
index f75edcb800..b473516e8b 100644
--- a/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java
+++ b/nifi-registry/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java
@@ -18,6 +18,9 @@ package org.apache.nifi.registry.bootstrap;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.bootstrap.util.OSUtils;
+import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
+import org.apache.nifi.deprecation.log.DeprecationLogger;
+import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
import org.apache.nifi.registry.util.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -119,7 +122,7 @@ public class RunNiFiRegistry {
private final Logger cmdLogger = LoggerFactory.getLogger("org.apache.nifi.registry.bootstrap.Command");
// used for logging all info. These by default will be written to the log file
private final Logger defaultLogger = LoggerFactory.getLogger(RunNiFiRegistry.class);
-
+ private final DeprecationLogger deprecationLogger = DeprecationLoggerFactory.getLogger(RunNiFiRegistry.class);
private final ExecutorService loggingExecutor;
private volatile Set<Future<?>> loggingFutures = new HashSet<>(2);
@@ -923,7 +926,8 @@ public class RunNiFiRegistry {
final String runtimeJavaVersion = System.getProperty("java.version");
defaultLogger.info("Runtime Java version: {}", runtimeJavaVersion);
- if (Integer.parseInt(runtimeJavaVersion.substring(0, runtimeJavaVersion.indexOf('.'))) >= 11) {
+ final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
+ if (javaMajorVersion >= 11) {
// If running on Java 11 or greater, add lib/java11 to the classpath.
// TODO: Once the minimum Java version requirement of NiFi Registry is 11, this processing should be removed.
final String libJava11Filename = replaceNull(props.get("lib.dir"), "./lib").trim() + "/java11";
@@ -935,6 +939,10 @@ public class RunNiFiRegistry {
}
}
+ if (RuntimeVersionProvider.isMajorVersionDeprecated(javaMajorVersion)) {
+ deprecationLogger.warn("Support for Java {} is deprecated. Java {} is the minimum recommended version", javaMajorVersion, RuntimeVersionProvider.getMinimumMajorVersion());
+ }
+
final StringBuilder classPathBuilder = new StringBuilder();
for (int i = 0; i < cpFiles.size(); i++) {
final String filename = cpFiles.get(i);