From 16ade3081111e453921218fb543c71e486b9fd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Fri, 29 Jul 2016 20:34:57 +0200 Subject: [PATCH] Add a partial fix for #259 where the logline pattern was bogus, in the case a frames returns multiple lines at once. I.e. it fixes this issue https://github.com/fabric8io/docker-maven-plugin/issues/259#issuecomment-233064923 --- doc/changelog.md | 7 +++++-- samples/custom-net/pom.xml | 4 ++-- samples/data-jolokia-demo/pom.xml | 4 ++-- samples/dockerignore/pom.xml | 4 ++-- samples/net/pom.xml | 4 ++-- samples/pom.xml | 2 +- samples/properties/pom.xml | 4 ++-- .../fabric8/maven/docker/access/log/LogRequestor.java | 8 ++++---- .../maven/docker/access/log/LogRequestorTest.java | 11 +++++++++++ 9 files changed, 31 insertions(+), 17 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 78f5cf94c..a8be19eb3 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -1,8 +1,11 @@ # ChangeLog +* **0.15.14** (2016-07-29) + - Pattern match fix for multiline log output. Related to ([#259](https://github.com/fabric8io/docker-maven-plugin/issues/259)) + * **0.15.13** (2016-07-29) - - Add for running containers in special security contexts (#524) - - Add support for multiples network aliases (#466) + - Add for running containers in special security contexts ([#524](https://github.com/fabric8io/docker-maven-plugin/issues/524)) + - Add support for multiples network aliases ([#466](https://github.com/fabric8io/docker-maven-plugin/issues/466)) * **0.15.12** (2016-07-25) - API and documentation updates diff --git a/samples/custom-net/pom.xml b/samples/custom-net/pom.xml index 5c712293d..3ae5342fb 100644 --- a/samples/custom-net/pom.xml +++ b/samples/custom-net/pom.xml @@ -13,12 +13,12 @@ io.fabric8 dmp-sample-parent - 0.15.13 + 0.15.14 ../pom.xml dmp-custom-net - 0.15.13 + 0.15.14 diff --git a/samples/data-jolokia-demo/pom.xml b/samples/data-jolokia-demo/pom.xml index 47b3fca84..34a9cc916 100644 --- a/samples/data-jolokia-demo/pom.xml +++ b/samples/data-jolokia-demo/pom.xml @@ -22,13 +22,13 @@ io.fabric8 dmp-sample-parent - 0.15.13 + 0.15.14 ../pom.xml io.fabric8 docker-jolokia-demo - 0.15.13 + 0.15.14 docker diff --git a/samples/dockerignore/pom.xml b/samples/dockerignore/pom.xml index 3828f4b3b..1619078df 100644 --- a/samples/dockerignore/pom.xml +++ b/samples/dockerignore/pom.xml @@ -10,12 +10,12 @@ io.fabric8 dmp-sample-parent - 0.15.13 + 0.15.14 ../pom.xml dmp-sample-dockerignore - 0.15.13 + 0.15.14 docker-build diff --git a/samples/net/pom.xml b/samples/net/pom.xml index aecc32c67..5e65f2e52 100644 --- a/samples/net/pom.xml +++ b/samples/net/pom.xml @@ -16,12 +16,12 @@ io.fabric8 dmp-sample-parent - 0.15.13 + 0.15.14 ../pom.xml dmp-sample-net - 0.15.13 + 0.15.14 diff --git a/samples/pom.xml b/samples/pom.xml index 9628c32f6..b2cab19dd 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -21,7 +21,7 @@ io.fabric8 dmp-sample-parent - 0.15.13 + 0.15.14 pom http://www.jolokia.org diff --git a/samples/properties/pom.xml b/samples/properties/pom.xml index 82d74da47..525839076 100644 --- a/samples/properties/pom.xml +++ b/samples/properties/pom.xml @@ -10,12 +10,12 @@ io.fabric8 dmp-sample-parent - 0.15.13 + 0.15.14 ../pom.xml dmp-sample-properties - 0.15.13 + 0.15.14 docker-build diff --git a/src/main/java/io/fabric8/maven/docker/access/log/LogRequestor.java b/src/main/java/io/fabric8/maven/docker/access/log/LogRequestor.java index 7a34e845c..c70ba8fc8 100644 --- a/src/main/java/io/fabric8/maven/docker/access/log/LogRequestor.java +++ b/src/main/java/io/fabric8/maven/docker/access/log/LogRequestor.java @@ -1,5 +1,5 @@ package io.fabric8.maven.docker.access.log;/* - * + * * Copyright 2014 Roland Huss * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,7 +44,7 @@ public class LogRequestor extends Thread implements LogGetHandle { // Patter for matching log entries - private static final Pattern LOG_LINE = Pattern.compile("^\\[?([^\\s\\]]*)]?\\s+(.*)\\s*$"); + static final Pattern LOG_LINE = Pattern.compile("^\\[?([^\\s\\]]*)]?\\s+(.*)\\s*$", Pattern.DOTALL); private final HttpClient client; private final String containerId; @@ -58,7 +58,7 @@ public class LogRequestor extends Thread implements LogGetHandle { private HttpUriRequest request; private final UrlBuilder urlBuilder; - + /** * Create a helper object for requesting log entries synchronously ({@link #fetchLogs()}) or asynchronously ({@link #start()}. * @@ -70,7 +70,7 @@ public class LogRequestor extends Thread implements LogGetHandle { public LogRequestor(HttpClient client, UrlBuilder urlBuilder, String containerId, LogCallback callback) { this.client = client; this.containerId = containerId; - + this.urlBuilder = urlBuilder; this.callback = callback; diff --git a/src/test/java/io/fabric8/maven/docker/access/log/LogRequestorTest.java b/src/test/java/io/fabric8/maven/docker/access/log/LogRequestorTest.java index 5024036da..3854d6b00 100644 --- a/src/test/java/io/fabric8/maven/docker/access/log/LogRequestorTest.java +++ b/src/test/java/io/fabric8/maven/docker/access/log/LogRequestorTest.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.regex.Matcher; import com.google.common.base.Charsets; import io.fabric8.maven.docker.access.UrlBuilder; @@ -27,6 +28,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertTrue; public class LogRequestorTest { private static final String containerId = RandomStringUtils.randomAlphabetic(64); @@ -201,6 +203,13 @@ public void testMessageWithExtraBytes() throws Exception { }}; } + @Test + public void checkMutlilinePattern() { + String line = "2016-07-15T20:34:06.024029849Z remote: Compressing objects: 4% (1/23) \n" + + "remote: Compressing objects: 8% (2/23) \n"; + Matcher matcher = LogRequestor.LOG_LINE.matcher(line);; + assertTrue(matcher.matches()); + } private void setupMocks(final InputStream inputStream) throws Exception { new Expectations() {{ RequestUtil.newGet(anyString); @@ -291,4 +300,6 @@ private static ByteBuffer messageToBuffer(Streams stream, String message) throws private static String logMessage(String message) { return String.format("[2015-08-05T12:34:56Z] %s", message); } + + }