[ 
https://issues.apache.org/jira/browse/APEXCORE-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16210137#comment-16210137
 ] 

ASF GitHub Bot commented on APEXCORE-550:
-----------------------------------------

WenbinZhu closed pull request #579: APEXCORE-550 User friendly error message 
when Java version mismatch happens
URL: https://github.com/apache/apex-core/pull/579
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java 
b/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java
index 1717ace2cc..d7c4bb789b 100644
--- a/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java
+++ b/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java
@@ -1978,6 +1978,7 @@ public void execute(String[] args, ConsoleReader reader) 
throws Exception
             if (ap != null) {
               try {
                 if (!commandLineInfo.force) {
+                  checkJdkVersionCompatible(ap);
                   checkPlatformCompatible(ap);
                   checkConfigPackageCompatible(ap, cp);
                 }
@@ -3111,6 +3112,8 @@ public void execute(String[] args, ConsoleReader reader) 
throws Exception
             }
 
             arr.put(oper);
+          } catch (UnsupportedClassVersionError ex) {
+            throw new CliException("Class build JDK version not compatible 
with system JDK version", ex);
           } catch (Exception | NoClassDefFoundError ex) {
             // ignore this class
             final String cls = clazz;
@@ -3561,6 +3564,16 @@ private void checkPlatformCompatible(AppPackage ap)
     }
   }
 
+  private void checkJdkVersionCompatible(AppPackage ap)
+  {
+    String appBuildJdkVersion = ap.getAppBuildJdkVersion();
+    String systemJdkVersion = System.getProperty("java.version");
+    // App JDK version should be lower than system JDK version
+    if (!VersionInfo.isCompatible(systemJdkVersion, appBuildJdkVersion)) {
+      throw new CliException("Application package build JDK version: " + 
appBuildJdkVersion + " is not compatible with system JDK version: " + 
systemJdkVersion);
+    }
+  }
+
   private void launchAppPackage(AppPackage ap, ConfigPackage cp, 
LaunchCommandLineInfo commandLineInfo, ConsoleReader reader) throws Exception
   {
     new LaunchCommand().execute(getLaunchAppPackageArgs(ap, cp, 
commandLineInfo, reader), reader);
diff --git a/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java 
b/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java
index a606b0668a..fbae9978c3 100644
--- a/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java
+++ b/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java
@@ -73,6 +73,7 @@
   public static final String ATTRIBUTE_DT_APP_PACKAGE_NAME = 
"DT-App-Package-Name";
   public static final String ATTRIBUTE_DT_APP_PACKAGE_VERSION = 
"DT-App-Package-Version";
   public static final String ATTRIBUTE_DT_APP_PACKAGE_GROUP_ID = 
"DT-App-Package-Group-Id";
+  public static final String ATTRIBUTE_BUILD_JDK_VERSION = "Build-Jdk";
   public static final String ATTRIBUTE_CLASS_PATH = "Class-Path";
   public static final String ATTRIBUTE_DT_APP_PACKAGE_DISPLAY_NAME = 
"DT-App-Package-Display-Name";
   public static final String ATTRIBUTE_DT_APP_PACKAGE_DESCRIPTION = 
"DT-App-Package-Description";
@@ -83,6 +84,7 @@
   private final String dtEngineVersion;
   private final String appPackageDescription;
   private final String appPackageDisplayName;
+  private final String appBuildJdkVersion;
   private final ArrayList<String> classPath = new ArrayList<>();
   private final File directory;
 
@@ -235,6 +237,7 @@ public AppPackage(InputStream input, File contentFolder, 
boolean processAppDirec
       dtEngineVersion = attr.getValue(ATTRIBUTE_DT_ENGINE_VERSION);
       appPackageDisplayName = 
attr.getValue(ATTRIBUTE_DT_APP_PACKAGE_DISPLAY_NAME);
       appPackageDescription = 
attr.getValue(ATTRIBUTE_DT_APP_PACKAGE_DESCRIPTION);
+      appBuildJdkVersion = attr.getValue(ATTRIBUTE_BUILD_JDK_VERSION);
       String classPathString = attr.getValue(ATTRIBUTE_CLASS_PATH);
       if (appPackageName == null || appPackageVersion == null || 
classPathString == null) {
         throw new IOException("Not a valid app package.  App Package Name or 
Version or Class-Path is missing from MANIFEST.MF");
@@ -396,6 +399,11 @@ public String getDtEngineVersion()
     return dtEngineVersion;
   }
 
+  public String getAppBuildJdkVersion()
+  {
+    return appBuildJdkVersion;
+  }
+
   public List<String> getClassPath()
   {
     return Collections.unmodifiableList(classPath);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> User friendly error message when Java version mismatch happens
> --------------------------------------------------------------
>
>                 Key: APEXCORE-550
>                 URL: https://issues.apache.org/jira/browse/APEXCORE-550
>             Project: Apache Apex Core
>          Issue Type: Bug
>            Reporter: Sandesh
>            Assignee: Wenbin Zhu
>
> When an app package is compiled with Java 1.8 and Apex is using 1.7, we see 
> the following behaviour with Apex CLI
> 1. launch <AppPackage>
>     "No applications in Application Package", ideally it should point out the 
> exact error message
> 2. get-app-package-operators <AppPackage>
> Throws the following exception java.lang.UnsupportedClassVersionError, 
> Should we add an extra message indicating that the Java version mismatch has 
> happened?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to