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

[Bug] The command line 'mvn versions:set' returns exit code 1 with the last maven version 3.8.2 #483

Closed
RomainPruvostMHH opened this issue Aug 24, 2021 · 28 comments

Comments

@RomainPruvostMHH
Copy link

Hi,

I have a shell script who runs the command line 'mvn versions:set' and verify the exit code. With my previous Maven 3.6.3, everything works fine.
But I recently upgraded maven to 3.8.2, and now the command line 'mvn versions:set' returns exit code 1 systematically. I precise that the result of the mvn command is BUILD SUCCESS of course.

  mvn versions:set -DgenerateBackupPoms=false -DnewVersion=$mvn_new_version
  exit_code=$?
  if [ $exit_code -ne 0 ]; then
    echo "ERROR : cmd mvn versions:set -DnewVersion=$mvn_new_version failed"
    exit 10
  fi

Any idea ?

Kind regards,
Romain

@slawekjaranowski
Copy link
Member

Can you show output of:

mvn -V versions:set -DnewVersion=1.2.3; echo "result=$?"

I can't see a problem - works for me 😄

@RomainPruvostMHH
Copy link
Author

Hi @slawekjaranowski,

I reproduce the problem with the minimum of files.

With maven 3.6.3, it's ok :
maven-3 6 3-result-ok

With maven 3.8.2, it's KO :
maven-3 8 2-result-ko

@slawekjaranowski
Copy link
Member

ok, last simply test:

 mvn -v; echo "result=$?"

@RomainPruvostMHH
Copy link
Author

maven-commands-results

@slawekjaranowski
Copy link
Member

I don't have any more quick idea ... can you share your test project

@RomainPruvostMHH
Copy link
Author

See in attachment my test project. But it is very simple. Not sure it can help you.
test-maven-3.8.2.zip

@slawekjaranowski
Copy link
Member

I can't reproduce wrong behavior on macos system ... so maybe it is connected with windows os

can you test on maven 3.8.1?

you can also try to write on "Maven User List" or "Maven Developer List"
http://maven.apache.org/mailing-lists.html

@slachiewicz
Copy link
Member

I can reproduce the issue with Windows/MinGW - please send mail to the Maven Developers list

sylwe@DESKTOP-7BCBELM MINGW64 /c/tmp/test-maven-3.8.2
$ uname -a
MINGW64_NT-10.0-22000 DESKTOP-7BCBELM 3.1.7-340.x86_64 2020-10-23 13:08 UTC x86_64 Msys

image
image

@raphaelNguyen
Copy link

raphaelNguyen commented Sep 3, 2021

I also have had this problem. I was on Maven 3.8.1 which was fine. After upgrading to 3.8.2, I started having my scripts failing and noticed the problem. Was able to reproduce it with a very minimalist project with no code and just a pom as follows:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>test</artifactId>
  <version>1.0</version>
</project>

All these are done on the same version of versions-maven-plugin so maybe this is some weird interaction with the new version of maven? Please tell me if I can provide any more information. I'm running maven on git bash for windows.

Same with the previous posts on this issue, the output of set looks identical to the same run on maven 3.8.1. Build was successful as indicated by maven. Only the exit code is 1 instead of 0.

@slawekjaranowski
Copy link
Member

Only out of my curiosity - can anyone trigger build on master branch - now GitHub runners should have Maven 3.8.2

@slawekjaranowski
Copy link
Member

You can also create issue at Apache Jira for Maven project:
https://issues.apache.org/jira/projects/MNG

@RomainPruvostMHH
Copy link
Author

@slawekjaranowski So, you are sure the problem is at Maven and is not at versions plugin ?

@slawekjaranowski
Copy link
Member

I'm not sure - where is the problem but Maven 3.8.2 exposes it ...
I don't have access to host with windows os so I can't reproduce it

Maybe someone else can help with it, I think it is good idea to post on Maven Developers list or create issue at Maven jira.

I heard that new Maven version 3.8.x will be prepared to the end of month - so maybe fix (if needed) will be catched

@RomainPruvostMHH
Copy link
Author

Issue at Apache Maven :

https://issues.apache.org/jira/browse/MNG-7234

@michael-o
Copy link
Member

Need to take a look at it. This is weird. There have been virtually no changes to the startup scripts of Maven in 3.8.2.

@michael-o
Copy link
Member

