Skip to content

Commit 61da774

Browse files
committed
perf(appsec): skip attribute I/O in Netty multipart when body callback is absent
When only requestFilesContent is registered, avoid calling getValue() on form attributes (which may trigger disk reads for large fields).
1 parent 42953b1 commit 61da774

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

dd-java-agent/instrumentation/netty/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/HttpPostRequestDecoderInstrumentation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ static void after(
119119

120120
RuntimeException exc = null;
121121

122-
Map<String, List<String>> attributes = new LinkedHashMap<>();
122+
Map<String, List<String>> attributes = callback != null ? new LinkedHashMap<>() : null;
123123
List<String> filenames = new ArrayList<>();
124124
List<String> filesContent = contentCb != null ? new ArrayList<>() : null;
125125
for (InterfaceHttpData data : thiz.getBodyHttpDatas()) {
126-
if (data.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) {
126+
if (attributes != null
127+
&& data.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) {
127128
String name = data.getName();
128129
List<String> values = attributes.get(name);
129130
if (values == null) {

0 commit comments

Comments
 (0)