fix NoClassDefFoundError from application insights (#38)

This commit is contained in:
Kevin Zhao 2017-08-28 09:51:35 +08:00 коммит произвёл GitHub
Родитель 811176e163
Коммит bf7f97461b
4 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -20,7 +20,7 @@
<maven.plugin-testing.version>3.3.0</maven.plugin-testing.version>
<codehaus.plexus-utils.version>3.0.20</codehaus.plexus-utils.version>
<azure.version>1.1.2</azure.version>
<azure.ai.version>1.0.8</azure.ai.version>
<azure.ai.version>1.0.9</azure.ai.version>
<azure.maven-plugin-lib.version>0.1.4</azure.maven-plugin-lib.version>
<azure.function.version>1.0-SNAPSHOT</azure.function.version>
<azure.storage.version>5.4.0</azure.storage.version>

Просмотреть файл

@ -22,7 +22,7 @@
<azure.version>1.1.2</azure.version>
<azure.client-runtime.version>1.0.4</azure.client-runtime.version>
<azure.client-auth.version>1.0.4</azure.client-auth.version>
<azure.ai.version>1.0.8</azure.ai.version>
<azure.ai.version>1.0.9</azure.ai.version>
<common-net.version>3.6</common-net.version>
<junit.version>4.12</junit.version>
<mockito.version>2.4.0</mockito.version>

Просмотреть файл

@ -24,7 +24,6 @@ import org.apache.maven.shared.filtering.MavenResourcesFiltering;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.rmi.server.ExportException;
import java.util.HashMap;
import java.util.UUID;
@ -202,6 +201,12 @@ public abstract class AbstractAzureMojo extends AbstractMojo implements Telemetr
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// Work around for Application Insights Java SDK:
// Sometimes, NoClassDefFoundError will be thrown even after Maven build is completed successfully.
// An issue has been filed at https://github.com/Microsoft/ApplicationInsights-Java/issues/416
// Before this issue is fixed, set default uncaught exception handler for all threads as work around.
Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
if (isSkipMojo()) {
trackMojoSkip();
return;
@ -264,4 +269,11 @@ public abstract class AbstractAzureMojo extends AbstractMojo implements Telemetr
getLog().error(message);
}
}
protected class DefaultUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
getLog().debug("uncaughtException: " + e);
}
}
}

Просмотреть файл

@ -19,7 +19,7 @@
<maven.plugin-tools.version>3.2</maven.plugin-tools.version>
<maven.plugin-testing.version>3.3.0</maven.plugin-testing.version>
<codehaus.plexus-utils.version>3.0.20</codehaus.plexus-utils.version>
<azure.ai.version>1.0.8</azure.ai.version>
<azure.ai.version>1.0.9</azure.ai.version>
<azure.maven-plugin-lib.version>0.1.4</azure.maven-plugin-lib.version>
<junit.version>4.12</junit.version>
<mockito.version>2.4.0</mockito.version>