View Javadoc
1   /*
2    * Copyright 2010 James Pether Sörling
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   *	$Id$
17   *  $HeadURL$
18  */
19  package com.hack23.cia.service.data.impl.liquidbase;
20  
21  import org.apache.commons.lang3.exception.ExceptionUtils;
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  
25  import liquibase.exception.LiquibaseException;
26  import liquibase.integration.spring.SpringLiquibase;
27  
28  /**
29   * The Class SpringLiquidBaseFailSafe.
30   */
31  public final class SpringLiquidBaseFailSafe extends SpringLiquibase {
32  
33  	/** The Constant LOGGER. */
34  	private static final Logger LOGGER = LoggerFactory
35  			.getLogger(SpringLiquidBaseFailSafe.class);
36  
37  
38  	@Override
39  	public void afterPropertiesSet() throws LiquibaseException {
40  		try {
41  			super.afterPropertiesSet();
42  		} catch (final LiquibaseException | RuntimeException e) {
43  			final String stackTrace = ExceptionUtils.getStackTrace(e);
44  			if(stackTrace.contains("Connection was already closed - calling hashCode is no longer allowed")) {
45  				LOGGER.warn("Problem after executing liquidbase, failed removing closed atomikos connection");
46  			} else {
47  				LOGGER.warn("Problem executing liquidbase", e);
48  			}
49  
50  		}
51  	}
52  
53  }