testcontainers / testcontainers/testcontainers-java

[Bug]: HttpWaitStrategy removes line breaks in http response body before responsePredicate invocation

オープン 初心者向け
#7,326 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

resolution/waiting-for-info type/bug
主要言語
Java
スター
8.7k
フォーク
1.9k
平均マージ
2日 17時間
マージ済み PR(30日)
9

説明

Module

Core

Testcontainers version

1.18.3

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host Arch

x86

Docker version
Client:
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        20.10.21-0ubuntu1~22.04.3
 Built:             Thu Apr 27 05:57:17 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       20.10.21-0ubuntu1~22.04.3
  Built:            Thu Apr 27 05:37:25 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.12-0ubuntu1~22.04.3
  GitCommit:        
 runc:
  Version:          1.1.4-0ubuntu1~22.04.3
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:
What happened?

for some reason, the HttpWaitStrategy reads the response line by line, but does not save the line break characters. In some cases it is really bad, for example, parsing the prometheus metric of springboot application becomes a nightmare.

from org.testcontainers.containers.wait.strategy.HttpWaitStrategy

   private String getResponseBody(HttpURLConnection connection) throws IOException {
        BufferedReader reader;
        if (200 <= connection.getResponseCode() && connection.getResponseCode() <= 299) {
            reader = new BufferedReader(new InputStreamReader((connection.getInputStream())));
        } else {
            reader = new BufferedReader(new InputStreamReader((connection.getErrorStream())));
        }

        StringBuilder builder = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            builder.append(line);  // THIS ROW!!!!!!!
        }
        return builder.toString();
    }
Relevant log output

No response

Additional Information

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

org.testcontainers.containers.wait.strategy.HttpWaitStrategy から始め、getResponseBody と responsePredicate の呼び出しに注目してください。複数行の HTTP response で動作を再現し、その後、responsePredicate が改行を受け取ること、および関連する Core wait-strategy tests が通ることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
docker, java
領域
testing
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。