Configured the code to work with Java 6 standards and using gradlew

This commit is contained in:
Guy Peleg 2014-12-11 10:26:42 +02:00
Родитель b45a270e0f
Коммит 35fb871175
7 изменённых файлов: 34 добавлений и 21 удалений

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="AppInsights Java" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
@ -14,9 +14,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Gradle: junit-4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: hamcrest-core-1.3" level="project" />
<orderEntry type="module" module-name="Core" exported="" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
</module>

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="AppInsights Java" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":Core" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="AppInsights Java" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
@ -14,13 +14,12 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Gradle: junit-4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="Gradle: commons-lang3-3.3.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: httpclient-4.3.5" level="project" />
<orderEntry type="library" exported="" name="Gradle: httpcore-4.3.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: commons-logging-1.1.3" level="project" />
<orderEntry type="library" exported="" name="Gradle: commons-codec-1.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.commons:commons-lang3:3.3.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.httpcomponents:httpclient:4.3.5" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.httpcomponents:httpcore:4.3.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: commons-logging:commons-logging:1.1.3" level="project" />
<orderEntry type="library" exported="" name="Gradle: commons-codec:commons-codec:1.6" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
</module>

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

@ -50,15 +50,31 @@ public class SimpleHttpChannel implements TelemetryChannel
CloseableHttpClient httpClient = HttpClients.createDefault();
try (CloseableHttpResponse response = httpClient.execute(request))
CloseableHttpResponse response = null;
try
{
response = httpClient.execute(request);
HttpEntity respEntity = response.getEntity();
if (respEntity != null)
respEntity.getContent().close();
if (developerMode) System.out.println("Status: " + response.getStatusLine());
}
catch (IOException ioe)
{
ioe.printStackTrace(System.err);
try
{
if (response != null)
{
response.close();
}
}
catch (IOException ioeIn)
{
ioeIn.printStackTrace(System.err);
}
}
}
catch (IOException ioe)
{

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

@ -191,7 +191,7 @@ public class ExceptionTelemetry extends BaseTelemetry
private void updateException(Exception exception)
{
ArrayList<ExceptionDetails> exceptions = new ArrayList<>();
ArrayList<ExceptionDetails> exceptions = new ArrayList<ExceptionDetails>();
convertExceptionTree(exception, null, exceptions);
this.data.setExceptions(exceptions);

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

@ -16,7 +16,7 @@ public class TelemetryConfiguration
private String instrumentationKey;
private final List<ContextInitializer> contextInitializers = new ArrayList<>();
private final List<ContextInitializer> contextInitializers = new ArrayList<ContextInitializer>();
private TelemetryChannel channel;
private boolean trackingIsDisabled = true;

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

@ -1,4 +1,3 @@
apply plugin: 'java'
jar {

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

@ -16,7 +16,7 @@ class Program
TelemetryClient appInsights = new TelemetryClient();
appInsights.getContext().getProperties().put("programmatic", "works");
Map<String, Double> metrics = new HashMap<>();
Map<String, Double> metrics = new HashMap<String, Double>();
metrics.put("Answers", (double)15);
appInsights.trackEvent("A test event", null, metrics);