Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions AppInsights Java.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually our repo should not include IDE specific files to allow anyone use their own tool of choice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about it. C# has the .sln file.
If we go with Intellij then we need to share a few files

please read: #1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Net sln files are used to list the projects to build.
However, as in this project we're using build.gradle as long as IntelliJ knows how to import the project from then I'm not sure that these files are really needed

<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" />
Expand All @@ -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>
19 changes: 9 additions & 10 deletions Core/Core.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above - we should generally refrain from submitting IDE specific files

<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" />
Expand All @@ -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" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you might have done it already but please make sure that we're including the libraries required for our SDK

<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>
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,31 @@ public void send(Telemetry item)

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check whether the common practices for single statement block is to add curly parentheses or not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, my guess is that opening should be on the line and not in a new line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we decide i did what is done in the project to make sure there is unification

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I was referring to using a one-line statements inside the 'if' statement vs. using a statement block using curly parentheses

respEntity.getContent().close();

if (developerMode) System.out.println("Status: " + response.getStatusLine());
}

catch (IOException ioe)
{
ioe.printStackTrace(System.err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure that an SDK should print anything to System.err.
Shouldn't it just trace it using a logger?

try
{
if (response != null)
{
response.close();
}
}
catch (IOException ioeIn)
{
ioeIn.printStackTrace(System.err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above regarding printing to System.err

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a version that aligns with SE 6
This is why I used what is already used throughout the Project.

We will need to tackle that issue in the near future. But for now I think it is out of scope

}
}
}
catch (IOException ioe)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void serialize(StackFrame frame, JsonWriter writer) throws IOException

private void updateException(Exception exception)
{
ArrayList<ExceptionDetails> exceptions = new ArrayList<>();
ArrayList<ExceptionDetails> exceptions = new ArrayList<ExceptionDetails>();
convertExceptionTree(exception, null, exceptions);

this.data.setExceptions(exceptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apply plugin: 'java'

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void main(String[] args) throws IOException
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);
Expand Down