goiri commented on a change in pull request #1751: MAPREDUCE-7251: Present
friendlier error for non-static main
URL: https://github.com/apache/hadoop/pull/1751#discussion_r356786765
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestRunJar.java
##########
@@ -297,4 +297,35 @@ public void testUnJar2() throws IOException {
"would create file outside of", e);
}
}
-}
\ No newline at end of file
+
+ /**
+ * Tests that RunJar errors appropriately for classes with non-static main
+ * methods.
+ */
+ public void testRunNonStaticMain() throws Throwable {
+ RunJar runJar = spy(new RunJar());
+ // enable the client classloader
+ when(runJar.useClientClassLoader()).thenReturn(true);
+ // set the system classes and blacklist the test main class and the test
+ // third class so they can be loaded by the application classloader
+ String mainCls = NonStaticMain.class.getName();
+ String systemClasses = "-" + mainCls + "," +
ApplicationClassLoader.SYSTEM_CLASSES_DEFAULT;
+ when(runJar.getSystemClasses()).thenReturn(systemClasses);
+
+ // create the test jar
+ File testJar = JarFinder.makeClassLoaderTestJar(this.getClass(),
TEST_ROOT_DIR, TEST_JAR_2_NAME, BUFF_SIZE,
Review comment:
80 chars?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]