You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tibor Digana <ti...@apache.org> on 2020/09/30 11:33:30 UTC
Re: 'mvn clean test' crashes
Hi Mukul,
Sorry for my late reply.
I am checking pending emails.
Usually these errors appear in the test itself or the *libraries*.
As for instance, we found out that a Spring's library is implementing Kafka
stuff calling the "Runtime.getRuntime().halt( <int> )".
The same bad thing is to call the "System.exit(<int>)".
I have recognized this situation after I saw a crashed test in your logs.
The test is supposed to be crashed if the execution breaks abruptly without
receiving a JUnit/TestNG event about finishing the test, see this log:
*[ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.t*
*est.SuspiciousActivityHelperTe**st*
T
On Tue, Jul 28, 2020 at 8:49 AM Mukul Gandhi <ga...@gmail.com> wrote:
> On Tue, Jul 7, 2020 at 5:49 PM Gary Gregory <ga...@gmail.com>
> wrote:
>
> > I've tried to deal with JVM crashes in the FailSafe (I was not having the
> > problem in SureFire) plugin by using:
> >
> > <plugin>
> > <groupId>org.apache.maven.plugins</groupId>
> > <artifactId>maven-failsafe-plugin</artifactId>
> > <version>${hmp.failsafe.version}</version>
> > <configuration>
> > <forkCount>1</forkCount>
> > <reuseForks>false</reuseForks>
> > </configuration>
> > </plugin>
> >
>
> I also ran the command 'mvn verify', by exactly specifying above within my
> Maven project's pom.xml file (and specifying the version
> as <version>3.0.0-M5</version>), and got the same kind of build failure
> errors, as I've mentioned in my previous post on this list.
>
> Any further thoughts, about how to solve the problems I'm facing as
> specified within this thread, would be appreciated.
>
>
>
> --
> Regards,
> Mukul Gandhi
>
Re: 'mvn clean test' crashes
Posted by Tibor Digaňa <ti...@googlemail.com.INVALID>.
Hi Mukul, the problem with System.exit() can be in a library - dependency,
not only in your code and therefore the system manager has to be configured
in system property in order to find and confirm the hypothesis. T
Dňa pi 9. 10. 2020, 18:01 Enrico Olivelli <eo...@gmail.com> napísal(a):
> Something like this:
>
> public class NoExitSecurityManager extends SecurityManager {
>
> private final SecurityManager wrapped;
>
> public static void setup() {
> Policy.setPolicy(new Policy() {
>
> final Permissions pc = new Permissions();
>
> {
> pc.add(new AllPermission());
> }
>
> @Override
> public boolean implies(ProtectionDomain domain, Permission
> permission) {
> return true;
> }
>
> @Override
> public PermissionCollection getPermissions(ProtectionDomain
> domain) {
> return pc;
> }
>
> @Override
> public PermissionCollection getPermissions(CodeSource
> codesource) {
> return pc;
> }
>
> });
> System.setSecurityManager(new NoExitSecurityManager());
> }
>
> public NoExitSecurityManager() {
> wrapped = new SecurityManager();
> }
>
> public NoExitSecurityManager(SecurityManager wrapped) {
> this.wrapped = wrapped;
> }
>
> @Override
> public void checkExit(int status) {
> StackTraceElement[] stackTrace =
> Thread.currentThread().getStackTrace();
> if (stackTrace != null) {
> for (StackTraceElement el : stackTrace) {
> String className = el.getClassName();
> if (className != null
> &&
> className.startsWith("org.apache.maven.surefire.booter.ForkedBooter")
> && ("acknowledgedExit".equals(el.getMethodName())
> || "exit".equals(el.getMethodName()))) {
> return;
> }
> }
> }
> throw new SecurityException("System.exit is disabled on unit
> tests");
>
> }
>
> @Override
> public void checkPermission(Permission perm) {
> if (wrapped == null) {
> return;
> }
> if (perm instanceof FilePermission) {
> // preveniamo errori su Jenkins
> return;
> }
> if (perm instanceof ReflectPermission) {
> return;
> }
> wrapped.checkPermission(perm);
> }
>
> }
>
> Il giorno ven 9 ott 2020 alle ore 09:19 Mukul Gandhi <
> gandhi.mukul@gmail.com>
> ha scritto:
>
> > On Wed, Oct 7, 2020 at 9:09 PM Enrico Olivelli <eo...@gmail.com>
> > wrote:
> >
> > > A good approach to workaround the presence of third party libraries
> that
> > > call System.exit is to set a SecurityManager that prevents calls to
> > > System.exit.
> >
> >
> > I'll find it helpful, if you may share any code sample how to do this?
> >
> >
> >
> > --
> > Regards,
> > Mukul Gandhi
> >
>
Re: 'mvn clean test' crashes
Posted by Enrico Olivelli <eo...@gmail.com>.
Something like this:
public class NoExitSecurityManager extends SecurityManager {
private final SecurityManager wrapped;
public static void setup() {
Policy.setPolicy(new Policy() {
final Permissions pc = new Permissions();
{
pc.add(new AllPermission());
}
@Override
public boolean implies(ProtectionDomain domain, Permission
permission) {
return true;
}
@Override
public PermissionCollection getPermissions(ProtectionDomain
domain) {
return pc;
}
@Override
public PermissionCollection getPermissions(CodeSource
codesource) {
return pc;
}
});
System.setSecurityManager(new NoExitSecurityManager());
}
public NoExitSecurityManager() {
wrapped = new SecurityManager();
}
public NoExitSecurityManager(SecurityManager wrapped) {
this.wrapped = wrapped;
}
@Override
public void checkExit(int status) {
StackTraceElement[] stackTrace =
Thread.currentThread().getStackTrace();
if (stackTrace != null) {
for (StackTraceElement el : stackTrace) {
String className = el.getClassName();
if (className != null
&&
className.startsWith("org.apache.maven.surefire.booter.ForkedBooter")
&& ("acknowledgedExit".equals(el.getMethodName())
|| "exit".equals(el.getMethodName()))) {
return;
}
}
}
throw new SecurityException("System.exit is disabled on unit
tests");
}
@Override
public void checkPermission(Permission perm) {
if (wrapped == null) {
return;
}
if (perm instanceof FilePermission) {
// preveniamo errori su Jenkins
return;
}
if (perm instanceof ReflectPermission) {
return;
}
wrapped.checkPermission(perm);
}
}
Il giorno ven 9 ott 2020 alle ore 09:19 Mukul Gandhi <ga...@gmail.com>
ha scritto:
> On Wed, Oct 7, 2020 at 9:09 PM Enrico Olivelli <eo...@gmail.com>
> wrote:
>
> > A good approach to workaround the presence of third party libraries that
> > call System.exit is to set a SecurityManager that prevents calls to
> > System.exit.
>
>
> I'll find it helpful, if you may share any code sample how to do this?
>
>
>
> --
> Regards,
> Mukul Gandhi
>
Re: 'mvn clean test' crashes
Posted by Mukul Gandhi <ga...@gmail.com>.
On Wed, Oct 7, 2020 at 9:09 PM Enrico Olivelli <eo...@gmail.com> wrote:
> A good approach to workaround the presence of third party libraries that
> call System.exit is to set a SecurityManager that prevents calls to
> System.exit.
I'll find it helpful, if you may share any code sample how to do this?
--
Regards,
Mukul Gandhi
Re: 'mvn clean test' crashes
Posted by Enrico Olivelli <eo...@gmail.com>.
A good approach to workaround the presence of third party libraries that
call System.exit is to set a SecurityManager that prevents calls to
System.exit. I did it a few times with good results.
You will have to allow well known libraries like Eclipse test runner or
Surefire itself
Just my 2 cents
Enrico
Il giorno mer 7 ott 2020 alle ore 09:50 Mukul Gandhi <ga...@gmail.com>
ha scritto:
> Hi Tibor,
>
> On Wed, Sep 30, 2020 at 5:03 PM Tibor Digana <ti...@apache.org>
> wrote:
>
> > Usually these errors appear in the test itself or the *libraries*.
> > As for instance, we found out that a Spring's library is implementing
> Kafka
> > stuff calling the "Runtime.getRuntime().halt( <int> )".
> > The same bad thing is to call the "System.exit(<int>)".
> > I have recognized this situation after I saw a crashed test in your logs.
> > The test is supposed to be crashed if the execution breaks abruptly
> without
> > receiving a JUnit/TestNG event about finishing the test, see this log:
> >
> > *[ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.t*
> > *est.SuspiciousActivityHelperTe**st*
> >
>
> Nowhere within my code (that's been tested by junit) and within my unit
> tests, I've used things like 'Runtime.getRuntime().halt' or 'System.exit'.
>
> The following within the logs that I've shared,
>
> (i.e *[ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.t*
> *est.SuspiciousActivityHelperTe**st*)
>
> that you've cited, doesn't indicate any of the things like use
> of 'Runtime.getRuntime().halt' or 'System.exit'. For the information, the
> name 'SuspiciousActivityHelper' is a business name within my application,
> and is not anything related to technical suspicious aspects within my
> application or test codebases.
>
> The issues that I've discussed within this thread, still causes the same
> problems to me.
>
>
>
>
> --
> Regards,
> Mukul Gandhi
>
Re: 'mvn clean test' crashes
Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Tibor,
On Wed, Sep 30, 2020 at 5:03 PM Tibor Digana <ti...@apache.org> wrote:
> Usually these errors appear in the test itself or the *libraries*.
> As for instance, we found out that a Spring's library is implementing Kafka
> stuff calling the "Runtime.getRuntime().halt( <int> )".
> The same bad thing is to call the "System.exit(<int>)".
> I have recognized this situation after I saw a crashed test in your logs.
> The test is supposed to be crashed if the execution breaks abruptly without
> receiving a JUnit/TestNG event about finishing the test, see this log:
>
> *[ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.t*
> *est.SuspiciousActivityHelperTe**st*
>
Nowhere within my code (that's been tested by junit) and within my unit
tests, I've used things like 'Runtime.getRuntime().halt' or 'System.exit'.
The following within the logs that I've shared,
(i.e *[ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.t*
*est.SuspiciousActivityHelperTe**st*)
that you've cited, doesn't indicate any of the things like use
of 'Runtime.getRuntime().halt' or 'System.exit'. For the information, the
name 'SuspiciousActivityHelper' is a business name within my application,
and is not anything related to technical suspicious aspects within my
application or test codebases.
The issues that I've discussed within this thread, still causes the same
problems to me.
--
Regards,
Mukul Gandhi