Skip to content

Commit 0138685

Browse files
authored
Java7fix (#496)
* Fixes java7 complaints * remove unused imports * set source/target compatibility options regardless of the JAVA_JRE_7 variable
1 parent 75f6b6e commit 0138685

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

gradle/common-java.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat;
2727

2828
apply plugin: 'java'
2929

30+
tasks.withType(JavaCompile) {
31+
sourceCompatibility = 1.7
32+
targetCompatibility = 1.7
33+
}
34+
35+
// setting this variable is highly recommended
3036
def java7JreDir = System.env.'JAVA_JRE_7'
3137
if (java7JreDir) {
3238
def requiredJavaBootArchives = ["rt.jar", "jsse.jar"]
@@ -40,8 +46,6 @@ if (java7JreDir) {
4046
bootClasspath += "$archivePath;"
4147
}
4248
tasks.withType(JavaCompile) {
43-
sourceCompatibility = 1.7
44-
targetCompatibility = 1.7
4549
options.bootClasspath = bootClasspath
4650
}
4751
} else {

web/src/main/java/com/microsoft/applicationinsights/web/extensibility/initializers/WebOperationIdTelemetryInitializer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ protected void onInitializeTelemetry(Telemetry telemetry) {
7070
// add correlation context to properties
7171
Map<String, String> correlationContextMap = telemetryContext.getCorrelationContext().getMappings();
7272
for (String key : correlationContextMap.keySet()) {
73-
telemetry.getProperties().putIfAbsent(key, correlationContextMap.get(key));
73+
if (telemetry.getProperties().get(key) == null) {
74+
telemetry.getProperties().put(key, correlationContextMap.get(key));
75+
}
7476
}
7577
}
7678
}

web/src/test/java/com/microsoft/applicationinsights/web/internal/correlation/mocks/MockHttpAsyncClientWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
package com.microsoft.applicationinsights.web.internal.correlation.mocks;
2323

2424
import org.apache.http.nio.client.HttpAsyncClient;
25-
import org.apache.http.ProtocolVersion;
2625
import org.apache.http.client.methods.HttpUriRequest;
26+
import org.apache.http.concurrent.FutureCallback;
2727

2828
import static org.mockito.Matchers.*;
2929
import static org.mockito.Mockito.mock;
@@ -45,7 +45,7 @@ public MockHttpAsyncClientWrapper() {
4545

4646
this.mockClient = mock(HttpAsyncClient.class);
4747

48-
when(mockClient.execute(any(HttpUriRequest.class), any())).thenReturn(this.task);
48+
when(mockClient.execute(any(HttpUriRequest.class), any(FutureCallback.class))).thenReturn(this.task);
4949
}
5050

5151
public void setAppId(String appId) {

web/src/test/java/com/microsoft/applicationinsights/web/utils/ServletUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static HttpServletRequest createServletRequestWithHeaders(Map<String, Str
8282
return createServletRequestWithHeaders(headers, 0);
8383
}
8484

85-
public static HttpServletRequest createServletRequestWithHeaders(Map<String, String> headers, int correlationContextHeaderCount) {
85+
public static HttpServletRequest createServletRequestWithHeaders(Map<String, String> headers, final int correlationContextHeaderCount) {
8686
HttpServletRequest request = mock(HttpServletRequest.class);
8787

8888
for (String headerName : headers.keySet()) {

0 commit comments

Comments
 (0)