Skip to content

Commit 54a5bdf

Browse files
committed
Don't remove empty lines from logs returned by the server.
1 parent d0439ac commit 54a5bdf

File tree

3 files changed

+2
-31
lines changed

3 files changed

+2
-31
lines changed

src/main/java/com/github/cowwoc/docker/internal/util/AsyncResponseListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ protected void processObject(String object)
7070
{
7171
String message = node.textValue();
7272
warnOnUnexpectedProperties(json, "message");
73-
for (String line : Strings.split(message))
74-
log.info(line);
73+
log.info(message);
7574
return;
7675
}
7776
node = json.get("errorDetail");

src/main/java/com/github/cowwoc/docker/internal/util/JsonStreamListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ protected void logMessage(String message, Level level)
159159
{
160160
// Only log the status if it's changed or PROGRESS_FREQUENCY has elapsed
161161
messageToTime.put(message, now);
162-
for (String line : Strings.split(message))
163-
log.atLevel(level).log(line);
162+
log.atLevel(level).log(message);
164163
}
165164
}
166165
}

src/main/java/com/github/cowwoc/docker/internal/util/Strings.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import java.text.DecimalFormat;
44
import java.text.DecimalFormatSymbols;
55
import java.text.NumberFormat;
6-
import java.util.ArrayList;
7-
import java.util.List;
86
import java.util.Locale;
97

108
/**
@@ -31,31 +29,6 @@ public static String format(long value)
3129
return FORMATTER.get().format(value);
3230
}
3331

34-
/**
35-
* Splits a String into multiple lines, omitting any empty lines.
36-
*
37-
* @param lines zero or more lines of text
38-
* @return a collection of lines
39-
* @throws NullPointerException if {@code text} is null
40-
*/
41-
public static List<String> split(String lines)
42-
{
43-
List<String> result = new ArrayList<>();
44-
while (true)
45-
{
46-
int index = lines.indexOf('\n');
47-
if (index == -1)
48-
break;
49-
String line = lines.substring(0, index);
50-
if (!line.isBlank())
51-
result.add(line);
52-
lines = lines.substring(index + 1);
53-
}
54-
if (!lines.isBlank())
55-
result.add(lines);
56-
return result;
57-
}
58-
5932
private Strings()
6033
{
6134
}

0 commit comments

Comments
 (0)