apache / apache/maven-mvnd

Cannot invoke "org.apache.maven.logging.LoggingOutputStream.forceFlush()" because "this.out" is null

Open
#1,271 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.5k
Forks
250
Avg merge
16h 22m
Merged PRs (30d)
36

Description

I'm running into a strange issue with [spotless](https://github.com/diffplug/spotless) where `mvnd` is throwing what looks like an NPE after the goal completes:

```
$ mvnd spotless:apply -DspotlessIdeHook=/home/jay/Projects/mvnd-npe-repro/src/main/java/com/mycompany/app/App.java
[INFO] Processing build on daemon 280ce708
[INFO] Scanning for projects...
[INFO] BuildTimeEventSpy is registered.
[INFO]
[INFO] Using the SmartBuilder implementation with a thread count of 15
[INFO]
[INFO] -----------------------------------------------< com.mycompany.app:my-app >-----------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] ---------------------------------------------------------[ jar ]----------------------------------------------------------
[INFO]
[INFO] --- spotless:2.44.2:apply (default-cli) @ my-app ---
[INFO] Index file does not exist. Fallback to an empty index
[WARNING] [stderr] IS CLEAN
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] Total time: 0.193 s (Wall Clock)
[INFO] Finished at: 2025-02-14T21:28:56Z
[INFO] --------------------------------------------------------------------------------------------------------------------------
[ERROR] Error executing Maven Daemon.
[ERROR] Cannot invoke "org.apache.maven.logging.LoggingOutputStream.forceFlush()" because "this.out" is null
```

I've put together a minimal-ish repro here: https://github.com/SapiensAnatis/mvnd-npe-repro. It'll download Spotless as I wasn't confident I'd be able to work out exactly what Spotless is doing to trigger this and recreate it with a custom goal, so it's not truly minimal, but I hope it's a good start.

The file is formatted as expected so it looks to be an error during cleanup. If I remove the `-DspotlessIdeHook` flag, I don't get the NPE anymore.

This happens in 1.0.2, and I also built the latest commit from `master` where it still reproduces.

It does not reproduce on regular `mvn` (3.9.9) if I substitute that in the command above.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked mvnd-npe-repro and run `mvnd spotless:apply -DspotlessIdeHook=...` using the reported setup. Compare the daemon run with regular Maven 3.9.9, focusing on cleanup after the successful goal and the `LoggingOutputStream.forceFlush()` failure. Done means the repro completes without the post-build error while the file remains formatted.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.