michael-o commented Sep 7, 2021

Hmmm:

$ ~/apache-maven-3.8.2/bin/mvn -V versions:set -DnewVersion=3 ; echo $?
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /net/home/osipovmi/apache-maven-3.8.2
Java version: 1.8.0_302, vendor: OpenJDK BSD Porting Team, runtime: /usr/local/openjdk8/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "freebsd", version: "12.2-stable", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< com.test:test >----------------------------
[INFO] Building test 2
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.8.1:set (default-cli) @ test ---
[INFO] Local aggregation root: /net/home/osipovmi
[INFO] Processing change of com.test:test:2 -> 3
[INFO] Processing com.test:test
[INFO]     Updating project com.test:test
[INFO]         from version 2 to 3
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.197 s
[INFO] Finished at: 2021-09-07T12:56:26+02:00
[INFO] ------------------------------------------------------------------------
0

Will try MinGW...

@michael-o
Copy link
Member

michael-o commented Sep 7, 2021

MinGW:

$ /c/Entwicklung/Programme/apache-maven-3.8.2/bin/mvn -V versions:set -DnewVersion=4 ; echo $?
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: C:\Entwicklung\Programme\apache-maven-3.8.2
Java version: 1.8.0_275, vendor: Azul Systems, Inc., runtime: C:\Program Files\Zulu\zulu-8\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< com.test:test >----------------------------
[INFO] Building test 2
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.8.1:set (default-cli) @ test ---
[INFO] Local aggregation root: C:\Users\osipovmi
[INFO] Processing change of com.test:test:2 -> 4
[INFO] Processing com.test:test
[INFO]     Updating project com.test:test
[INFO]         from version 2 to 4
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.563 s
[INFO] Finished at: 2021-09-07T13:03:19+02:00
[INFO] ------------------------------------------------------------------------
1

Confirmed, but don't understand it yet.

@michael-o
Copy link
Member

OK, here is the bug (swallowed exceptions) and it in Cygwin only. @gnodet needs to take a look.

Affected object

Flush buffer

Invalid handle

Invalid handle...

@michael-o
Copy link
Member

Note that happens only in MinGW. It does not fail in PowerShell as well as Windows Command Prompt.

@michael-o
Copy link
Member

Debugged a bit further, MinGW (MSYS2) assignes handles 1112 to both stdout and stderr while PowerShell does 84 and 88. Something is either flawed in MSYS2 or in Jansi. So without @gnodet no progress.

@gnodet
Copy link

gnodet commented Sep 8, 2021

@michael-o which call throws the invalid handle exception exactly ?
The uninstall should not close the streams, so the handle should not become invalid...
The 1112 is the file descriptor of the underlying FileOutputStream ?

@michael-o
Copy link
Member

When I enter flushBuffer() specifically out.write(buf, 0, count); fails with the invalid handle.
1112 is not the FD, but the handle. The fd is -1 in this case. I guess Windows uses the handle.

@gnodet
Copy link

gnodet commented Sep 9, 2021

I think the problem is located here:
https://github.com/codehaus-plexus/plexus-interactivity/blob/master/plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultOutputHandler.java#L53

The DefaultOutputHandler should not close the consoleWriter because it will also close the underlying System.out print stream. Those system streams are not supposed to be closed directly.

@gnodet
Copy link

gnodet commented Sep 9, 2021

See codehaus-plexus/plexus-interactivity#3 for a possible fix.

@michael-o
Copy link
Member

Thank you @gnodet I will check tomorrow.

@michael-o
Copy link
Member

Checked now. I can confirm @gnodet's analysis and it correct. Thank you for that. So this is not a bug in Maven or Jansi, they just trigger the bug in Plexus Interactivity.

@michael-o
Copy link
Member

Plexus Interactivity 1.1 has been pushed to Central. Please update at the earliest convenience.

@pigelvy
Copy link

pigelvy commented Jul 13, 2022

This issue has been fixed since r2.9.0 by #488.

To assert that, execute the following commands:

  • path/to/maven/3.8.2+/bin/mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:set -DnewVersion=XYZ; echo $? returns 1
  • path/to/maven/3.8.2+/bin/mvn org.codehaus.mojo:versions-maven-plugin:2.9.0:set -DnewVersion=XYZ; echo $? returns 0

IMO, this issue could be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants