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

NPE when logging to file #911

Closed
hho opened this issue Dec 14, 2017 · 1 comment · Fixed by #940
Closed

NPE when logging to file #911

hho opened this issue Dec 14, 2017 · 1 comment · Fixed by #940
Labels

Comments

@hho
Copy link
Contributor

hho commented Dec 14, 2017

Description

When logging to a file and starting a container early in the build, a NullPointerException is thrown:

Exception in thread "Thread-1" java.lang.NullPointerException
	at io.fabric8.maven.docker.log.DefaultLogCallback.ps(DefaultLogCallback.java:74)
	at io.fabric8.maven.docker.log.DefaultLogCallback.error(DefaultLogCallback.java:84)
	at io.fabric8.maven.docker.access.log.LogRequestor.run(LogRequestor.java:110)

Info

  • d-m-p version: 0.23.0
  • Maven version (mvn -v):
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T09:58:13+02:00)
Maven home: /home/hho/.sdkman/candidates/maven/current
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.13.0-19-generic", arch: "amd64", family: "unix"
  • Docker version: 17.11.0-ce
  • If it's a bug, how to reproduce:
    1. Use the POM given below
    2. run mvn compile
POM to reproduce
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>demo</groupId>
  <artifactId>npedemo</artifactId>
  <version>1.0-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>0.23.0</version>
        <configuration>
          <images>
            <image>
              <name>postgres:alpine</name>
              <run>
                <log>
                  <file>${project.build.directory}/postgres.log</file>
                </log>
              </run>
            </image>
          </images>
        </configuration>
        <executions>
          <execution>
            <id>start-db</id>
            <phase>generate-sources</phase>
            <goals><goal>start</goal></goals>
          </execution>
          <execution>
            <id>stop-db</id>
            <phase>generate-resources</phase>
            <goals><goal>stop</goal></goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
Example Build Output
➜ mvn compile
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building npedemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- docker-maven-plugin:0.23.0:start (start-db) @ npedemo ---
[INFO] DOCKER> [postgres:alpine]: Start container 69f9e99da85e
Exception in thread "Thread-1" java.lang.NullPointerException
	at io.fabric8.maven.docker.log.DefaultLogCallback.ps(DefaultLogCallback.java:74)
	at io.fabric8.maven.docker.log.DefaultLogCallback.error(DefaultLogCallback.java:84)
	at io.fabric8.maven.docker.access.log.LogRequestor.run(LogRequestor.java:110)
[INFO] 
[INFO] --- docker-maven-plugin:0.23.0:stop (stop-db) @ npedemo ---
[INFO] DOCKER> [postgres:alpine]: Stop and removed container 69f9e99da85e after 0 ms
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ npedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/npedemo/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ npedemo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /tmp/npedemo/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.681 s
[INFO] Finished at: 2017-12-14T17:28:47+01:00
[INFO] Final Memory: 21M/360M
[INFO] ------------------------------------------------------------------------
@rhuss rhuss added the bug label Dec 14, 2017
@rhuss
Copy link
Collaborator

rhuss commented Dec 14, 2017

Thanks, good finding. Indeed there can be a race and should be protected.

@ghost ghost mentioned this issue Feb 7, 2018
@rhuss rhuss closed this as completed in #940 Feb 8, 2018
rhuss added a commit that referenced this issue Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants