MNG-7738 don't dump raw stack traces to System.err (#1064)

This commit is contained in:
Elliotte Rusty Harold 2023-03-22 08:44:37 -04:00 committed by GitHub
parent 703f814e34
commit cadeab53f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 71 deletions

View File

@ -73,8 +73,6 @@ public boolean matches(String requirement) {
return range.getRecommendedVersion().compareTo(version) == 0;
}
} catch (InvalidVersionSpecificationException ex) {
// TODO error reporting
ex.printStackTrace();
return false;
}
}

View File

@ -1,52 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven;
import javax.inject.Inject;
import org.apache.maven.exception.ExceptionHandler;
import org.junit.jupiter.api.Test;
public class MavenTest extends AbstractCoreMavenComponentTestCase {
@Inject
private Maven maven;
@Inject
private ExceptionHandler exceptionHandler;
protected String getProjectsDirectory() {
return "src/test/projects/lifecycle-executor";
}
@Test
public void testLifecycleExecutionUsingADefaultLifecyclePhase() throws Exception {
/*
File pom = getProject( "project-with-additional-lifecycle-elements" );
MavenExecutionRequest request = createMavenExecutionRequest( pom );
MavenExecutionResult result = maven.execute( request );
if ( result.hasExceptions() )
{
ExceptionSummary es = exceptionHandler.handleException( result.getExceptions().get( 0 ) );
System.out.println( es.getMessage() );
es.getException().printStackTrace();
fail( "Maven did not execute correctly." );
}
*/
}
}

View File

@ -229,7 +229,7 @@ public ArtifactResolutionResult resolve(ArtifactResolutionRequest request) {
.map(Dependency::new)
.collect(Collectors.toList());
} catch (IOException e) {
e.printStackTrace();
// ignore
}
}

View File

@ -21,10 +21,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.apache.maven.cli.logging.impl.UnsupportedSlf4jBindingConfiguration;
import org.codehaus.plexus.util.PropertyUtils;
@ -42,8 +39,6 @@ public class Slf4jConfigurationFactory {
public static final String RESOURCE = "META-INF/maven/slf4j-configuration.properties";
public static Slf4jConfiguration getConfiguration(ILoggerFactory loggerFactory) {
Map<URL, Set<Object>> supported = new LinkedHashMap<>();
String slf4jBinding = loggerFactory.getClass().getCanonicalName();
try {
@ -52,19 +47,18 @@ public static Slf4jConfiguration getConfiguration(ILoggerFactory loggerFactory)
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
Properties conf = PropertyUtils.loadProperties(resource.openStream());
String impl = conf.getProperty(slf4jBinding);
if (impl != null) {
return (Slf4jConfiguration) Class.forName(impl).newInstance();
try {
Properties conf = PropertyUtils.loadProperties(resource.openStream());
String impl = conf.getProperty(slf4jBinding);
if (impl != null) {
return (Slf4jConfiguration) Class.forName(impl).newInstance();
}
} catch (IOException | ClassNotFoundException | IllegalAccessException | InstantiationException ex) {
// ignore and move on to the next
}
supported.put(resource, conf.keySet());
}
} catch (IOException | ClassNotFoundException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
} catch (IOException ex) {
// ignore
}
return new UnsupportedSlf4jBindingConfiguration();