camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [6/8] camel git commit: camel apt compiler plugin write error log. Also fix problem for javac to scan/load hadoop/spark JARs
Date Thu, 17 Dec 2015 07:37:56 GMT
camel apt compiler plugin write error log. Also fix problem for javac to scan/load hadoop/spark
JARs


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/87ce9cce
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/87ce9cce
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/87ce9cce

Branch: refs/heads/master
Commit: 87ce9ccef9b5a82fbbb694ddd7589b87e17d8f96
Parents: aa05030
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Dec 17 08:33:13 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Dec 17 08:33:13 2015 +0100

----------------------------------------------------------------------
 .../tools/apt/AbstractAnnotationProcessor.java  | 31 +++++++++++++++++++-
 .../camel/tools/apt/EipAnnotationProcessor.java |  2 +-
 .../tools/apt/EndpointAnnotationProcessor.java  |  2 +-
 3 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/87ce9cce/tooling/apt/src/main/java/org/apache/camel/tools/apt/AbstractAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/AbstractAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/AbstractAnnotationProcessor.java
index 9a49110..c5af901 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/AbstractAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/AbstractAnnotationProcessor.java
@@ -17,6 +17,7 @@
 package org.apache.camel.tools.apt;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
@@ -24,6 +25,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.net.URI;
+import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import javax.annotation.processing.AbstractProcessor;
@@ -208,7 +210,7 @@ public abstract class AbstractAnnotationProcessor extends AbstractProcessor
{
             String packageName = className.substring(0, idx);
             PackageElement pe = elementUtils.getPackageElement(packageName);
             if (pe != null) {
-                List<? extends Element> enclosedElements = pe.getEnclosedElements();
+                List<? extends Element> enclosedElements = getEnclosedElements(pe);
                 for (Element rootElement : enclosedElements) {
                     if (rootElement instanceof TypeElement) {
                         TypeElement typeElement = (TypeElement) rootElement;
@@ -224,6 +226,17 @@ public abstract class AbstractAnnotationProcessor extends AbstractProcessor
{
         return null;
     }
 
+    @SuppressWarnings("unchecked")
+    private List<? extends Element> getEnclosedElements(PackageElement pe) {
+        // some components like hadoop/spark has bad classes that causes javac scanning issues
+        try {
+            return pe.getEnclosedElements();
+        } catch (Throwable e) {
+            // ignore
+        }
+        return Collections.EMPTY_LIST;
+    }
+
     protected void findTypeElementChildren(RoundEnvironment roundEnv, Set<TypeElement>
found, String superClassName) {
         Elements elementUtils = processingEnv.getElementUtils();
 
@@ -350,4 +363,20 @@ public abstract class AbstractAnnotationProcessor extends AbstractProcessor
{
 
         return null;
     }
+
+    protected void dumpExceptionToErrorFile(String fileName, String message, Throwable e)
{
+        File file = new File(fileName);
+        try {
+            FileOutputStream fos = new FileOutputStream(file);
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            e.printStackTrace(pw);
+            fos.write(sw.toString().getBytes());
+            pw.close();
+            sw.close();
+            fos.close();
+        } catch (Throwable t) {
+            // ignore
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/87ce9cce/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
index d124e39..e817d64 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
@@ -102,7 +102,7 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
                 }
             }
         } catch (Throwable e) {
-            // ignore
+            dumpExceptionToErrorFile("camel-apt-error.log", "Error processing EIP model",
e);
         }
         return true;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/87ce9cce/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index d7c6249..e662217 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -79,7 +79,7 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor
{
                 }
             }
         } catch (Throwable e) {
-            // ignore
+            dumpExceptionToErrorFile("camel-apt-error.log", "Error processing @UriEndpoint",
e);
         }
         return true;
     }


Mime
View raw message