Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-72011] MavenConsoleParser: do not read from empty stream #944

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ protected void preprocessLine(final String line) {
if (goalMatcher.find()) {
goal = String.format("%s:%s", goalMatcher.group("id"), goalMatcher.group("goal"));
}
else if (line.contains("[INFO] BUILD ")) {
goal = StringUtils.EMPTY; // reset goal after build
}

Matcher moduleMatcher = MAVEN_MODULE_START.matcher(line);
if (moduleMatcher.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStre
int length = StringUtils.length(timestamp);

String continuation = "^(?:.*\\s|)\\[(INFO|WARNING|ERROR)";
while (!lookahead.hasNext(continuation)) {
while (lookahead.hasNext() && !lookahead.hasNext(continuation)) {
message.append('\n');
message.append(StringUtils.substring(lookahead.next(), length));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ protected MavenConsoleParserTest() {
super("maven-console.txt");
}

@Test
void issue72011MavenEnforcerExceptionWhenEmpty() {
var report = parse("issue72011.txt");
assertThat(report).hasSize(1);
assertThat(report.get(0)).hasModuleName("-");

assertThat(parse("enforcer-empty.txt")).hasSize(1);
}

@Test
void issue70658RemovePrefixAndSuffixFromMavenPlugins() {
Report warnings = parse("maven.3.9.1.log");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[2023-09-13T11:34:06.033Z] [INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-maven) @ tframe-tgate-root ---
[2023-09-13T11:34:06.033Z] [WARNING] Downloading from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-api/3.0.0-M3/enforcer-api-3.0.0-M3.pom
27 changes: 27 additions & 0 deletions src/test/resources/edu/hm/hafner/analysis/parser/issue72011.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[2023-09-13T11:34:06.033Z] [INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-maven) @ tframe-tgate-root ---
[2023-09-13T11:34:06.033Z] [INFO] Downloading from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-api/3.0.0-M3/enforcer-api-3.0.0-M3.pom
[2023-09-13T11:34:06.033Z] [INFO] Downloaded from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-api/3.0.0-M3/enforcer-api-3.0.0-M3.pom (2.8 kB at 123 kB/s)
[2023-09-13T11:34:06.033Z] [INFO] Downloading from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-rules/3.0.0-M3/enforcer-rules-3.0.0-M3.pom
[2023-09-13T11:34:06.033Z] [INFO] Downloaded from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-rules/3.0.0-M3/enforcer-rules-3.0.0-M3.pom (4.1 kB at 295 kB/s)
[2023-09-13T11:34:06.033Z] [INFO] Downloading from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/commons-codec/commons-codec/1.12/commons-codec-1.12.pom
[2023-09-13T11:34:06.033Z] [INFO] Downloaded from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/commons-codec/commons-codec/1.12/commons-codec-1.12.pom (14 kB at 1.2 MB/s)
[2023-09-13T11:34:06.033Z] [INFO] Downloading from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-api/3.0.0-M3/enforcer-api-3.0.0-M3.jar
[2023-09-13T11:34:06.033Z] [INFO] Downloading from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/commons-codec/commons-codec/1.12/commons-codec-1.12.jar
[2023-09-13T11:34:06.033Z] [INFO] Downloading from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-rules/3.0.0-M3/enforcer-rules-3.0.0-M3.jar
[2023-09-13T11:34:06.033Z] [INFO] Downloaded from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-api/3.0.0-M3/enforcer-api-3.0.0-M3.jar (12 kB at 585 kB/s)
[2023-09-13T11:34:06.033Z] [INFO] Downloaded from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/org/apache/maven/enforcer/enforcer-rules/3.0.0-M3/enforcer-rules-3.0.0-M3.jar (107 kB at 5.1 MB/s)
[2023-09-13T11:34:06.033Z] [INFO] Downloaded from magenta-mirror: https://bin.t-mobile.at/artifactory/maven/commons-codec/commons-codec/1.12/commons-codec-1.12.jar (340 kB at 12 MB/s)
[2023-09-13T11:34:06.033Z] [INFO] ------------------------------------------------------------------------
[2023-09-13T11:34:06.033Z] [INFO] Reactor Summary:
[2023-09-13T11:34:06.033Z] [INFO]
[2023-09-13T11:34:06.033Z] [INFO] webapi ............................................. SUCCESS [ 17.201 s]
[2023-09-13T11:34:06.033Z] [INFO] oauth2 ............................................. SUCCESS [23:15 min]
[2023-09-13T11:34:06.033Z] [INFO] tframe-tgate-root 23.09.19-SNAPSHOT ................ SUCCESS [ 0.149 s]
[2023-09-13T11:34:06.033Z] [INFO] ------------------------------------------------------------------------
[2023-09-13T11:34:06.033Z] [INFO] BUILD SUCCESS
[2023-09-13T11:34:06.033Z] [INFO] ------------------------------------------------------------------------
[2023-09-13T11:34:06.033Z] [INFO] Total time: 23:34 min
[2023-09-13T11:34:06.033Z] [INFO] Finished at: 2023-09-13T11:34:06Z
[2023-09-13T11:34:06.033Z] [INFO] ------------------------------------------------------------------------
[2023-09-13T11:34:06.033Z] [WARNING] The requested profile "with-jacoco" could not be activated because it does not exist.
[Pipeline] }
Loading