Skip to content

Commit 74a8e20

Browse files
committed
last update
1 parent add7e0c commit 74a8e20

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3OutputStreamWriteIntAdvice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public static boolean methodEnter(
2626
// if handleWrite return true, then it means the injection has happened and the 'write'
2727
// manipulate is done. the function would return false then, meaning skip the original write
2828
// function
29-
return !handleWrite(state, servletOutputStream, (byte) write);
29+
return !handleWrite(state, servletOutputStream, write);
3030
}
3131
}

instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/Injection.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ public class Injection {
1515
public static void initializeInjectionStateIfNeeded(
1616
ServletOutputStream servletOutputStream, SnippetInjectingResponseWrapper wrapper) {
1717
InjectionState state = virtualField.get(servletOutputStream);
18+
if (!wrapper.isContentTypeTextHtml()) {
19+
virtualField.set(servletOutputStream, null);
20+
return;
21+
}
1822
if (state == null || state.getWrapper() != wrapper) {
1923
state = new InjectionState(wrapper);
20-
if (wrapper.isContentTypeTextHtml()) {
21-
virtualField.set(servletOutputStream, state);
22-
}
24+
virtualField.set(servletOutputStream, state);
2325
}
2426
}
2527

instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import javax.servlet.http.HttpServletResponseWrapper;
2222

2323
public class SnippetInjectingResponseWrapper extends HttpServletResponseWrapper {
24+
private static final Logger logger = Logger.getLogger(HttpServletResponseWrapper.class.getName());
2425
public static final String FAKE_SNIPPET_HEADER = "FAKE_SNIPPET_HEADER";
2526
private static final String SNIPPET = SnippetHolder.getSnippet();
2627
private static final int SNIPPET_LENGTH = SNIPPET.length();
28+
@Nullable private static final MethodHandle setContentLengthLongHandler = getMethodHandle();
2729

28-
private static final Logger logger = Logger.getLogger(HttpServletResponseWrapper.class.getName());
2930
private SnippetInjectingPrintWriter snippetInjectingPrintWriter = null;
30-
@Nullable private static final MethodHandle setContentLengthLongHandler = getMethodHandle();
3131

3232
public SnippetInjectingResponseWrapper(HttpServletResponse response) {
3333
super(response);

instrumentation/servlet/servlet-common/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/servlet/SnippetHolder.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
package io.opentelemetry.javaagent.bootstrap.servlet;
77

88
import java.io.UnsupportedEncodingException;
9-
import java.nio.charset.Charset;
10-
import javax.annotation.Nullable;
119

1210
public class SnippetHolder {
1311

@@ -21,12 +19,7 @@ public static String getSnippet() {
2119
return snippet;
2220
}
2321

24-
public static byte[] getSnippetBytes(@Nullable String encoding)
25-
throws UnsupportedEncodingException {
26-
if (encoding != null) {
27-
return snippet.getBytes(encoding);
28-
} else {
29-
return snippet.getBytes(Charset.defaultCharset());
30-
}
22+
public static byte[] getSnippetBytes(String encoding) throws UnsupportedEncodingException {
23+
return snippet.getBytes(encoding);
3124
}
3225
}

0 commit comments

Comments
 (0)