public static void convertAttachment(
            DefaultHttp2Headers headers, Map<String, Object> attachments, boolean needConvertHeaderKey) {
        if (attachments == null) {
            return;
        }
        Map<String, String> needConvertKey = new HashMap<>();
        for (Map.Entry<String, Object> entry : attachments.entrySet()) {
            String key = lruHeaderMap.get(entry.getKey());
            if (key == null) {
                final String lowerCaseKey = entry.getKey().toLowerCase(Locale.ROOT);
                lruHeaderMap.put(entry.getKey(), lowerCaseKey);
                key = lowerCaseKey;
            }
            if (TripleHeaderEnum.containsExcludeAttachments(key)) {
                continue;
            }
            final Object v = entry.getValue();
            if (v == null) {
                continue;
            }
            if (needConvertHeaderKey && !key.equals(entry.getKey())) {
                needConvertKey.put(key, entry.getKey());
            }
            convertSingleAttachment(headers, key, v);
        }
        if (!needConvertKey.isEmpty()) {
            String needConvertJson = JsonUtils.toJson(needConvertKey);
            headers.add(TripleHeaderEnum.TRI_HEADER_CONVERT.getHeader(), TriRpcStatus.encodeMessage(needConvertJson));
        }
    }
@Test
    void testConvertAttachment() throws InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        DefaultHttp2Headers headers = new DefaultHttp2Headers();
        headers.add("key", "value");

        Map<String, Object> attachments = new HashMap<>();
        attachments.put(TripleHeaderEnum.PATH_KEY.getHeader(), "value");
        attachments.put("key1111", "value");
        attachments.put("Upper", "Upper");
        attachments.put("obj", new Object());

        StreamUtils.convertAttachment(headers, attachments, false);
        Assertions.assertNull(headers.get(TripleHeaderEnum.PATH_KEY.getHeader()));
        Assertions.assertNull(headers.get("Upper"));
        Assertions.assertNull(headers.get("obj"));

        headers = new DefaultHttp2Headers();
        headers.add("key", "value");

        StreamUtils.convertAttachment(headers, attachments, true);
        Assertions.assertNull(headers.get(TripleHeaderEnum.PATH_KEY.getHeader()));
        Assertions.assertNull(headers.get("Upper"));
        Assertions.assertNull(headers.get("obj"));
        String jsonRaw =
                headers.get(TripleHeaderEnum.TRI_HEADER_CONVERT.getHeader()).toString();
        String json = TriRpcStatus.decodeMessage(jsonRaw);
        System.out.println(jsonRaw + "---" + json);
        Map<String, String> upperMap = JsonUtils.toJavaObject(json, Map.class);
        Assertions.assertArrayEquals(
                "Upper".getBytes(StandardCharsets.UTF_8), upperMap.get("upper").getBytes(StandardCharsets.UTF_8));

        int count = 10000;
        CountDownLatch latch = new CountDownLatch(count);
        for (int i = 0; i < count; i++) {
            String randomKey = "key" + i;
            String randomValue = "value" + i;
            Map<String, Object> attachments2 = new HashMap<>();
            attachments2.put(TripleHeaderEnum.PATH_KEY.getHeader(), "value");
            attachments2.put("key1111", "value");
            attachments2.put("Upper", "Upper");
            attachments2.put("obj", new Object());
            attachments2.put(randomKey, randomValue);
            executorService.execute(() -> {
                DefaultHttp2Headers headers2 = new DefaultHttp2Headers();
                headers2.add("key", "value");
                StreamUtils.convertAttachment(headers2, attachments2, true);

                if (headers2.get(TripleHeaderEnum.PATH_KEY.getHeader()) != null) {
                    return;
                }
                if (headers2.get("Upper") != null) {
                    return;
                }
                if (headers2.get("obj") != null) {
                    return;
                }
                if (!headers2.get(randomKey).toString().equals(randomValue)) {
                    return;
                }
                latch.countDown();
            });
        }
        latch.await(10, TimeUnit.SECONDS);
        Assertions.assertEquals(0, latch.getCount());
        executorService.shutdown();
    }