Skip to content

Commit

Permalink
Add a partial fix for #259
Browse files Browse the repository at this point in the history
where the logline pattern was bogus, in the case a frames returns
multiple lines at once.

I.e. it fixes this issue #259 (comment)
  • Loading branch information
rhuss committed Jul 29, 2016
1 parent 083322c commit 16ade30
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 17 deletions.
7 changes: 5 additions & 2 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -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 <securityOpts> for running containers in special security contexts (#524)
- Add support for multiples network aliases (#466)
- Add <securityOpts> 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
Expand Down
4 changes: 2 additions & 2 deletions samples/custom-net/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>dmp-sample-parent</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>dmp-custom-net</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>

<build>
<plugins>
Expand Down
4 changes: 2 additions & 2 deletions samples/data-jolokia-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>dmp-sample-parent</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>io.fabric8</groupId>
<artifactId>docker-jolokia-demo</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<!-- add custom lifecycle -->
<packaging>docker</packaging>

Expand Down
4 changes: 2 additions & 2 deletions samples/dockerignore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>dmp-sample-parent</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>dmp-sample-dockerignore</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<packaging>docker-build</packaging>

<build>
Expand Down
4 changes: 2 additions & 2 deletions samples/net/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>dmp-sample-parent</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>dmp-sample-net</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>

<profiles>
<profile>
Expand Down
2 changes: 1 addition & 1 deletion samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>io.fabric8</groupId>
<artifactId>dmp-sample-parent</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<packaging>pom</packaging>

<url>http://www.jolokia.org</url>
Expand Down
4 changes: 2 additions & 2 deletions samples/properties/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>dmp-sample-parent</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>dmp-sample-properties</artifactId>
<version>0.15.13</version>
<version>0.15.14</version>
<packaging>docker-build</packaging>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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()}.
*
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


}

0 comments on commit 16ade30

Please sign in to comment.