Polish
This commit is contained in:
parent
127da15c3c
commit
883fd9162f
|
|
@ -239,7 +239,7 @@ public class CrshAutoConfiguration {
|
|||
try {
|
||||
token = this.authenticationManager.authenticate(token);
|
||||
}
|
||||
catch (AuthenticationException ae) {
|
||||
catch (AuthenticationException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ public class CrshAutoConfiguration {
|
|||
this.accessDecisionManager.decide(token, this,
|
||||
SecurityConfig.createList(this.roles));
|
||||
}
|
||||
catch (AccessDeniedException e) {
|
||||
catch (AccessDeniedException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -440,7 +440,7 @@ public class CrshAutoConfiguration {
|
|||
try {
|
||||
return this.resource.lastModified();
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,18 +50,18 @@ public class SimpleHealthIndicator implements HealthIndicator<Map<String, Object
|
|||
map.put("database", this.dataSource.getConnection().getMetaData()
|
||||
.getDatabaseProductName());
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch (SQLException ex) {
|
||||
map.put("status", "error");
|
||||
map.put("error", e.getClass().getName() + ": " + e.getMessage());
|
||||
map.put("error", ex.getClass().getName() + ": " + ex.getMessage());
|
||||
}
|
||||
if (StringUtils.hasText(this.query)) {
|
||||
try {
|
||||
map.put("hello",
|
||||
this.jdbcTemplate.queryForObject(this.query, String.class));
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
map.put("status", "error");
|
||||
map.put("error", e.getClass().getName() + ": " + e.getMessage());
|
||||
map.put("error", ex.getClass().getName() + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link CrshAutoConfiguration}.
|
||||
|
|
@ -235,7 +234,7 @@ public class CrshAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleAuthenticationProvider() {
|
||||
public void testSimpleAuthenticationProvider() throws Exception {
|
||||
MockEnvironment env = new MockEnvironment();
|
||||
env.setProperty("shell.auth", "simple");
|
||||
env.setProperty("shell.auth.simple.username", "user");
|
||||
|
|
@ -261,24 +260,13 @@ public class CrshAutoConfigurationTests {
|
|||
}
|
||||
}
|
||||
assertNotNull(authenticationPlugin);
|
||||
try {
|
||||
assertTrue(authenticationPlugin.authenticate("user", "password"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
|
||||
try {
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
"password"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
assertTrue(authenticationPlugin.authenticate("user", "password"));
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
"password"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpringAuthenticationProvider() {
|
||||
public void testSpringAuthenticationProvider() throws Exception {
|
||||
MockEnvironment env = new MockEnvironment();
|
||||
env.setProperty("shell.auth", "spring");
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
|
|
@ -300,22 +288,11 @@ public class CrshAutoConfigurationTests {
|
|||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(authenticationPlugin);
|
||||
try {
|
||||
assertTrue(authenticationPlugin.authenticate(SecurityConfiguration.USERNAME,
|
||||
SecurityConfiguration.PASSWORD));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
assertTrue(authenticationPlugin.authenticate(SecurityConfiguration.USERNAME,
|
||||
SecurityConfiguration.PASSWORD));
|
||||
|
||||
try {
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
SecurityConfiguration.PASSWORD));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
SecurityConfiguration.PASSWORD));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -197,7 +197,8 @@ public class WebMvcAutoConfiguration {
|
|||
logger.info("Adding welcome page: "
|
||||
+ this.resourceLoader.getResource(resource).getURL());
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
// Ignore
|
||||
}
|
||||
registry.addViewController("/").setViewName("/index.html");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -16,12 +16,15 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.amqp;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.amqp.core.AmqpAdmin;
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
@ -29,7 +32,6 @@ import org.springframework.context.annotation.Configuration;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link RabbitAutoConfiguration}.
|
||||
|
|
@ -40,6 +42,9 @@ public class RabbitAutoconfigurationTests {
|
|||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testDefaultRabbitTemplate() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
|
|
@ -123,12 +128,11 @@ public class RabbitAutoconfigurationTests {
|
|||
this.context.register(TestConfiguration.class, RabbitAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.rabbitmq.dynamic:false");
|
||||
this.context.refresh();
|
||||
try {
|
||||
this.context.getBean(AmqpAdmin.class);
|
||||
fail("There should NOT be an AmqpAdmin bean when dynamic is switch to false");
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
// There should NOT be an AmqpAdmin bean when dynamic is switch to false
|
||||
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
||||
this.thrown.expectMessage("No qualifying bean of type "
|
||||
+ "[org.springframework.amqp.core.AmqpAdmin] is defined");
|
||||
this.context.getBean(AmqpAdmin.class);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
/**
|
||||
* Integration tests for unsecured service endpoints (even with Spring Security on
|
||||
* classpath).
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class UnsecureManagementSampleActuatorApplicationTests {
|
||||
|
|
@ -87,7 +87,7 @@ public class UnsecureManagementSampleActuatorApplicationTests {
|
|||
public void testMetrics() throws Exception {
|
||||
try {
|
||||
testHomeIsSecure(); // makes sure some requests have been made
|
||||
} catch (AssertionError e) {
|
||||
} catch (AssertionError ex) {
|
||||
// ignore;
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public class SampleMongoApplicationTests {
|
|||
public void testDefaultSettings() throws Exception {
|
||||
try {
|
||||
SampleMongoApplication.main(new String[0]);
|
||||
} catch (IllegalStateException e) {
|
||||
if (serverNotRunning(e)) {
|
||||
} catch (IllegalStateException ex) {
|
||||
if (serverNotRunning(ex)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ public class SnakeTimer {
|
|||
try {
|
||||
tick();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
log.error("Caught to prevent timer from shutting down", e);
|
||||
catch (Throwable ex) {
|
||||
log.error("Caught to prevent timer from shutting down", ex);
|
||||
}
|
||||
}
|
||||
}, TICK_DELAY, TICK_DELAY);
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ public class WebApplicationInitializersConfiguration extends AbstractConfigurati
|
|||
initializer.onStartup(sce.getServletContext());
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,14 +173,16 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
|||
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, AccessController.getContext());
|
||||
}
|
||||
catch (java.security.PrivilegedActionException pae) {
|
||||
catch (java.security.PrivilegedActionException ex) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ public class PropertiesLauncher extends Launcher {
|
|||
this.logger.info("Main class from home directory manifest: " + mainClass);
|
||||
return mainClass;
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
catch (IllegalStateException ex) {
|
||||
// Otherwise try the parent archive
|
||||
String mainClass = createArchive().getMainClass();
|
||||
this.logger.info("Main class from archive manifest: " + mainClass);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public abstract class Archive {
|
|||
try {
|
||||
return getUrl().toString();
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
return "archive";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import org.springframework.boot.loader.tools.MainClassFinder;
|
|||
* @author Phillip Webb
|
||||
*/
|
||||
@Mojo(name = "run", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE, requiresDependencyResolution = ResolutionScope.TEST)
|
||||
@Execute(phase=LifecyclePhase.TEST_COMPILE)
|
||||
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
||||
public class RunMojo extends AbstractMojo {
|
||||
|
||||
/**
|
||||
|
|
@ -179,7 +179,7 @@ public class RunMojo extends AbstractMojo {
|
|||
hasNonDaemonThreads = true;
|
||||
thread.join();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
|
@ -249,8 +249,8 @@ public class RunMojo extends AbstractMojo {
|
|||
+ "main method with appropriate signature.", ex);
|
||||
thread.getThreadGroup().uncaughtException(thread, wrappedEx);
|
||||
}
|
||||
catch (Exception e) {
|
||||
thread.getThreadGroup().uncaughtException(thread, e);
|
||||
catch (Exception ex) {
|
||||
thread.getThreadGroup().uncaughtException(thread, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public abstract class AnsiOutput {
|
|||
}
|
||||
return !(OPERATING_SYSTEM_NAME.indexOf("win") >= 0);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
catch (Throwable ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
|
|||
try {
|
||||
value = resolver.getProperty(propertyName);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
catch (RuntimeException ex) {
|
||||
// Probably could not resolve placeholders, ignore it here
|
||||
}
|
||||
this.propertyValues.put(propertyName, new PropertyValue(
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
|
|||
try {
|
||||
super.refresh();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
catch (RuntimeException ex) {
|
||||
stopAndReleaseEmbeddedServletContainer();
|
||||
throw e;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -340,11 +340,11 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
|
|||
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
|
||||
throw ex;
|
||||
}
|
||||
catch (Error err) {
|
||||
logger.error("Context initialization failed", err);
|
||||
catch (Error ex) {
|
||||
logger.error("Context initialization failed", ex);
|
||||
servletContext.setAttribute(
|
||||
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
|
||||
throw err;
|
||||
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
|
|||
Connector connector = this.tomcat.getConnector();
|
||||
connector.getProtocolHandler().stop();
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("Cannot pause connector: ", e);
|
||||
catch (Exception ex) {
|
||||
this.logger.error("Cannot pause connector: ", ex);
|
||||
}
|
||||
// Unlike Jetty, all Tomcat threads are daemon threads. We create a
|
||||
// blocking non-daemon to stop immediate shutdown
|
||||
|
|
@ -105,8 +105,8 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
|
|||
try {
|
||||
connector.getProtocolHandler().start();
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("Cannot start connector: ", e);
|
||||
catch (Exception ex) {
|
||||
this.logger.error("Cannot start connector: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -454,9 +454,9 @@ public class TomcatEmbeddedServletContainerFactory extends
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
catch (ClassNotFoundException ex) {
|
||||
}
|
||||
catch (LinkageError e) {
|
||||
catch (LinkageError ex) {
|
||||
}
|
||||
return nativePage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class TomcatEmbeddedWebappClassLoader extends WebappClassLoader {
|
|||
try {
|
||||
return Class.forName(name, false, this.parent);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
catch (ClassNotFoundException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ public class TomcatEmbeddedWebappClassLoader extends WebappClassLoader {
|
|||
try {
|
||||
return findClass(name);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
catch (ClassNotFoundException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,9 +105,9 @@ public class TomcatEmbeddedWebappClassLoader extends WebappClassLoader {
|
|||
this.securityManager.checkPackageAccess(name.substring(0,
|
||||
name.lastIndexOf('.')));
|
||||
}
|
||||
catch (SecurityException se) {
|
||||
catch (SecurityException ex) {
|
||||
throw new ClassNotFoundException("Security Violation, attempt to use "
|
||||
+ "Restricted Class: " + name, se);
|
||||
+ "Restricted Class: " + name, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ public class VcapApplicationContextInitializer implements
|
|||
properties.putAll(map);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Could not parse VCAP_APPLICATION", e);
|
||||
catch (Exception ex) {
|
||||
logger.error("Could not parse VCAP_APPLICATION", ex);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
|
@ -187,8 +187,8 @@ public class VcapApplicationContextInitializer implements
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Could not parse VCAP_APPLICATION", e);
|
||||
catch (Exception ex) {
|
||||
logger.error("Could not parse VCAP_APPLICATION", ex);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class SimpleFormatter extends Formatter {
|
|||
try {
|
||||
value = System.getenv(key);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
if (value == null) {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class OutputCapture implements TestRule {
|
|||
this.captureOut.flush();
|
||||
this.captureErr.flush();
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ public class OutputCapture implements TestRule {
|
|||
Class.forName("org.springframework.boot.ansi.AnsiOutput");
|
||||
return new AnsiPresentOutputControl();
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
catch (ClassNotFoundException ex) {
|
||||
return new AnsiOutputControl();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue