Minor change to code formatting

This commit is contained in:
Phillip Webb 2013-07-06 14:21:20 -07:00
parent a6341dc0af
commit 764a0a9af8
84 changed files with 391 additions and 214 deletions

View File

@ -193,11 +193,11 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert

View File

@ -93,7 +93,8 @@ public class AuditEvent implements Serializable {
if (entry.contains("=")) { if (entry.contains("=")) {
int index = entry.indexOf("="); int index = entry.indexOf("=");
result.put(entry.substring(0, index), entry.substring(index + 1)); result.put(entry.substring(0, index), entry.substring(index + 1));
} else { }
else {
result.put(entry, null); result.put(entry, null);
} }
} }

View File

@ -140,7 +140,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
ServerProperties serverProperties; ServerProperties serverProperties;
try { try {
serverProperties = beanFactory.getBean(ServerProperties.class); serverProperties = beanFactory.getBean(ServerProperties.class);
} catch (NoSuchBeanDefinitionException ex) { }
catch (NoSuchBeanDefinitionException ex) {
serverProperties = new ServerProperties(); serverProperties = new ServerProperties();
} }
@ -148,7 +149,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
try { try {
managementServerProperties = beanFactory managementServerProperties = beanFactory
.getBean(ManagementServerProperties.class); .getBean(ManagementServerProperties.class);
} catch (NoSuchBeanDefinitionException ex) { }
catch (NoSuchBeanDefinitionException ex) {
managementServerProperties = new ManagementServerProperties(); managementServerProperties = new ManagementServerProperties();
} }

View File

@ -83,7 +83,8 @@ public class MetricFilterAutoConfiguration {
&& (response instanceof HttpServletResponse)) { && (response instanceof HttpServletResponse)) {
doFilter((HttpServletRequest) request, (HttpServletResponse) response, doFilter((HttpServletRequest) request, (HttpServletResponse) response,
chain); chain);
} else { }
else {
chain.doFilter(request, response); chain.doFilter(request, response);
} }
} }
@ -96,7 +97,8 @@ public class MetricFilterAutoConfiguration {
stopWatch.start(); stopWatch.start();
try { try {
chain.doFilter(request, response); chain.doFilter(request, response);
} finally { }
finally {
stopWatch.stop(); stopWatch.stop();
String gaugeKey = getKey("response" + suffix); String gaugeKey = getKey("response" + suffix);
MetricFilterAutoConfiguration.this.gaugeService.set(gaugeKey, MetricFilterAutoConfiguration.this.gaugeService.set(gaugeKey,
@ -109,7 +111,8 @@ public class MetricFilterAutoConfiguration {
private int getStatus(HttpServletResponse response) { private int getStatus(HttpServletResponse response) {
try { try {
return response.getStatus(); return response.getStatus();
} catch (Exception e) { }
catch (Exception e) {
return UNDEFINED_HTTP_STATUS; return UNDEFINED_HTTP_STATUS;
} }
} }

View File

@ -61,7 +61,8 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> impl
public void run() { public void run() {
try { try {
Thread.sleep(500L); Thread.sleep(500L);
} catch (InterruptedException e) { }
catch (InterruptedException e) {
} }
ShutdownEndpoint.this.context.close(); ShutdownEndpoint.this.context.close();
} }

View File

@ -112,7 +112,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
} }
} }
throw new HttpMediaTypeNotAcceptableException(this.allSupportedMediaTypes); throw new HttpMediaTypeNotAcceptableException(this.allSupportedMediaTypes);
} finally { }
finally {
outputMessage.close(); outputMessage.close();
} }
} }
@ -179,7 +180,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
if (mediaType.isConcrete()) { if (mediaType.isConcrete()) {
selectedMediaType = mediaType; selectedMediaType = mediaType;
break; break;
} else if (mediaType.equals(MediaType.ALL) }
else if (mediaType.equals(MediaType.ALL)
|| mediaType.equals(MEDIA_TYPE_APPLICATION)) { || mediaType.equals(MEDIA_TYPE_APPLICATION)) {
selectedMediaType = MediaType.APPLICATION_OCTET_STREAM; selectedMediaType = MediaType.APPLICATION_OCTET_STREAM;
break; break;

View File

@ -54,7 +54,8 @@ public class DefaultCounterService implements CounterService {
private String wrap(String metricName) { private String wrap(String metricName) {
if (metricName.startsWith("counter")) { if (metricName.startsWith("counter")) {
return metricName; return metricName;
} else { }
else {
return "counter." + metricName; return "counter." + metricName;
} }
} }

View File

@ -43,7 +43,8 @@ public class DefaultGaugeService implements GaugeService {
private String wrap(String metricName) { private String wrap(String metricName) {
if (metricName.startsWith("gauge")) { if (metricName.startsWith("gauge")) {
return metricName; return metricName;
} else { }
else {
return "gauge." + metricName; return "gauge." + metricName;
} }
} }

View File

@ -37,7 +37,8 @@ public class InMemoryMetricRepository implements MetricRepository {
Metric metric = current.getMetric(); Metric metric = current.getMetric();
this.metrics.replace(metricName, current, this.metrics.replace(metricName, current,
new Measurement(timestamp, metric.increment(amount))); new Measurement(timestamp, metric.increment(amount)));
} else { }
else {
this.metrics.putIfAbsent(metricName, new Measurement(timestamp, new Metric( this.metrics.putIfAbsent(metricName, new Measurement(timestamp, new Metric(
metricName, amount))); metricName, amount)));
} }
@ -50,7 +51,8 @@ public class InMemoryMetricRepository implements MetricRepository {
Metric metric = current.getMetric(); Metric metric = current.getMetric();
this.metrics.replace(metricName, current, this.metrics.replace(metricName, current,
new Measurement(timestamp, metric.set(value))); new Measurement(timestamp, metric.set(value)));
} else { }
else {
this.metrics.putIfAbsent(metricName, new Measurement(timestamp, new Metric( this.metrics.putIfAbsent(metricName, new Measurement(timestamp, new Metric(
metricName, value))); metricName, value)));
} }

View File

@ -48,9 +48,11 @@ public class AuthenticationAuditListener implements
public void onApplicationEvent(AbstractAuthenticationEvent event) { public void onApplicationEvent(AbstractAuthenticationEvent event) {
if (event instanceof AbstractAuthenticationFailureEvent) { if (event instanceof AbstractAuthenticationFailureEvent) {
onAuthenticationFailureEvent((AbstractAuthenticationFailureEvent) event); onAuthenticationFailureEvent((AbstractAuthenticationFailureEvent) event);
} else if (event instanceof AuthenticationSwitchUserEvent) { }
else if (event instanceof AuthenticationSwitchUserEvent) {
onAuthenticationSwitchUserEvent((AuthenticationSwitchUserEvent) event); onAuthenticationSwitchUserEvent((AuthenticationSwitchUserEvent) event);
} else { }
else {
onAuthenticationEvent(event); onAuthenticationEvent(event);
} }
} }

View File

@ -48,7 +48,8 @@ public class AuthorizationAuditListener implements
public void onApplicationEvent(AbstractAuthorizationEvent event) { public void onApplicationEvent(AbstractAuthorizationEvent event) {
if (event instanceof AuthenticationCredentialsNotFoundEvent) { if (event instanceof AuthenticationCredentialsNotFoundEvent) {
onAuthenticationCredentialsNotFoundEvent((AuthenticationCredentialsNotFoundEvent) event); onAuthenticationCredentialsNotFoundEvent((AuthenticationCredentialsNotFoundEvent) event);
} else if (event instanceof AuthorizationFailureEvent) { }
else if (event instanceof AuthorizationFailureEvent) {
onAuthorizationFailureEvent((AuthorizationFailureEvent) event); onAuthorizationFailureEvent((AuthorizationFailureEvent) event);
} }
} }

View File

@ -101,7 +101,8 @@ public class WebRequestTraceFilter implements Filter, Ordered {
.get("headers"); .get("headers");
this.logger.trace("Headers: " this.logger.trace("Headers: "
+ this.objectMapper.writeValueAsString(headers)); + this.objectMapper.writeValueAsString(headers));
} catch (JsonProcessingException e) { }
catch (JsonProcessingException e) {
throw new IllegalStateException("Cannot create JSON", e); throw new IllegalStateException("Cannot create JSON", e);
} }
} }
@ -121,7 +122,8 @@ public class WebRequestTraceFilter implements Filter, Ordered {
Object value = values; Object value = values;
if (values.size() == 1) { if (values.size() == 1) {
value = values.get(0); value = values.get(0);
} else if (values.isEmpty()) { }
else if (values.isEmpty()) {
value = ""; value = "";
} }
map.put(name, value); map.put(name, value);

View File

@ -76,7 +76,8 @@ public class BasicErrorController implements ErrorController {
if (obj != null) { if (obj != null) {
status = (Integer) obj; status = (Integer) obj;
map.put("error", HttpStatus.valueOf(status).getReasonPhrase()); map.put("error", HttpStatus.valueOf(status).getReasonPhrase());
} else { }
else {
map.put("error", "None"); map.put("error", "None");
} }
map.put("status", status); map.put("status", status);
@ -94,12 +95,14 @@ public class BasicErrorController implements ErrorController {
map.put("trace", stackTrace.toString()); map.put("trace", stackTrace.toString());
} }
this.logger.error(error); this.logger.error(error);
} else { }
else {
Object message = request.getAttribute("javax.servlet.error.message"); Object message = request.getAttribute("javax.servlet.error.message");
map.put("message", message == null ? "No message available" : message); map.put("message", message == null ? "No message available" : message);
} }
return map; return map;
} catch (Exception e) { }
catch (Exception e) {
map.put("error", e.getClass().getName()); map.put("error", e.getClass().getName());
map.put("message", e.getMessage()); map.put("message", e.getMessage());
this.logger.error(e); this.logger.error(e);

View File

@ -61,7 +61,8 @@ public class EndpointWebMvcAutoConfigurationTests {
public void close() { public void close() {
try { try {
this.applicationContext.close(); this.applicationContext.close();
} catch (Exception ex) { }
catch (Exception ex) {
} }
} }
@ -168,10 +169,12 @@ public class EndpointWebMvcAutoConfigurationTests {
String actual = StreamUtils.copyToString(response.getBody(), String actual = StreamUtils.copyToString(response.getBody(),
Charset.forName("UTF-8")); Charset.forName("UTF-8"));
assertThat(actual, equalTo(expected)); assertThat(actual, equalTo(expected));
} finally { }
finally {
response.close(); response.close();
} }
} catch (Exception ex) { }
catch (Exception ex) {
if (expected == null) { if (expected == null) {
if (SocketException.class.isInstance(ex) if (SocketException.class.isInstance(ex)
|| FileNotFoundException.class.isInstance(ex)) { || FileNotFoundException.class.isInstance(ex)) {

View File

@ -40,7 +40,8 @@ public abstract class AutoConfigurationUtils {
public static List<String> getBasePackages(BeanFactory beanFactory) { public static List<String> getBasePackages(BeanFactory beanFactory) {
try { try {
return beanFactory.getBean(BASE_PACKAGES_BEAN, List.class); return beanFactory.getBean(BASE_PACKAGES_BEAN, List.class);
} catch (NoSuchBeanDefinitionException e) { }
catch (NoSuchBeanDefinitionException e) {
return Collections.emptyList(); return Collections.emptyList();
} }
} }
@ -50,7 +51,8 @@ public abstract class AutoConfigurationUtils {
if (!beanFactory.containsBean(BASE_PACKAGES_BEAN)) { if (!beanFactory.containsBean(BASE_PACKAGES_BEAN)) {
beanFactory.registerSingleton(BASE_PACKAGES_BEAN, new ArrayList<String>( beanFactory.registerSingleton(BASE_PACKAGES_BEAN, new ArrayList<String>(
basePackages)); basePackages));
} else { }
else {
List<String> packages = getBasePackages(beanFactory); List<String> packages = getBasePackages(beanFactory);
for (String pkg : basePackages) { for (String pkg : basePackages) {
if (packages.contains(pkg)) { if (packages.contains(pkg)) {

View File

@ -58,7 +58,8 @@ public class BasicDataSourceConfiguration extends AbstractDataSourceConfiguratio
if (this.pool != null) { if (this.pool != null) {
try { try {
this.pool.close(); this.pool.close();
} catch (SQLException e) { }
catch (SQLException e) {
throw new DataAccessResourceFailureException( throw new DataAccessResourceFailureException(
"Could not close data source", e); "Could not close data source", e);
} }

View File

@ -78,7 +78,8 @@ public abstract class JpaAutoConfiguration implements BeanFactoryAware {
.getBeanDefinition("dataSource"); .getBeanDefinition("dataSource");
return EmbeddedDatabaseConfiguration.class.getName().equals( return EmbeddedDatabaseConfiguration.class.getName().equals(
beanDefinition.getFactoryBeanName()); beanDefinition.getFactoryBeanName());
} catch (NoSuchBeanDefinitionException e) { }
catch (NoSuchBeanDefinitionException e) {
return false; return false;
} }
} }
@ -89,7 +90,8 @@ public abstract class JpaAutoConfiguration implements BeanFactoryAware {
protected DataSource getDataSource() { protected DataSource getDataSource() {
try { try {
return this.beanFactory.getBean("dataSource", DataSource.class); return this.beanFactory.getBean("dataSource", DataSource.class);
} catch (RuntimeException e) { }
catch (RuntimeException e) {
return this.beanFactory.getBean(DataSource.class); return this.beanFactory.getBean(DataSource.class);
} }
} }

View File

@ -84,7 +84,8 @@ public class ThymeleafAutoConfiguration {
try { try {
return DefaultTemplateResolverConfiguration.this.resourceLoader return DefaultTemplateResolverConfiguration.this.resourceLoader
.getResource(resourceName).getInputStream(); .getResource(resourceName).getInputStream();
} catch (IOException e) { }
catch (IOException e) {
return null; return null;
} }
} }

View File

@ -143,7 +143,8 @@ class AutoConfigurationSorter {
if (this.after == null) { if (this.after == null) {
if (this.afterAnnotation == null) { if (this.afterAnnotation == null) {
this.after = Collections.emptyList(); this.after = Collections.emptyList();
} else { }
else {
this.after = new ArrayList<AutoConfigurationClass>(); this.after = new ArrayList<AutoConfigurationClass>();
for (String afterClass : (String[]) this.afterAnnotation.get("value")) { for (String afterClass : (String[]) this.afterAnnotation.get("value")) {
this.after.add(new AutoConfigurationClass(afterClass)); this.after.add(new AutoConfigurationClass(afterClass));

View File

@ -70,7 +70,8 @@ class ComponentScanDetector implements ImportBeanDefinitionRegistrar, BeanFactor
private void storeComponentScanBasePackages() { private void storeComponentScanBasePackages() {
if (this.beanFactory instanceof ConfigurableListableBeanFactory) { if (this.beanFactory instanceof ConfigurableListableBeanFactory) {
storeComponentScanBasePackages((ConfigurableListableBeanFactory) this.beanFactory); storeComponentScanBasePackages((ConfigurableListableBeanFactory) this.beanFactory);
} else { }
else {
if (this.logger.isWarnEnabled()) { if (this.logger.isWarnEnabled()) {
this.logger this.logger
.warn("Unable to read @ComponentScan annotations for auto-configure"); .warn("Unable to read @ComponentScan annotations for auto-configure");
@ -109,7 +110,8 @@ class ComponentScanDetector implements ImportBeanDefinitionRegistrar, BeanFactor
MetadataReader metadataReader = this.metadataReaderFactory MetadataReader metadataReader = this.metadataReaderFactory
.getMetadataReader(className); .getMetadataReader(className);
return metadataReader.getAnnotationMetadata(); return metadataReader.getAnnotationMetadata();
} catch (IOException ex) { }
catch (IOException ex) {
if (this.logger.isDebugEnabled()) { if (this.logger.isDebugEnabled()) {
this.logger.debug( this.logger.debug(
"Could not find class file for introspecting @ComponentScan classes: " "Could not find class file for introspecting @ComponentScan classes: "

View File

@ -69,7 +69,8 @@ class EnableAutoConfigurationImportSelector implements DeferredImportSelector,
factories.add(0, ComponentScanDetector.class.getName()); factories.add(0, ComponentScanDetector.class.getName());
return factories.toArray(new String[factories.size()]); return factories.toArray(new String[factories.size()]);
} catch (IOException ex) { }
catch (IOException ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
} }

View File

@ -70,11 +70,14 @@ public class Spring {
for (String arg : args) { for (String arg : args) {
if (ClassUtils.isPresent(arg, null)) { if (ClassUtils.isPresent(arg, null)) {
sources.add(ClassUtils.forName(arg, null)); sources.add(ClassUtils.forName(arg, null));
} else if (arg.endsWith(".xml")) { }
else if (arg.endsWith(".xml")) {
sources.add(arg); sources.add(arg);
} else if (!scanner.findCandidateComponents(arg).isEmpty()) { }
else if (!scanner.findCandidateComponents(arg).isEmpty()) {
sources.add(arg); sources.add(arg);
} else { }
else {
strings.add(arg); strings.add(arg);
} }
} }

View File

@ -56,8 +56,8 @@ public class ServerPropertiesAutoConfigurationTests {
@Before @Before
public void init() { public void init() {
containerFactory = containerFactory = Mockito
Mockito.mock(ConfigurableEmbeddedServletContainerFactory.class); .mock(ConfigurableEmbeddedServletContainerFactory.class);
} }
@After @After
@ -70,8 +70,8 @@ public class ServerPropertiesAutoConfigurationTests {
@Test @Test
public void createFromConfigClass() throws Exception { public void createFromConfigClass() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(); this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
.register(Config.class, ServerPropertiesAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
TestUtils.addEnviroment(this.context, "server.port:9000"); TestUtils.addEnviroment(this.context, "server.port:9000");
this.context.refresh(); this.context.refresh();
ServerProperties server = this.context.getBean(ServerProperties.class); ServerProperties server = this.context.getBean(ServerProperties.class);
@ -84,8 +84,8 @@ public class ServerPropertiesAutoConfigurationTests {
public void tomcatProperties() throws Exception { public void tomcatProperties() throws Exception {
containerFactory = Mockito.mock(TomcatEmbeddedServletContainerFactory.class); containerFactory = Mockito.mock(TomcatEmbeddedServletContainerFactory.class);
this.context = new AnnotationConfigEmbeddedWebApplicationContext(); this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
.register(Config.class, ServerPropertiesAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
TestUtils.addEnviroment(this.context, "server.tomcat.basedir:target/foo"); TestUtils.addEnviroment(this.context, "server.tomcat.basedir:target/foo");
this.context.refresh(); this.context.refresh();
ServerProperties server = this.context.getBean(ServerProperties.class); ServerProperties server = this.context.getBean(ServerProperties.class);
@ -97,8 +97,9 @@ public class ServerPropertiesAutoConfigurationTests {
@Test @Test
public void testAccidentalMultipleServerPropertiesBeans() throws Exception { public void testAccidentalMultipleServerPropertiesBeans() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(); this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context this.context.register(Config.class, MutiServerPropertiesBeanConfig.class,
.register(Config.class, MutiServerPropertiesBeanConfig.class, ServerPropertiesAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.thrown.expectCause(Matchers this.thrown.expectCause(Matchers
.<Throwable> instanceOf(NoUniqueBeanDefinitionException.class)); .<Throwable> instanceOf(NoUniqueBeanDefinitionException.class));
this.context.refresh(); this.context.refresh();
@ -113,8 +114,7 @@ public class ServerPropertiesAutoConfigurationTests {
} }
@Bean @Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor(); return new EmbeddedServletContainerCustomizerBeanPostProcessor();
} }

View File

@ -24,9 +24,9 @@ import java.util.ServiceLoader;
import java.util.Set; import java.util.Set;
/** /**
* Spring Zero Command Line Interface. This is the main entry-point for the Spring * Spring Zero Command Line Interface. This is the main entry-point for the Spring Zero
* Zero command line application. This class will parse input arguments and delegate * command line application. This class will parse input arguments and delegate to a
* to a suitable {@link Command} implementation based on the first argument. * suitable {@link Command} implementation based on the first argument.
* *
* <p> * <p>
* The '-d' and '--debug' switches are handled by this class, however, most argument * The '-d' and '--debug' switches are handled by this class, however, most argument
@ -47,8 +47,7 @@ public class SpringZeroCli {
private List<Command> commands; private List<Command> commands;
/** /**
* Create a new {@link SpringZeroCli} implementation with the default set of * Create a new {@link SpringZeroCli} implementation with the default set of commands.
* commands.
*/ */
public SpringZeroCli() { public SpringZeroCli() {
setCommands(ServiceLoader.load(CommandFactory.class, getClass().getClassLoader())); setCommands(ServiceLoader.load(CommandFactory.class, getClass().getClassLoader()));
@ -87,10 +86,12 @@ public class SpringZeroCli {
try { try {
run(argsWithoutDebugFlags); run(argsWithoutDebugFlags);
return 0; return 0;
} catch (NoArgumentsException ex) { }
catch (NoArgumentsException ex) {
showUsage(); showUsage();
return 1; return 1;
} catch (Exception ex) { }
catch (Exception ex) {
Set<SpringZeroCliException.Option> options = NO_EXCEPTION_OPTIONS; Set<SpringZeroCliException.Option> options = NO_EXCEPTION_OPTIONS;
if (ex instanceof SpringZeroCliException) { if (ex instanceof SpringZeroCliException) {
options = ((SpringZeroCliException) ex).getOptions(); options = ((SpringZeroCliException) ex).getOptions();

View File

@ -70,8 +70,7 @@ public class SpringZeroCliException extends RuntimeException {
} }
/** /**
* Returns options a set of options that are understood by the * Returns options a set of options that are understood by the {@link SpringZeroCli}.
* {@link SpringZeroCli}.
*/ */
public Set<Option> getOptions() { public Set<Option> getOptions() {
return Collections.unmodifiableSet(this.options); return Collections.unmodifiableSet(this.options);

View File

@ -102,7 +102,8 @@ public class CleanCommand extends OptionParsingCommand {
|| group.equals("org.springframework.zero")) { || group.equals("org.springframework.zero")) {
System.out.println("Deleting: " + file); System.out.println("Deleting: " + file);
FileUtil.forceDelete(file); FileUtil.forceDelete(file);
} else { }
else {
for (Object obj : FileUtil.listAll(file, Collections.emptyList())) { for (Object obj : FileUtil.listAll(file, Collections.emptyList())) {
File candidate = (File) obj; File candidate = (File) obj;
if (candidate.getName().contains("SNAPSHOT")) { if (candidate.getName().contains("SNAPSHOT")) {
@ -119,7 +120,8 @@ public class CleanCommand extends OptionParsingCommand {
File parent = root; File parent = root;
if (layout == Layout.IVY) { if (layout == Layout.IVY) {
parent = new File(parent, group); parent = new File(parent, group);
} else { }
else {
for (String path : group.split("\\.")) { for (String path : group.split("\\.")) {
parent = new File(parent, path); parent = new File(parent, path);
} }
@ -140,7 +142,8 @@ public class CleanCommand extends OptionParsingCommand {
if (dir == null || !new File(dir).exists()) { if (dir == null || !new File(dir).exists()) {
dir = userdir; dir = userdir;
home = new File(dir, ".groovy"); home = new File(dir, ".groovy");
} else { }
else {
home = new File(dir); home = new File(dir);
} }
if (dir == null || !new File(dir).exists()) { if (dir == null || !new File(dir).exists()) {

View File

@ -77,7 +77,8 @@ public class OptionHandler {
OutputStream out = new ByteArrayOutputStream(); OutputStream out = new ByteArrayOutputStream();
try { try {
getParser().printHelpOn(out); getParser().printHelpOn(out);
} catch (IOException e) { }
catch (IOException e) {
return "Help not available"; return "Help not available";
} }
return out.toString(); return out.toString();

View File

@ -91,13 +91,17 @@ public class ScriptCommand implements Command {
private void run(Object main, String[] args) throws Exception { private void run(Object main, String[] args) throws Exception {
if (main instanceof Command) { if (main instanceof Command) {
((Command) main).run(args); ((Command) main).run(args);
} else if (main instanceof OptionHandler) { }
else if (main instanceof OptionHandler) {
((OptionHandler) getMain()).run(args); ((OptionHandler) getMain()).run(args);
} else if (main instanceof Closure) { }
else if (main instanceof Closure) {
((Closure<?>) main).call((Object[]) args); ((Closure<?>) main).call((Object[]) args);
} else if (main instanceof Runnable) { }
else if (main instanceof Runnable) {
((Runnable) main).run(); ((Runnable) main).run();
} else if (main instanceof Script) { }
else if (main instanceof Script) {
Script script = (Script) this.main; Script script = (Script) this.main;
script.setProperty("args", args); script.setProperty("args", args);
if (this.main instanceof GroovyObjectSupport) { if (this.main instanceof GroovyObjectSupport) {
@ -135,13 +139,15 @@ public class ScriptCommand implements Command {
if (this.main == null) { if (this.main == null) {
try { try {
this.main = getMainClass().newInstance(); this.main = getMainClass().newInstance();
} catch (Exception e) { }
catch (Exception e) {
throw new IllegalStateException("Cannot create main class: " + this.name, throw new IllegalStateException("Cannot create main class: " + this.name,
e); e);
} }
if (this.main instanceof OptionHandler) { if (this.main instanceof OptionHandler) {
((OptionHandler) this.main).options(); ((OptionHandler) this.main).options();
} else if (this.main instanceof GroovyObjectSupport) { }
else if (this.main instanceof GroovyObjectSupport) {
GroovyObjectSupport object = (GroovyObjectSupport) this.main; GroovyObjectSupport object = (GroovyObjectSupport) this.main;
MetaClass metaClass = object.getMetaClass(); MetaClass metaClass = object.getMetaClass();
MetaMethod options = metaClass.getMetaMethod("options", null); MetaMethod options = metaClass.getMetaMethod("options", null);
@ -160,9 +166,11 @@ public class ScriptCommand implements Command {
Class<?>[] classes; Class<?>[] classes;
try { try {
classes = compiler.compile(source); classes = compiler.compile(source);
} catch (CompilationFailedException e) { }
catch (CompilationFailedException e) {
throw new IllegalStateException("Could not compile script", e); throw new IllegalStateException("Could not compile script", e);
} catch (IOException e) { }
catch (IOException e) {
throw new IllegalStateException("Could not compile script", e); throw new IllegalStateException("Could not compile script", e);
} }
this.mainClass = classes[0]; this.mainClass = classes[0];
@ -185,18 +193,21 @@ public class ScriptCommand implements Command {
if (url != null) { if (url != null) {
if (url.toString().startsWith("file:")) { if (url.toString().startsWith("file:")) {
file = new File(url.toString().substring("file:".length())); file = new File(url.toString().substring("file:".length()));
} else { }
else {
// probably in JAR file // probably in JAR file
try { try {
file = File.createTempFile(name, ".groovy"); file = File.createTempFile(name, ".groovy");
file.deleteOnExit(); file.deleteOnExit();
FileUtil.copy(url, file, null); FileUtil.copy(url, file, null);
} catch (IOException e) { }
catch (IOException e) {
throw new IllegalStateException( throw new IllegalStateException(
"Could not create temp file for source: " + name); "Could not create temp file for source: " + name);
} }
} }
} else { }
else {
String home = System.getProperty("SPRING_HOME", System.getenv("SPRING_HOME")); String home = System.getProperty("SPRING_HOME", System.getenv("SPRING_HOME"));
if (home == null) { if (home == null) {
home = "."; home = ".";

View File

@ -72,7 +72,8 @@ public class DependencyCustomizer {
for (String classname : classNames) { for (String classname : classNames) {
try { try {
DependencyCustomizer.this.loader.loadClass(classname); DependencyCustomizer.this.loader.loadClass(classname);
} catch (Exception e) { }
catch (Exception e) {
return true; return true;
} }
} }
@ -95,7 +96,8 @@ public class DependencyCustomizer {
try { try {
DependencyCustomizer.this.loader.loadClass(classname); DependencyCustomizer.this.loader.loadClass(classname);
return false; return false;
} catch (Exception e) { }
catch (Exception e) {
} }
} }
return DependencyCustomizer.this.canAdd(); return DependencyCustomizer.this.canAdd();
@ -119,7 +121,8 @@ public class DependencyCustomizer {
return false; return false;
} }
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
} }
} }
return DependencyCustomizer.this.canAdd(); return DependencyCustomizer.this.canAdd();
@ -143,7 +146,8 @@ public class DependencyCustomizer {
return true; return true;
} }
return false; return false;
} catch (Exception e) { }
catch (Exception e) {
} }
} }
return DependencyCustomizer.this.canAdd(); return DependencyCustomizer.this.canAdd();

View File

@ -88,7 +88,8 @@ public class GroovyCompiler {
for (File file : files) { for (File file : files) {
if (file.getName().endsWith(".groovy") || file.getName().endsWith(".java")) { if (file.getName().endsWith(".groovy") || file.getName().endsWith(".java")) {
compilables.add(file); compilables.add(file);
} else { }
else {
others.add(file); others.add(file);
} }
} }

View File

@ -58,8 +58,8 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
imports.addStarImports("org.springframework.web.bind.annotation", imports.addStarImports("org.springframework.web.bind.annotation",
"org.springframework.web.servlet.config.annotation", "org.springframework.web.servlet.config.annotation",
"org.springframework.http"); "org.springframework.http");
imports.addStaticImport( imports.addStaticImport("org.springframework.zero.cli.template.GroovyTemplate",
"org.springframework.zero.cli.template.GroovyTemplate", "template"); "template");
} }
} }

View File

@ -100,7 +100,8 @@ public class SpringZeroCompilerAutoConfiguration extends CompilerAutoConfigurati
AnnotationNode annotationNode = new AnnotationNode(new ClassNode( AnnotationNode annotationNode = new AnnotationNode(new ClassNode(
annotationClass)); annotationClass));
classNode.addAnnotation(annotationNode); classNode.addAnnotation(annotationNode);
} catch (ClassNotFoundException e) { }
catch (ClassNotFoundException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }

View File

@ -92,10 +92,12 @@ public class SpringZeroRunner {
this.fileWatchThread.start(); this.fileWatchThread.start();
} }
} catch (Exception ex) { }
catch (Exception ex) {
if (this.fileWatchThread == null) { if (this.fileWatchThread == null) {
throw ex; throw ex;
} else { }
else {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@ -132,7 +134,8 @@ public class SpringZeroRunner {
String[].class); String[].class);
this.applicationContext = method.invoke(null, this.sources, this.applicationContext = method.invoke(null, this.sources,
SpringZeroRunner.this.args); SpringZeroRunner.this.args);
} catch (Exception ex) { }
catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@ -145,11 +148,14 @@ public class SpringZeroRunner {
try { try {
Method method = this.applicationContext.getClass().getMethod("close"); Method method = this.applicationContext.getClass().getMethod("close");
method.invoke(this.applicationContext); method.invoke(this.applicationContext);
} catch (NoSuchMethodException ex) { }
catch (NoSuchMethodException ex) {
// Not an application context that we can close // Not an application context that we can close
} catch (Exception ex) { }
catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally { }
finally {
this.applicationContext = null; this.applicationContext = null;
} }
} }
@ -186,9 +192,11 @@ public class SpringZeroRunner {
compileAndRun(); compileAndRun();
} }
} }
} catch (InterruptedException ex) { }
catch (InterruptedException ex) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch (Exception ex) { }
catch (Exception ex) {
// Swallow, will be reported by compileAndRun // Swallow, will be reported by compileAndRun
} }
} }

View File

@ -48,10 +48,12 @@ public class GroovyTemplate {
Template template; Template template;
if (file.exists()) { if (file.exists()) {
template = engine.createTemplate(file); template = engine.createTemplate(file);
} else { }
else {
if (resource != null) { if (resource != null) {
template = engine.createTemplate(resource); template = engine.createTemplate(resource);
} else { }
else {
template = engine.createTemplate(name); template = engine.createTemplate(name);
} }
} }

View File

@ -138,7 +138,8 @@ class BeanDefinitionLoader {
if (source instanceof CharSequence) { if (source instanceof CharSequence) {
try { try {
return load(Class.forName(source.toString())); return load(Class.forName(source.toString()));
} catch (ClassNotFoundException e) { }
catch (ClassNotFoundException e) {
} }
Resource loadedResource = (this.resourceLoader != null ? this.resourceLoader Resource loadedResource = (this.resourceLoader != null ? this.resourceLoader

View File

@ -270,7 +270,8 @@ public class SpringApplication {
contextClass = Class contextClass = Class
.forName(this.webEnvironment ? DEFAULT_WEB_CONTEXT_CLASS .forName(this.webEnvironment ? DEFAULT_WEB_CONTEXT_CLASS
: DEFAULT_CONTEXT_CLASS); : DEFAULT_CONTEXT_CLASS);
} catch (ClassNotFoundException ex) { }
catch (ClassNotFoundException ex) {
throw new IllegalStateException( throw new IllegalStateException(
"Unable create a default ApplicationContext, " "Unable create a default ApplicationContext, "
+ "please specify an ApplicationContextClass", ex); + "please specify an ApplicationContextClass", ex);
@ -344,14 +345,16 @@ public class SpringApplication {
for (String arg : defaults) { for (String arg : defaults) {
if (isOptionArg(arg)) { if (isOptionArg(arg)) {
addOptionArg(options, arg); addOptionArg(options, arg);
} else { }
else {
nonopts.add(arg); nonopts.add(arg);
} }
} }
for (String arg : args) { for (String arg : args) {
if (isOptionArg(arg)) { if (isOptionArg(arg)) {
addOptionArg(options, arg); addOptionArg(options, arg);
} else if (!nonopts.contains(arg)) { }
else if (!nonopts.contains(arg)) {
nonopts.add(arg); nonopts.add(arg);
} }
} }
@ -376,7 +379,8 @@ public class SpringApplication {
optionName = optionText.substring(0, optionText.indexOf("=")); optionName = optionText.substring(0, optionText.indexOf("="));
optionValue = optionText.substring(optionText.indexOf("=") + 1, optionValue = optionText.substring(optionText.indexOf("=") + 1,
optionText.length()); optionText.length());
} else { }
else {
optionName = optionText; optionName = optionText;
} }
if (optionName.isEmpty()) { if (optionName.isEmpty()) {
@ -434,7 +438,8 @@ public class SpringApplication {
for (CommandLineRunner runner : runners) { for (CommandLineRunner runner : runners) {
try { try {
runner.run(args); runner.run(args);
} catch (Exception e) { }
catch (Exception e) {
throw new IllegalStateException("Failed to execute CommandLineRunner", e); throw new IllegalStateException("Failed to execute CommandLineRunner", e);
} }
} }
@ -606,11 +611,13 @@ public class SpringApplication {
generators.addAll(context.getBeansOfType(ExitCodeGenerator.class) generators.addAll(context.getBeansOfType(ExitCodeGenerator.class)
.values()); .values());
exitCode = getExitCode(generators); exitCode = getExitCode(generators);
} finally { }
finally {
close(context); close(context);
} }
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
exitCode = (exitCode == 0 ? 1 : exitCode); exitCode = (exitCode == 0 ? 1 : exitCode);
} }
@ -625,7 +632,8 @@ public class SpringApplication {
if (value > 0 && value > exitCode || value < 0 && value < exitCode) { if (value > 0 && value > exitCode || value < 0 && value < exitCode) {
exitCode = value; exitCode = value;
} }
} catch (Exception e) { }
catch (Exception e) {
exitCode = (exitCode == 0 ? 1 : exitCode); exitCode = (exitCode == 0 ? 1 : exitCode);
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -74,7 +74,8 @@ public class CustomPropertyConstructor extends Constructor {
try { try {
typeMap.put(alias, this.propertyUtils.getProperty(type, name)); typeMap.put(alias, this.propertyUtils.getProperty(type, name));
} catch (IntrospectionException e) { }
catch (IntrospectionException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@ -37,7 +37,8 @@ public class InetAddressEditor extends PropertyEditorSupport implements Property
public void setAsText(String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
try { try {
setValue(InetAddress.getByName(text)); setValue(InetAddress.getByName(text));
} catch (UnknownHostException e) { }
catch (UnknownHostException e) {
throw new IllegalArgumentException("Cannot locate host", e); throw new IllegalArgumentException("Cannot locate host", e);
} }
} }

View File

@ -172,7 +172,8 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>,
try { try {
if (this.properties != null) { if (this.properties != null) {
logger.trace("Properties:\n" + this.properties); logger.trace("Properties:\n" + this.properties);
} else { }
else {
logger.trace("Property Sources: " + this.propertySources); logger.trace("Property Sources: " + this.propertySources);
} }
this.initialized = true; this.initialized = true;
@ -180,7 +181,8 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>,
RelaxedDataBinder dataBinder; RelaxedDataBinder dataBinder;
if (this.targetName != null) { if (this.targetName != null) {
dataBinder = new RelaxedDataBinder(this.configuration, this.targetName); dataBinder = new RelaxedDataBinder(this.configuration, this.targetName);
} else { }
else {
dataBinder = new RelaxedDataBinder(this.configuration); dataBinder = new RelaxedDataBinder(this.configuration);
} }
if (this.validator != null) { if (this.validator != null) {
@ -195,7 +197,8 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>,
PropertyValues pvs; PropertyValues pvs;
if (this.properties != null) { if (this.properties != null) {
pvs = new MutablePropertyValues(this.properties); pvs = new MutablePropertyValues(this.properties);
} else { }
else {
pvs = new PropertySourcesPropertyValues(this.propertySources); pvs = new PropertySourcesPropertyValues(this.propertySources);
} }
dataBinder.bind(pvs); dataBinder.bind(pvs);
@ -219,7 +222,8 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>,
} }
} }
} }
} catch (BindException e) { }
catch (BindException e) {
if (this.exceptionIfInvalid) { if (this.exceptionIfInvalid) {
throw e; throw e;
} }

View File

@ -98,7 +98,8 @@ public class PropertySourcesPropertyValues implements PropertyValues {
PropertyValue pvOld = old.getPropertyValue(newPv.getName()); PropertyValue pvOld = old.getPropertyValue(newPv.getName());
if (pvOld == null) { if (pvOld == null) {
changes.addPropertyValue(newPv); changes.addPropertyValue(newPv);
} else if (!pvOld.equals(newPv)) { }
else if (!pvOld.equals(newPv)) {
// it's changed // it's changed
changes.addPropertyValue(newPv); changes.addPropertyValue(newPv);
} }

View File

@ -157,7 +157,8 @@ public class RelaxedDataBinder extends DataBinder {
Map<String, Object> existing = (Map<String, Object>) target Map<String, Object> existing = (Map<String, Object>) target
.getPropertyValue(base); .getPropertyValue(base);
nested = existing; nested = existing;
} else { }
else {
target.setPropertyValue(base, nested); target.setPropertyValue(base, nested);
} }
modifyPopertiesForMap(nested, propertyValues, index, base); modifyPopertiesForMap(nested, propertyValues, index, base);
@ -196,7 +197,8 @@ public class RelaxedDataBinder extends DataBinder {
if (target.getPropertyType(prefix + candidate) != null) { if (target.getPropertyType(prefix + candidate) != null) {
return candidate; return candidate;
} }
} catch (InvalidPropertyException ex) { }
catch (InvalidPropertyException ex) {
} }
} }
} }

View File

@ -158,7 +158,8 @@ public class YamlConfigurationFactory<T> implements FactoryBean<T>, MessageSourc
} }
} }
} }
} catch (YAMLException e) { }
catch (YAMLException e) {
if (this.exceptionIfInvalid) { if (this.exceptionIfInvalid) {
throw e; throw e;
} }

View File

@ -34,7 +34,8 @@ public class JacksonJsonParser implements JsonParser {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> map = new ObjectMapper().readValue(json, Map.class); Map<String, Object> map = new ObjectMapper().readValue(json, Map.class);
return map; return map;
} catch (Exception e) { }
catch (Exception e) {
throw new IllegalArgumentException("Cannot parse JSON", e); throw new IllegalArgumentException("Cannot parse JSON", e);
} }
} }
@ -45,7 +46,8 @@ public class JacksonJsonParser implements JsonParser {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Object> list = new ObjectMapper().readValue(json, List.class); List<Object> list = new ObjectMapper().readValue(json, List.class);
return list; return list;
} catch (Exception e) { }
catch (Exception e) {
throw new IllegalArgumentException("Cannot parse JSON", e); throw new IllegalArgumentException("Cannot parse JSON", e);
} }
} }

View File

@ -39,7 +39,8 @@ public class SimpleJsonParser implements JsonParser {
public Map<String, Object> parseMap(String json) { public Map<String, Object> parseMap(String json) {
if (json.startsWith("{")) { if (json.startsWith("{")) {
return parseMapInternal(json); return parseMapInternal(json);
} else if (json.trim().equals("")) { }
else if (json.trim().equals("")) {
return new HashMap<String, Object>(); return new HashMap<String, Object>();
} }
return null; return null;
@ -49,7 +50,8 @@ public class SimpleJsonParser implements JsonParser {
public List<Object> parseList(String json) { public List<Object> parseList(String json) {
if (json.startsWith("[")) { if (json.startsWith("[")) {
return parseListInternal(json); return parseListInternal(json);
} else if (json.trim().equals("")) { }
else if (json.trim().equals("")) {
return new ArrayList<Object>(); return new ArrayList<Object>();
} }
return null; return null;
@ -104,7 +106,8 @@ public class SimpleJsonParser implements JsonParser {
trimTrailingCharacter(values[1], '"'), '"'); trimTrailingCharacter(values[1], '"'), '"');
if (string.startsWith("{") && string.endsWith("}")) { if (string.startsWith("{") && string.endsWith("}")) {
value = parseInternal(string); value = parseInternal(string);
} else { }
else {
value = string; value = string;
} }
} }
@ -129,7 +132,8 @@ public class SimpleJsonParser implements JsonParser {
if (current == ',' && inObject == 0) { if (current == ',' && inObject == 0) {
list.add(build.toString()); list.add(build.toString());
build.setLength(0); build.setLength(0);
} else { }
else {
build.append(current); build.append(current);
} }
index++; index++;

View File

@ -99,7 +99,8 @@ public class YamlMapFactoryBean extends YamlProcessor implements
(Map) existing); (Map) existing);
merge(result, (Map) value); merge(result, (Map) value);
output.put(key, result); output.put(key, result);
} else { }
else {
output.put(key, value); output.put(key, value);
} }
} }

View File

@ -179,14 +179,16 @@ public class YamlProcessor {
// No need to load any more resources // No need to load any more resources
break; break;
} }
} catch (IOException e) { }
catch (IOException e) {
if (this.resolutionMethod == ResolutionMethod.FIRST_FOUND if (this.resolutionMethod == ResolutionMethod.FIRST_FOUND
|| this.resolutionMethod == ResolutionMethod.OVERRIDE_AND_IGNORE) { || this.resolutionMethod == ResolutionMethod.OVERRIDE_AND_IGNORE) {
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn("Could not load map from " + resource + ": " logger.warn("Could not load map from " + resource + ": "
+ e.getMessage()); + e.getMessage());
} }
} else { }
else {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }
@ -199,7 +201,8 @@ public class YamlProcessor {
if (this.documentMatchers.isEmpty()) { if (this.documentMatchers.isEmpty()) {
logger.debug("Merging document (no matchers set)" + map); logger.debug("Merging document (no matchers set)" + map);
callback.process(properties, map); callback.process(properties, map);
} else { }
else {
boolean valueFound = false; boolean valueFound = false;
MatchStatus result = MatchStatus.ABSTAIN; MatchStatus result = MatchStatus.ABSTAIN;
for (DocumentMatcher matcher : this.documentMatchers) { for (DocumentMatcher matcher : this.documentMatchers) {
@ -216,7 +219,8 @@ public class YamlProcessor {
if (result == MatchStatus.ABSTAIN && this.matchDefault) { if (result == MatchStatus.ABSTAIN && this.matchDefault) {
logger.debug("Matched document with default matcher: " + map); logger.debug("Matched document with default matcher: " + map);
callback.process(properties, map); callback.process(properties, map);
} else if (!valueFound) { }
else if (!valueFound) {
logger.debug("Unmatched document"); logger.debug("Unmatched document");
return false; return false;
} }
@ -231,19 +235,22 @@ public class YamlProcessor {
if (StringUtils.hasText(path)) { if (StringUtils.hasText(path)) {
if (key.startsWith("[")) { if (key.startsWith("[")) {
key = path + key; key = path + key;
} else { }
else {
key = path + "." + key; key = path + "." + key;
} }
} }
Object value = entry.getValue(); Object value = entry.getValue();
if (value instanceof String) { if (value instanceof String) {
properties.put(key, value); properties.put(key, value);
} else if (value instanceof Map) { }
else if (value instanceof Map) {
// Need a compound key // Need a compound key
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) value; Map<String, Object> map = (Map<String, Object>) value;
assignProperties(properties, map, key); assignProperties(properties, map, key);
} else if (value instanceof Collection) { }
else if (value instanceof Collection) {
// Need a compound key // Need a compound key
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<Object> collection = (Collection<Object>) value; Collection<Object> collection = (Collection<Object>) value;
@ -254,7 +261,8 @@ public class YamlProcessor {
assignProperties(properties, assignProperties(properties,
Collections.singletonMap("[" + (count++) + "]", object), key); Collections.singletonMap("[" + (count++) + "]", object), key);
} }
} else { }
else {
properties.put(key, value == null ? "" : value); properties.put(key, value == null ? "" : value);
} }
} }

View File

@ -78,7 +78,8 @@ abstract class AbstractOnBeanCondition implements ConfigurationCondition {
} }
} }
}); });
} catch (Exception e) { }
catch (Exception e) {
} }
} }
} }
@ -116,7 +117,8 @@ abstract class AbstractOnBeanCondition implements ConfigurationCondition {
if (beans.length != 0) { if (beans.length != 0) {
beanClassesFound.add(beanClass); beanClassesFound.add(beanClass);
} }
} catch (ClassNotFoundException ex) { }
catch (ClassNotFoundException ex) {
} }
} }
for (String beanName : beanNames) { for (String beanName : beanNames) {
@ -142,7 +144,8 @@ abstract class AbstractOnBeanCondition implements ConfigurationCondition {
+ candidates); + candidates);
if (found.isEmpty()) { if (found.isEmpty()) {
this.logger.debug(prefix + "Found no beans"); this.logger.debug(prefix + "Found no beans");
} else { }
else {
this.logger.debug(prefix + "Found beans with " + type + ": " + found); this.logger.debug(prefix + "Found beans with " + type + ": " + found);
} }
} }

View File

@ -77,10 +77,12 @@ public class ConfigurationPropertiesBindingConfiguration {
if (this.configurer != null) { if (this.configurer != null) {
propertySources = extractPropertySources(this.configurer); propertySources = extractPropertySources(this.configurer);
} else if (this.environment instanceof ConfigurableEnvironment) { }
else if (this.environment instanceof ConfigurableEnvironment) {
propertySources = flattenPropertySources(((ConfigurableEnvironment) this.environment) propertySources = flattenPropertySources(((ConfigurableEnvironment) this.environment)
.getPropertySources()); .getPropertySources());
} else { }
else {
// empty, so not very useful, but fulfils the contract // empty, so not very useful, but fulfils the contract
propertySources = new MutablePropertySources(); propertySources = new MutablePropertySources();
} }
@ -121,7 +123,8 @@ public class ConfigurationPropertiesBindingConfiguration {
for (PropertySource<?> childSource : environment.getPropertySources()) { for (PropertySource<?> childSource : environment.getPropertySources()) {
flattenPropertySources(childSource, result); flattenPropertySources(childSource, result);
} }
} else { }
else {
result.addLast(propertySource); result.addLast(propertySource);
} }
} }

View File

@ -113,9 +113,11 @@ public class PropertySourcesBindingPostProcessor implements BeanPostProcessor,
factory.setTargetName(targetName); factory.setTargetName(targetName);
try { try {
target = factory.getObject(); // throwaway target = factory.getObject(); // throwaway
} catch (BeansException e) { }
catch (BeansException e) {
throw e; throw e;
} catch (Exception e) { }
catch (Exception e) {
throw new BeanCreationException(beanName, "Could not bind", e); throw new BeanCreationException(beanName, "Could not bind", e);
} }
} }

View File

@ -378,7 +378,8 @@ public abstract class AbstractEmbeddedServletContainerFactory implements
path = path.substring(0, path.indexOf("!/")); path = path.substring(0, path.indexOf("!/"));
} }
return new File(path); return new File(path);
} catch (IOException e) { }
catch (IOException e) {
return null; return null;
} }
} }

View File

@ -131,10 +131,12 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
EmbeddedServletContainerFactory containerFactory = getEmbeddedServletContainerFactory(); EmbeddedServletContainerFactory containerFactory = getEmbeddedServletContainerFactory();
this.embeddedServletContainer = containerFactory this.embeddedServletContainer = containerFactory
.getEmbeddedServletContainer(getSelfInitializer()); .getEmbeddedServletContainer(getSelfInitializer());
} else if (getServletContext() != null) { }
else if (getServletContext() != null) {
try { try {
getSelfInitializer().onStartup(getServletContext()); getSelfInitializer().onStartup(getServletContext());
} catch (ServletException e) { }
catch (ServletException e) {
throw new ApplicationContextException( throw new ApplicationContextException(
"Cannot initialize servlet context", e); "Cannot initialize servlet context", e);
} }
@ -280,12 +282,14 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
logger.info("Root WebApplicationContext: initialization completed in " logger.info("Root WebApplicationContext: initialization completed in "
+ elapsedTime + " ms"); + elapsedTime + " ms");
} }
} catch (RuntimeException ex) { }
catch (RuntimeException ex) {
logger.error("Context initialization failed", ex); logger.error("Context initialization failed", ex);
servletContext.setAttribute( servletContext.setAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
throw ex; throw ex;
} catch (Error err) { }
catch (Error err) {
logger.error("Context initialization failed", err); logger.error("Context initialization failed", err);
servletContext.setAttribute( servletContext.setAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err); WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
@ -312,7 +316,8 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
try { try {
this.embeddedServletContainer.stop(); this.embeddedServletContainer.stop();
this.embeddedServletContainer = null; this.embeddedServletContainer = null;
} catch (Exception ex) { }
catch (Exception ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
} }

View File

@ -244,7 +244,8 @@ public class FilterRegistrationBean extends RegistrationBean {
if (servletNames.isEmpty() && this.urlPatterns.isEmpty()) { if (servletNames.isEmpty() && this.urlPatterns.isEmpty()) {
registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter, registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter,
DEFAULT_URL_MAPPINGS); DEFAULT_URL_MAPPINGS);
} else { }
else {
if (servletNames.size() > 0) { if (servletNames.size() > 0) {
registration.addMappingForServletNames(dispatcherTypes, this.matchAfter, registration.addMappingForServletNames(dispatcherTypes, this.matchAfter,
servletNames.toArray(new String[servletNames.size()])); servletNames.toArray(new String[servletNames.size()]));

View File

@ -46,7 +46,8 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
private synchronized void start() { private synchronized void start() {
try { try {
this.server.start(); this.server.start();
} catch (Exception ex) { }
catch (Exception ex) {
throw new EmbeddedServletContainerException( throw new EmbeddedServletContainerException(
"Unable to start embedded Jetty servlet container", ex); "Unable to start embedded Jetty servlet container", ex);
} }
@ -56,10 +57,12 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
public synchronized void stop() { public synchronized void stop() {
try { try {
this.server.stop(); this.server.stop();
} catch (InterruptedException ex) { }
catch (InterruptedException ex) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
// No drama // No drama
} catch (Exception ex) { }
catch (Exception ex) {
throw new EmbeddedServletContainerException( throw new EmbeddedServletContainerException(
"Unable to stop embedded Jetty servlet container", ex); "Unable to stop embedded Jetty servlet container", ex);
} }

View File

@ -132,7 +132,8 @@ public class JettyEmbeddedServletContainerFactory extends
if (root != null) { if (root != null) {
try { try {
handler.setBaseResource(Resource.newResource(root)); handler.setBaseResource(Resource.newResource(root));
} catch (Exception ex) { }
catch (Exception ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
} }
@ -270,11 +271,13 @@ public class JettyEmbeddedServletContainerFactory extends
if (errorPage.isGlobal()) { if (errorPage.isGlobal()) {
handler.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE, handler.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE,
errorPage.getPath()); errorPage.getPath());
} else { }
else {
if (errorPage.getExceptionName() != null) { if (errorPage.getExceptionName() != null) {
handler.addErrorPage(errorPage.getExceptionName(), handler.addErrorPage(errorPage.getExceptionName(),
errorPage.getPath()); errorPage.getPath());
} else { }
else {
handler.addErrorPage(errorPage.getStatusCode(), handler.addErrorPage(errorPage.getStatusCode(),
errorPage.getPath()); errorPage.getPath());
} }

View File

@ -52,7 +52,8 @@ public class ServletContextInitializerLifecycleListener implements LifecycleList
for (ServletContextInitializer initializer : this.initializers) { for (ServletContextInitializer initializer : this.initializers) {
try { try {
initializer.onStartup(standardContext.getServletContext()); initializer.onStartup(standardContext.getServletContext());
} catch (ServletException ex) { }
catch (ServletException ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
} }

View File

@ -57,7 +57,8 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
}; };
awaitThread.setDaemon(false); awaitThread.setDaemon(false);
awaitThread.start(); awaitThread.start();
} catch (Exception ex) { }
catch (Exception ex) {
throw new EmbeddedServletContainerException( throw new EmbeddedServletContainerException(
"Unable to start embdedded Tomcat", ex); "Unable to start embdedded Tomcat", ex);
} }
@ -68,10 +69,12 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
try { try {
try { try {
this.tomcat.stop(); this.tomcat.stop();
} catch (LifecycleException e) { }
catch (LifecycleException e) {
} }
this.tomcat.destroy(); this.tomcat.destroy();
} catch (Exception ex) { }
catch (Exception ex) {
throw new EmbeddedServletContainerException( throw new EmbeddedServletContainerException(
"Unable to stop embdedded Tomcat", ex); "Unable to stop embdedded Tomcat", ex);
} }

View File

@ -118,7 +118,8 @@ public class TomcatEmbeddedServletContainerFactory extends
this.connector.setPort(getPort()); this.connector.setPort(getPort());
this.tomcat.getService().addConnector(this.connector); this.tomcat.getService().addConnector(this.connector);
this.tomcat.setConnector(this.connector); this.tomcat.setConnector(this.connector);
} else { }
else {
Connector connector = new Connector( Connector connector = new Connector(
"org.apache.coyote.http11.Http11NioProtocol"); "org.apache.coyote.http11.Http11NioProtocol");
customizeConnector(connector); customizeConnector(connector);
@ -246,7 +247,8 @@ public class TomcatEmbeddedServletContainerFactory extends
tempFolder.mkdir(); tempFolder.mkdir();
tempFolder.deleteOnExit(); tempFolder.deleteOnExit();
return tempFolder; return tempFolder;
} catch (IOException ex) { }
catch (IOException ex) {
throw new EmbeddedServletContainerException( throw new EmbeddedServletContainerException(
"Unable to create Tomcat tempdir", ex); "Unable to create Tomcat tempdir", ex);
} }

View File

@ -194,11 +194,13 @@ public class ConfigFileApplicationContextInitializer implements
new PropertiesPropertySource(resource.getDescription(), new PropertiesPropertySource(resource.getDescription(),
properties)); properties));
} else { }
else {
propertySources.addFirst(new PropertiesPropertySource(resource propertySources.addFirst(new PropertiesPropertySource(resource
.getDescription(), properties)); .getDescription(), properties));
} }
} catch (IOException e) { }
catch (IOException e) {
throw new IllegalStateException("Could not load properties file from " throw new IllegalStateException("Could not load properties file from "
+ resource, e); + resource, e);
} }
@ -252,7 +254,8 @@ public class ConfigFileApplicationContextInitializer implements
} }
// matches default profile // matches default profile
return MatchStatus.FOUND; return MatchStatus.FOUND;
} else { }
else {
return MatchStatus.NOT_FOUND; return MatchStatus.NOT_FOUND;
} }
} }

View File

@ -77,7 +77,8 @@ public class ContextIdApplicationContextInitializer implements
index = environment.getProperty("spring.application.index", Integer.class, index); index = environment.getProperty("spring.application.index", Integer.class, index);
if (index >= 0) { if (index >= 0) {
name = name + ":" + index; name = name + ":" + index;
} else { }
else {
// FIXME do we want this // FIXME do we want this
String profiles = StringUtils.arrayToCommaDelimitedString(environment String profiles = StringUtils.arrayToCommaDelimitedString(environment
.getActiveProfiles()); .getActiveProfiles());

View File

@ -95,7 +95,8 @@ public class EnvironmentDelegateApplicationContextInitializer implements
"class [" + className "class [" + className
+ "] must implement ApplicationContextInitializer"); + "] must implement ApplicationContextInitializer");
classes.add((Class<ApplicationContextInitializer<ConfigurableApplicationContext>>) clazz); classes.add((Class<ApplicationContextInitializer<ConfigurableApplicationContext>>) clazz);
} catch (ClassNotFoundException ex) { }
catch (ClassNotFoundException ex) {
throw new ApplicationContextException( throw new ApplicationContextException(
"Failed to load context initializer class [" + className "Failed to load context initializer class [" + className
+ "]", ex); + "]", ex);

View File

@ -170,9 +170,11 @@ public class LoggingApplicationContextInitializer implements
String configLocation = getConfigLocation(applicationContext); String configLocation = getConfigLocation(applicationContext);
try { try {
doInit(applicationContext, configLocation); doInit(applicationContext, configLocation);
} catch (RuntimeException ex) { }
catch (RuntimeException ex) {
throw ex; throw ex;
} catch (Exception ex) { }
catch (Exception ex) {
throw new IllegalStateException("Cannot initialize logging from " throw new IllegalStateException("Cannot initialize logging from "
+ configLocation, ex); + configLocation, ex);
} }

View File

@ -121,7 +121,8 @@ public class VcapApplicationContextInitializer implements
CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME, CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME,
new PropertiesPropertySource("vcap", properties)); new PropertiesPropertySource("vcap", properties));
} else { }
else {
propertySources.addFirst(new PropertiesPropertySource("vcap", properties)); propertySources.addFirst(new PropertiesPropertySource("vcap", properties));
} }
@ -168,19 +169,22 @@ public class VcapApplicationContextInitializer implements
if (StringUtils.hasText(path)) { if (StringUtils.hasText(path)) {
if (key.startsWith("[")) { if (key.startsWith("[")) {
key = path + key; key = path + key;
} else { }
else {
key = path + "." + key; key = path + "." + key;
} }
} }
Object value = entry.getValue(); Object value = entry.getValue();
if (value instanceof String) { if (value instanceof String) {
properties.put(key, value); properties.put(key, value);
} else if (value instanceof Map) { }
else if (value instanceof Map) {
// Need a compound key // Need a compound key
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) value; Map<String, Object> map = (Map<String, Object>) value;
flatten(properties, map, key); flatten(properties, map, key);
} else if (value instanceof Collection) { }
else if (value instanceof Collection) {
// Need a compound key // Need a compound key
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<Object> collection = (Collection<Object>) value; Collection<Object> collection = (Collection<Object>) value;
@ -191,7 +195,8 @@ public class VcapApplicationContextInitializer implements
flatten(properties, flatten(properties,
Collections.singletonMap("[" + (count++) + "]", object), key); Collections.singletonMap("[" + (count++) + "]", object), key);
} }
} else { }
else {
properties.put(key, value == null ? "" : value); properties.put(key, value == null ? "" : value);
} }
} }

View File

@ -40,11 +40,14 @@ public abstract class JavaLoggerConfigurer {
try { try {
LogManager.getLogManager().readConfiguration( LogManager.getLogManager().readConfiguration(
ResourceUtils.getURL(resolvedLocation).openStream()); ResourceUtils.getURL(resolvedLocation).openStream());
} catch (FileNotFoundException e) { }
catch (FileNotFoundException e) {
throw e; throw e;
} catch (RuntimeException e) { }
catch (RuntimeException e) {
throw e; throw e;
} catch (Exception e) { }
catch (Exception e) {
throw new IllegalArgumentException("Could not initialize logging from " throw new IllegalArgumentException("Could not initialize logging from "
+ location, e); + location, e);
} }

View File

@ -47,7 +47,8 @@ public abstract class LogbackConfigurer {
context.stop(); context.stop();
try { try {
new ContextInitializer(context).configureByResource(url); new ContextInitializer(context).configureByResource(url);
} catch (JoranException e) { }
catch (JoranException e) {
throw new IllegalArgumentException("Could not initialize logging from " throw new IllegalArgumentException("Could not initialize logging from "
+ location, e); + location, e);
} }

View File

@ -42,7 +42,8 @@ public abstract class SpringServletInitializer implements WebApplicationInitiali
// no-op because the application context is already initialized // no-op because the application context is already initialized
} }
}); });
} else { }
else {
this.logger this.logger
.debug("No ContextLoaderListener registered, as " .debug("No ContextLoaderListener registered, as "
+ "createRootApplicationContext() did not return an application context"); + "createRootApplicationContext() did not return an application context");

View File

@ -361,7 +361,8 @@ public class SpringApplicationTests {
this.sources = sources; this.sources = sources;
if (this.useMockLoader) { if (this.useMockLoader) {
this.loader = mock(BeanDefinitionLoader.class); this.loader = mock(BeanDefinitionLoader.class);
} else { }
else {
this.loader = spy(super.createBeanDefinitionLoader(registry, sources)); this.loader = spy(super.createBeanDefinitionLoader(registry, sources));
} }
return this.loader; return this.loader;

View File

@ -79,7 +79,8 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
if (this.container != null) { if (this.container != null) {
try { try {
this.container.stop(); this.container.stop();
} catch (Exception e) { }
catch (Exception e) {
} }
} }
} }
@ -156,7 +157,8 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
try { try {
Thread.sleep(500); Thread.sleep(500);
date[0] = new Date(); date[0] = new Date();
} catch (InterruptedException ex) { }
catch (InterruptedException ex) {
throw new ServletException(ex); throw new ServletException(ex);
} }
} }
@ -249,7 +251,8 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
ClientHttpResponse response = request.execute(); ClientHttpResponse response = request.execute();
try { try {
return StreamUtils.copyToString(response.getBody(), Charset.forName("UTF-8")); return StreamUtils.copyToString(response.getBody(), Charset.forName("UTF-8"));
} finally { }
finally {
response.close(); response.close();
} }
} }

View File

@ -55,7 +55,8 @@ public class EmbeddedServletContainerMvcIntegrationTests {
public void closeContext() { public void closeContext() {
try { try {
this.context.close(); this.context.close();
} catch (Exception ex) { }
catch (Exception ex) {
} }
} }
@ -90,7 +91,8 @@ public class EmbeddedServletContainerMvcIntegrationTests {
String actual = StreamUtils.copyToString(response.getBody(), String actual = StreamUtils.copyToString(response.getBody(),
Charset.forName("UTF-8")); Charset.forName("UTF-8"));
assertThat(actual, equalTo("Hello World")); assertThat(actual, equalTo("Hello World"));
} finally { }
finally {
response.close(); response.close();
} }
} }

View File

@ -132,7 +132,8 @@ public class MockEmbeddedServletContainerFactory extends
for (ServletContextInitializer initializer : this.initializers) { for (ServletContextInitializer initializer : this.initializers) {
initializer.onStartup(this.servletContext); initializer.onStartup(this.servletContext);
} }
} catch (ServletException ex) { }
catch (ServletException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }

View File

@ -55,7 +55,8 @@ public abstract class Launcher {
public void launch(String[] args) { public void launch(String[] args) {
try { try {
launch(args, getClass().getProtectionDomain()); launch(args, getClass().getProtectionDomain());
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.exit(1); System.exit(1);
} }

View File

@ -51,7 +51,8 @@ public class MainMethodRunner implements Runnable {
+ " does not have a main method"); + " does not have a main method");
} }
mainMethod.invoke(null, new Object[] { args }); mainMethod.invoke(null, new Object[] { args });
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.exit(1); System.exit(1);
} }

View File

@ -36,7 +36,8 @@ public class WarLauncher extends Launcher {
protected boolean isNestedJarFile(JarEntry jarEntry) { protected boolean isNestedJarFile(JarEntry jarEntry) {
if (jarEntry.isDirectory()) { if (jarEntry.isDirectory()) {
return jarEntry.getName().equals("WEB-INF/classes/"); return jarEntry.getName().equals("WEB-INF/classes/");
} else { }
else {
return jarEntry.getName().startsWith("WEB-INF/lib/") return jarEntry.getName().startsWith("WEB-INF/lib/")
|| jarEntry.getName().startsWith("WEB-INF/lib-provided/"); || jarEntry.getName().startsWith("WEB-INF/lib-provided/");
} }

View File

@ -163,10 +163,12 @@ public class RandomAccessDataFile implements RandomAccessData {
int rtn = file.read(); int rtn = file.read();
moveOn(rtn == -1 ? 0 : 1); moveOn(rtn == -1 ? 0 : 1);
return rtn; return rtn;
} else { }
else {
return (int) moveOn(file.read(b, off, (int) cap(len))); return (int) moveOn(file.read(b, off, (int) cap(len)));
} }
} finally { }
finally {
RandomAccessDataFile.this.filePool.release(file); RandomAccessDataFile.this.filePool.release(file);
} }
} }
@ -222,7 +224,8 @@ public class RandomAccessDataFile implements RandomAccessData {
RandomAccessFile file = this.files.poll(); RandomAccessFile file = this.files.poll();
return (file == null ? new RandomAccessFile( return (file == null ? new RandomAccessFile(
RandomAccessDataFile.this.file, "r") : file); RandomAccessDataFile.this.file, "r") : file);
} catch (InterruptedException e) { }
catch (InterruptedException e) {
throw new IOException(e); throw new IOException(e);
} }
} }
@ -241,10 +244,12 @@ public class RandomAccessDataFile implements RandomAccessData {
file.close(); file.close();
file = files.poll(); file = files.poll();
} }
} finally { }
finally {
this.available.release(size); this.available.release(size);
} }
} catch (InterruptedException e) { }
catch (InterruptedException e) {
throw new IOException(e); throw new IOException(e);
} }
} }

View File

@ -127,7 +127,8 @@ public class RandomAccessJarFile extends JarFile {
((Entry) containedEntry).configure(this.manifest); ((Entry) containedEntry).configure(this.manifest);
} }
} }
} finally { }
finally {
inputStream.close(); inputStream.close();
} }
} }
@ -220,7 +221,8 @@ public class RandomAccessJarFile extends JarFile {
return new RandomAccessJarFile(this.rootJarFile, getName() + "!/" return new RandomAccessJarFile(this.rootJarFile, getName() + "!/"
+ directoryName.substring(0, directoryName.length() - 1), this.data, + directoryName.substring(0, directoryName.length() - 1), this.data,
filtersToUse); filtersToUse);
} else { }
else {
if (ze.getMethod() != ZipEntry.STORED) { if (ze.getMethod() != ZipEntry.STORED) {
throw new IllegalStateException("Unable to open nested compressed entry " throw new IllegalStateException("Unable to open nested compressed entry "
+ ze.getName()); + ze.getName());
@ -411,7 +413,8 @@ public class RandomAccessJarFile extends JarFile {
connect(); connect();
return (int) (this.jarEntry == null ? this.jarFile.size() : this.jarEntry return (int) (this.jarEntry == null ? this.jarFile.size() : this.jarEntry
.getSize()); .getSize());
} catch (IOException e) { }
catch (IOException e) {
return -1; return -1;
} }
} }
@ -453,7 +456,8 @@ public class RandomAccessJarFile extends JarFile {
protected void fill() throws IOException { protected void fill() throws IOException {
try { try {
super.fill(); super.fill();
} catch (EOFException ex) { }
catch (EOFException ex) {
if (this.extraBytesWritten) { if (this.extraBytesWritten) {
throw ex; throw ex;
} }

View File

@ -54,7 +54,8 @@ public class RandomAccessDataZipInputStreamTest {
try { try {
writeDataEntry(zipOutputStream, "a", new byte[10]); writeDataEntry(zipOutputStream, "a", new byte[10]);
writeDataEntry(zipOutputStream, "b", new byte[20]); writeDataEntry(zipOutputStream, "b", new byte[20]);
} finally { }
finally {
zipOutputStream.close(); zipOutputStream.close();
} }
} }
@ -85,7 +86,8 @@ public class RandomAccessDataZipInputStreamTest {
assertThat(entry2.getName(), equalTo("b")); assertThat(entry2.getName(), equalTo("b"));
assertThat(entry2.getData().getSize(), equalTo(20L)); assertThat(entry2.getData().getSize(), equalTo(20L));
assertThat(z.getNextEntry(), nullValue()); assertThat(z.getNextEntry(), nullValue());
} finally { }
finally {
z.close(); z.close();
} }
} }

View File

@ -93,7 +93,8 @@ public class RandomAccessJarFileTest {
jarOutputStream.putNextEntry(nestedEntry); jarOutputStream.putNextEntry(nestedEntry);
jarOutputStream.write(nestedJarData); jarOutputStream.write(nestedJarData);
jarOutputStream.closeEntry(); jarOutputStream.closeEntry();
} finally { }
finally {
jarOutputStream.close(); jarOutputStream.close();
} }
this.jarFile = new RandomAccessJarFile(this.rootJarFile); this.jarFile = new RandomAccessJarFile(this.rootJarFile);

View File

@ -187,7 +187,8 @@ public abstract class AbstractExecutableArchiveMojo extends AbstractMojo {
File archiveFile = createArchive(); File archiveFile = createArchive();
if (this.classifier == null || this.classifier.isEmpty()) { if (this.classifier == null || this.classifier.isEmpty()) {
this.project.getArtifact().setFile(archiveFile); this.project.getArtifact().setFile(archiveFile);
} else { }
else {
this.projectHelper.attachArtifact(this.project, getType(), this.classifier, this.projectHelper.attachArtifact(this.project, getType(), this.classifier,
archiveFile); archiveFile);
} }
@ -209,10 +210,12 @@ public abstract class AbstractExecutableArchiveMojo extends AbstractMojo {
try { try {
archiver.createArchive(this.session, this.project, this.archive); archiver.createArchive(this.session, this.project, this.archive);
return archiveFile; return archiveFile;
} finally { }
finally {
zipFile.close(); zipFile.close();
} }
} catch (Exception ex) { }
catch (Exception ex) {
throw new MojoExecutionException("Error assembling archive", ex); throw new MojoExecutionException("Error assembling archive", ex);
} }
} }
@ -306,7 +309,8 @@ public abstract class AbstractExecutableArchiveMojo extends AbstractMojo {
throw new MojoExecutionException("Unable to resolve launcher classes"); throw new MojoExecutionException("Unable to resolve launcher classes");
} }
return addLauncherClasses(archiver, artifactResult.getArtifact().getFile()); return addLauncherClasses(archiver, artifactResult.getArtifact().getFile());
} catch (Exception ex) { }
catch (Exception ex) {
if (ex instanceof MojoExecutionException) { if (ex instanceof MojoExecutionException) {
throw (MojoExecutionException) ex; throw (MojoExecutionException) ex;
} }

View File

@ -101,10 +101,12 @@ class MainClassFinder {
MainMethodFinder mainMethodFinder = new MainMethodFinder(); MainMethodFinder mainMethodFinder = new MainMethodFinder();
classReader.accept(mainMethodFinder, ClassReader.SKIP_CODE); classReader.accept(mainMethodFinder, ClassReader.SKIP_CODE);
return mainMethodFinder.isFound(); return mainMethodFinder.isFound();
} finally { }
finally {
inputStream.close(); inputStream.close();
} }
} catch (IOException ex) { }
catch (IOException ex) {
return false; return false;
} }
} }

View File

@ -87,7 +87,8 @@ public class MainClassFinderTests {
OutputStream outputStream = new FileOutputStream(file); OutputStream outputStream = new FileOutputStream(file);
try { try {
IOUtil.copy(inputStream, outputStream); IOUtil.copy(inputStream, outputStream);
} finally { }
finally {
outputStream.close(); outputStream.close();
} }
return file; return file;

View File

@ -34,7 +34,8 @@ public class SampleProfileApplicationTests {
public void after() { public void after() {
if (this.profiles != null) { if (this.profiles != null) {
System.setProperty("spring.profiles.active", this.profiles); System.setProperty("spring.profiles.active", this.profiles);
} else { }
else {
System.clearProperty("spring.profiles.active"); System.clearProperty("spring.profiles.active");
} }
} }

View File

@ -35,7 +35,8 @@ public class SampleSimpleApplicationTests {
public void after() { public void after() {
if (this.profiles != null) { if (this.profiles != null) {
System.setProperty("spring.profiles.active", this.profiles); System.setProperty("spring.profiles.active", this.profiles);
} else { }
else {
System.clearProperty("spring.profiles.active"); System.clearProperty("spring.profiles.active");
} }
System.setOut(this.savedOutput); System.setOut(this.savedOutput);