You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ro...@apache.org on 2015/05/22 19:26:24 UTC

svn commit: r1681163 - in /pig/trunk: CHANGES.txt src/org/apache/pig/JVMReuseImpl.java

Author: rohini
Date: Fri May 22 17:26:23 2015
New Revision: 1681163

URL: http://svn.apache.org/r1681163
Log:
PIG-4418: NullPointerException in JVMReuseImpl (rohini)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/JVMReuseImpl.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1681163&r1=1681162&r2=1681163&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri May 22 17:26:23 2015
@@ -76,6 +76,8 @@ PIG-4333: Split BigData tests into multi
  
 BUG FIXES
 
+PIG-4418: NullPointerException in JVMReuseImpl (rohini)
+
 PIG-4562: Typo in DataType.toDateTime (daijy)
 
 PIG-4559: Fix several new tez e2e test failures (daijy)

Modified: pig/trunk/src/org/apache/pig/JVMReuseImpl.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/JVMReuseImpl.java?rev=1681163&r1=1681162&r2=1681163&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/JVMReuseImpl.java (original)
+++ pig/trunk/src/org/apache/pig/JVMReuseImpl.java Fri May 22 17:26:23 2015
@@ -28,23 +28,42 @@ public class JVMReuseImpl {
     private static Log LOG = LogFactory.getLog(JVMReuseImpl.class);
 
     public void cleanupStaticData() {
+        String className = null;
+        String msg = null;
         List<Method> staticCleanupMethods = JVMReuseManager.getInstance()
                 .getStaticDataCleanupMethods();
         for (Method m : staticCleanupMethods) {
             try {
-                String msg = "Invoking method " + m.getName() + " in class "
-                        + m.getDeclaringClass().getName() + " for static data cleanup";
-                if (m.getDeclaringClass().getName().startsWith("org.apache.pig")) {
+                className = m.getDeclaringClass() == null ? "anonymous" : m.getDeclaringClass().getName();
+                msg = "Invoking method " + m.getName() + " in class "
+                        + className + " for static data cleanup";
+                if (className.startsWith("org.apache.pig")) {
                     LOG.debug(msg);
                 } else {
                     LOG.info(msg);
                 }
                 m.invoke(null);
+                msg = null;
             } catch (Exception e) {
-                throw new RuntimeException("Error while invoking method "
-                        + m.getName() + " in class " + m.getDeclaringClass().getName()
-                        + " for static data cleanup", e);
+                LOG.error("Exception while calling static methods:" + getMethodNames() + ". " + msg, e);
+                throw new RuntimeException("Error while " + msg, e);
             }
         }
     }
+
+    private String getMethodNames() {
+        StringBuilder sb = new StringBuilder();
+        for (Method m : JVMReuseManager.getInstance().getStaticDataCleanupMethods()) {
+            if (m == null) {
+                sb.append("null,");
+            } else {
+                sb.append(m.getDeclaringClass() == null ? "anonymous" : m.getDeclaringClass().getName());
+                sb.append(".").append(m.getName()).append(",");
+            }
+        }
+        if (sb.length() > 1) {
+            sb.deleteCharAt(sb.length() - 1);
+        }
+        return sb.toString();
+    }
 }