You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2015/06/17 09:05:27 UTC

ambari git commit: Revert "AMBARI-11965 - Fix high impact Outstanding Security Risks (Dmytro Shkvyra via abaranchuk)"

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 778d6c218 -> 4b142b3ad


Revert "AMBARI-11965 - Fix high impact Outstanding Security Risks (Dmytro Shkvyra via abaranchuk)"

This reverts commit 2eaac094c4331e815a40a7bd13ef5bfed4f837c1.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4b142b3a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4b142b3a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4b142b3a

Branch: refs/heads/branch-2.1
Commit: 4b142b3ade01162f0617deef58f4d38dda15d638
Parents: 778d6c2
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Wed Jun 17 00:05:07 2015 -0700
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Wed Jun 17 00:05:07 2015 -0700

----------------------------------------------------------------------
 .../metrics/timeline/PhoenixHBaseAccessor.java  |  18 +-
 .../ambari/eventdb/db/PostgresConnector.java    |  12 +-
 .../ambari/server/agent/HeartBeatHandler.java   |   7 +-
 .../server/api/services/AmbariMetaInfo.java     |   4 +-
 .../api/services/serializers/CsvSerializer.java |  23 +-
 .../gsinstaller/ClusterDefinition.java          |  10 +-
 .../controller/jdbc/JDBCResourceProvider.java   |  10 +-
 .../metrics/RestMetricsPropertyProvider.java    |   9 +-
 .../ambari/server/orm/DBAccessorImpl.java       | 337 ++++++++-----------
 .../ambari/server/orm/entities/ViewEntity.java  |   1 -
 .../encryption/CredentialStoreServiceImpl.java  |   9 +-
 .../apache/ambari/server/view/ViewRegistry.java |  33 +-
 .../ambari/server/orm/DBAccessorImplTest.java   |   1 +
 .../encryption/CredentialStoreServiceTest.java  |   1 +
 .../ambari/server/view/ViewRegistryTest.java    |  14 +-
 .../shell/commands/BlueprintCommands.java       |  13 +-
 16 files changed, 183 insertions(+), 319 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
index d018f29..8e5d101 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
@@ -396,7 +396,7 @@ public class PhoenixHBaseAccessor {
     try {
       //get latest
       if(condition.isPointInTime()){
-        getLatestMetricRecords(condition, conn, metrics);
+        stmt = getLatestMetricRecords(condition, conn, metrics);
       } else {
         stmt = PhoenixTransactSQL.prepareGetMetricsSqlStmt(conn, condition);
         rs = stmt.executeQuery();
@@ -465,7 +465,7 @@ public class PhoenixHBaseAccessor {
     }
   }
 
-  private void getLatestMetricRecords(
+  private PreparedStatement getLatestMetricRecords(
     Condition condition, Connection conn, TimelineMetrics metrics)
     throws SQLException, IOException {
 
@@ -490,10 +490,9 @@ public class PhoenixHBaseAccessor {
           // Ignore
         }
       }
-      if (stmt != null) {
-        stmt.close();
-      }
     }
+
+    return stmt;
   }
 
   /**
@@ -516,7 +515,7 @@ public class PhoenixHBaseAccessor {
     try {
       //get latest
       if(condition.isPointInTime()) {
-        getLatestAggregateMetricRecords(condition, conn, metrics, metricFunctions);
+        stmt = getLatestAggregateMetricRecords(condition, conn, metrics, metricFunctions);
       } else {
         stmt = PhoenixTransactSQL.prepareGetAggregateSqlStmt(conn, condition);
 
@@ -578,7 +577,7 @@ public class PhoenixHBaseAccessor {
     }
   }
 
-  private void getLatestAggregateMetricRecords(Condition condition,
+  private PreparedStatement getLatestAggregateMetricRecords(Condition condition,
       Connection conn, TimelineMetrics metrics,
       Map<String, List<Function>> metricFunctions) throws SQLException {
 
@@ -620,11 +619,10 @@ public class PhoenixHBaseAccessor {
             // Ignore
           }
         }
-        if (stmt != null) {
-          stmt.close();
-        }        
       }
     }
+
+    return stmt;
   }
 
   private SingleValuedTimelineMetric getAggregateTimelineMetricFromResultSet(ResultSet rs,

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/eventdb/db/PostgresConnector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/eventdb/db/PostgresConnector.java b/ambari-server/src/main/java/org/apache/ambari/eventdb/db/PostgresConnector.java
index 421d001..552df9c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/eventdb/db/PostgresConnector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/eventdb/db/PostgresConnector.java
@@ -164,12 +164,8 @@ public class PostgresConnector implements DBConnector {
       throw new IOException(e);
     } finally {
       try {
-        if (rs != null){
+        if (rs != null)
           rs.close();
-        }
-        if (ps != null) {
-          ps.close();
-        }
       } catch (SQLException e) {
         LOG.error("Exception while closing ResultSet", e);
       }
@@ -197,12 +193,8 @@ public class PostgresConnector implements DBConnector {
       throw new IOException(e);
     } finally {
       try {
-        if (rs != null) {
+        if (rs != null)
           rs.close();
-        }
-        if (ps != null) {
-          ps.close();
-        }        
       } catch (SQLException e) {
         LOG.error("Exception while closing ResultSet", e);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index 6f34b62..1c993ef 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -1125,12 +1125,7 @@ public class HeartBeatHandler {
                   keytabMap.put(KerberosIdentityDataFileReader.KEYTAB_FILE_GROUP_ACCESS, record.get(KerberosIdentityDataFileReader.KEYTAB_FILE_GROUP_ACCESS));
 
                   BufferedInputStream bufferedIn = new BufferedInputStream(new FileInputStream(keytabFile));
-                  byte[] keytabContent = null;
-                  try {
-                    keytabContent = IOUtils.toByteArray(bufferedIn);
-                  } finally {
-                    bufferedIn.close();
-                  }
+                  byte[] keytabContent = IOUtils.toByteArray(bufferedIn);
                   String keytabContentBase64 = Base64.encodeBase64String(keytabContent);
                   keytabMap.put(KerberosServerAction.KEYTAB_CONTENT_BASE64, keytabContentBase64);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index 4afa9b0..a77f7b1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -736,9 +736,7 @@ public class AmbariMetaInfo {
     if (!versionFile.exists()) {
       throw new AmbariException("Server version file does not exist.");
     }
-    Scanner scanner = new Scanner(versionFile);
-    serverVersion = scanner.useDelimiter("\\Z").next();
-    scanner.close();
+    serverVersion = new Scanner(versionFile).useDelimiter("\\Z").next();
   }
 
   private void getCustomActionDefinitions(File customActionDefinitionRoot) throws JAXBException, AmbariException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/CsvSerializer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/CsvSerializer.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/CsvSerializer.java
index 04dd1ab..87751dc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/CsvSerializer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/CsvSerializer.java
@@ -32,8 +32,6 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 /**
  * CSV serializer used to generate a CSV-formatted document from a result.
@@ -79,7 +77,7 @@ public class CsvSerializer implements ResultSerializer {
     if (result.getStatus().isErrorState()) {
       return serializeError(result.getStatus());
     } else {
-      CSVPrinter csvPrinter = null;
+
       try {
         // A StringBuffer to store the CSV-formatted document while building it.  It may be
         // necessary to use file-based storage if the data set is expected to be really large.
@@ -88,7 +86,7 @@ public class CsvSerializer implements ResultSerializer {
         TreeNode<Resource> root = result.getResultTree();
 
         if (root != null) {
-          csvPrinter = new CSVPrinter(buffer, CSVFormat.DEFAULT);
+          CSVPrinter csvPrinter = new CSVPrinter(buffer, CSVFormat.DEFAULT);
 
           // TODO: recursively handle tree structure, for now only handle single level of detail
           if ("true".equalsIgnoreCase(root.getStringProperty("isCollection"))) {
@@ -109,23 +107,15 @@ public class CsvSerializer implements ResultSerializer {
       } catch (IOException e) {
         //todo: exception handling.  Create ResultStatus 500 and call serializeError
         throw new RuntimeException("Unable to serialize to csv: " + e, e);
-      } finally {
-        if (csvPrinter != null) {
-          try {
-            csvPrinter.close();
-          } catch (IOException ex) {
-          }
-        }
       }
     }
   }
 
   @Override
   public Object serializeError(ResultStatus error) {
-    CSVPrinter csvPrinter = null;
     try {
       StringBuffer buffer = new StringBuffer();
-      csvPrinter = new CSVPrinter(buffer, CSVFormat.DEFAULT);
+      CSVPrinter csvPrinter = new CSVPrinter(buffer, CSVFormat.DEFAULT);
 
       csvPrinter.printRecord(Arrays.asList("status", "message"));
       csvPrinter.printRecord(Arrays.asList(error.getStatus().getStatus(), error.getMessage()));
@@ -134,13 +124,6 @@ public class CsvSerializer implements ResultSerializer {
     } catch (IOException e) {
       //todo: exception handling.  Create ResultStatus 500 and call serializeError
       throw new RuntimeException("Unable to serialize to csv: " + e, e);
-    } finally {
-      if (csvPrinter != null) {
-        try {
-          csvPrinter.close();
-        } catch (IOException ex) {
-        }
-      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java
index 6f9876a..b6dfa30 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java
@@ -228,9 +228,8 @@ public class ClusterDefinition {
    * Read the gsInstaller cluster definition file.
    */
   private void readClusterDefinition() {
-    InputStream is = null;
     try {
-      is = this.getClass().getClassLoader().getResourceAsStream(CLUSTER_DEFINITION_FILE);
+      InputStream    is = this.getClass().getClassLoader().getResourceAsStream(CLUSTER_DEFINITION_FILE);
       BufferedReader br = new BufferedReader(new InputStreamReader(is));
 
       String line;
@@ -281,13 +280,6 @@ public class ClusterDefinition {
     } catch (IOException e) {
       String msg = "Caught exception reading " + CLUSTER_DEFINITION_FILE + ".";
       throw new IllegalStateException(msg, e);
-    } finally {
-      if (is != null) {
-        try {
-          is.close();
-        } catch (IOException ex) {
-        }
-      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java
index 3edde8a..2f2eab1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java
@@ -416,9 +416,8 @@ public class JDBCResourceProvider extends BaseProvider implements ResourceProvid
             this.importedKeys.put(table, importedKeys);
 
             DatabaseMetaData metaData = connection.getMetaData();
-            ResultSet rs = null;
-            try {
-            rs = metaData.getImportedKeys(connection.getCatalog(), null, table);
+
+            ResultSet rs = metaData.getImportedKeys(connection.getCatalog(), null, table);
 
             while (rs.next()) {
 
@@ -430,11 +429,6 @@ public class JDBCResourceProvider extends BaseProvider implements ResourceProvid
 
                 importedKeys.put(pkPropertyId, fkPropertyId);
             }
-            } finally {
-              if (rs != null) {
-                rs.close();
-              }
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProvider.java
index b32adda..b92537b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProvider.java
@@ -225,16 +225,13 @@ public class RestMetricsPropertyProvider extends ThreadPoolEnabledPropertyProvid
       try {
         InputStream in = streamProvider.readFrom(getSpec(protocol, hostname, port, url));
         if (!ticket.isValid()) {
-          if (in != null) {
-            in.close();
-          }
           return resource;
-        }       
+        }
         try {
           extractValuesFromJSON(in, urls.get(url), resource, propertyInfos);
         } finally {
-            in.close();
-          }
+          in.close();
+        }
       } catch (IOException e) {
         logException(e);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
index 6e31eee..c891691 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
@@ -41,12 +41,11 @@ import org.eclipse.persistence.sessions.DatabaseLogin;
 import org.eclipse.persistence.sessions.DatabaseSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
+ 
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.nio.charset.Charset;
 import java.sql.Blob;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
@@ -71,7 +70,7 @@ public class DBAccessorImpl implements DBAccessor {
   private static final String dbURLPatternString = "jdbc:(.*?):.*";
   private Pattern dbURLPattern = Pattern.compile(dbURLPatternString, Pattern.CASE_INSENSITIVE);
   private DbType dbType;
-  
+
   @Inject
   public DBAccessorImpl(Configuration configuration) {
     this.configuration = configuration;
@@ -80,14 +79,14 @@ public class DBAccessorImpl implements DBAccessor {
       Class.forName(configuration.getDatabaseDriver());
 
       connection = DriverManager.getConnection(configuration.getDatabaseUrl(),
-              configuration.getDatabaseUser(),
-              configuration.getDatabasePassword());
+        configuration.getDatabaseUser(),
+        configuration.getDatabasePassword());
 
       connection.setAutoCommit(true); //enable autocommit
 
       //TODO create own mapping and platform classes for supported databases
-      String vendorName = connection.getMetaData().getDatabaseProductName()
-              + connection.getMetaData().getDatabaseMajorVersion();
+      String vendorName = connection.getMetaData().getDatabaseProductName() +
+        connection.getMetaData().getDatabaseMajorVersion();
       String dbPlatform = DBPlatformHelper.getDBPlatform(vendorName, new AbstractSessionLog() {
         @Override
         public void log(SessionLogEntry sessionLogEntry) {
@@ -107,13 +106,13 @@ public class DBAccessorImpl implements DBAccessor {
     if (databasePlatform instanceof OraclePlatform) {
       dbType = DbType.ORACLE;
       return new OracleHelper(databasePlatform);
-    } else if (databasePlatform instanceof MySQLPlatform) {
+    }else if (databasePlatform instanceof MySQLPlatform) {
       dbType = DbType.MYSQL;
       return new MySqlHelper(databasePlatform);
-    } else if (databasePlatform instanceof PostgreSQLPlatform) {
+    }else if (databasePlatform instanceof PostgreSQLPlatform) {
       dbType = DbType.POSTGRES;
       return new PostgresHelper(databasePlatform);
-    } else if (databasePlatform instanceof DerbyPlatform) {
+    }else if (databasePlatform instanceof DerbyPlatform) {
       dbType = DbType.DERBY;
       return new DerbyHelper(databasePlatform);
     } else {
@@ -130,8 +129,8 @@ public class DBAccessorImpl implements DBAccessor {
   public Connection getNewConnection() {
     try {
       return DriverManager.getConnection(configuration.getDatabaseUrl(),
-              configuration.getDatabaseUser(),
-              configuration.getDatabasePassword());
+        configuration.getDatabaseUser(),
+        configuration.getDatabasePassword());
     } catch (SQLException e) {
       throw new RuntimeException("Unable to connect to database", e);
     }
@@ -144,7 +143,7 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public void createTable(String tableName, List<DBColumnInfo> columnInfo,
-          String... primaryKeyColumns) throws SQLException {
+                          String... primaryKeyColumns) throws SQLException {
     if (!tableExists(tableName)) {
       String query = dbmsHelper.getCreateTableStatement(tableName, columnInfo, Arrays.asList(primaryKeyColumns));
 
@@ -168,24 +167,27 @@ public class DBAccessorImpl implements DBAccessor {
     DatabaseMetaData metaData = getDatabaseMetaData();
     if (metaData.storesLowerCaseIdentifiers()) {
       return objectName.toLowerCase();
-    } else if (metaData.storesUpperCaseIdentifiers()) {
+    }else if (metaData.storesUpperCaseIdentifiers()) {
       return objectName.toUpperCase();
     }
 
     return objectName;
   }
 
+
+
   @Override
   public boolean tableExists(String tableName) throws SQLException {
     boolean result = false;
     DatabaseMetaData metaData = getDatabaseMetaData();
 
-    ResultSet res = metaData.getTables(null, null, convertObjectName(tableName), new String[]{"TABLE"});
+    ResultSet res = metaData.getTables(null, null, convertObjectName(tableName), new String[] { "TABLE" });
 
     if (res != null) {
       try {
         if (res.next()) {
-          return res.getString("TABLE_NAME") != null && res.getString("TABLE_NAME").equalsIgnoreCase(tableName);
+          return res.getString("TABLE_NAME") != null && res.getString
+            ("TABLE_NAME").equalsIgnoreCase(tableName);
         }
       } finally {
         res.close();
@@ -206,7 +208,7 @@ public class DBAccessorImpl implements DBAccessor {
     boolean retVal = false;
     ResultSet rs = null;
     try {
-      rs = statement.executeQuery(query);
+       rs = statement.executeQuery(query);
       if (rs != null) {
         if (rs.next()) {
           return rs.getInt(1) > 0;
@@ -215,9 +217,6 @@ public class DBAccessorImpl implements DBAccessor {
     } catch (Exception e) {
       LOG.error("Unable to check if table " + tableName + " has any data. Exception: " + e.getMessage());
     } finally {
-      if (statement != null) {
-        statement.close();
-      }
       if (rs != null) {
         rs.close();
       }
@@ -234,7 +233,8 @@ public class DBAccessorImpl implements DBAccessor {
     if (rs != null) {
       try {
         if (rs.next()) {
-          return rs.getString("COLUMN_NAME") != null && rs.getString("COLUMN_NAME").equalsIgnoreCase(columnName);
+          return rs.getString("COLUMN_NAME") != null && rs.getString
+            ("COLUMN_NAME").equalsIgnoreCase(columnName);
         }
       } finally {
         rs.close();
@@ -245,7 +245,7 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   @Override
-  public boolean tableHasColumn(String tableName, String... columnName) throws SQLException {
+  public boolean tableHasColumn(String tableName, String... columnName) throws SQLException{
     List<String> columnsList = new ArrayList<String>(Arrays.asList(columnName));
     DatabaseMetaData metaData = getDatabaseMetaData();
 
@@ -292,18 +292,19 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public boolean tableHasForeignKey(String tableName, String refTableName,
-          String columnName, String refColumnName) throws SQLException {
+              String columnName, String refColumnName) throws SQLException {
     return tableHasForeignKey(tableName, refTableName, new String[]{columnName}, new String[]{refColumnName});
   }
 
   @Override
   public boolean tableHasForeignKey(String tableName, String referenceTableName, String[] keyColumns,
-          String[] referenceColumns) throws SQLException {
+                                    String[] referenceColumns) throws SQLException {
     DatabaseMetaData metaData = getDatabaseMetaData();
 
     //NB: reference table contains pk columns while key table contains fk columns
+
     ResultSet rs = metaData.getCrossReference(null, null, convertObjectName(referenceTableName),
-            null, null, convertObjectName(tableName));
+      null, null, convertObjectName(tableName));
 
     List<String> pkColumns = new ArrayList<String>(referenceColumns.length);
     for (String referenceColumn : referenceColumns) {
@@ -331,10 +332,12 @@ public class DBAccessorImpl implements DBAccessor {
               fkColumns.remove(fkIndex);
             }
 
+
           } else {
             LOG.debug("pkCol={}, fkCol={} not found in provided column names, skipping", pkColumn, fkColumn); //TODO debug
           }
 
+
         }
         if (pkColumns.isEmpty() && fkColumns.isEmpty()) {
           return true;
@@ -345,13 +348,14 @@ public class DBAccessorImpl implements DBAccessor {
       }
     }
 
+
     return false;
 
   }
 
   @Override
   public void createIndex(String indexName, String tableName,
-          String... columnNames) throws SQLException {
+                          String... columnNames) throws SQLException {
     String query = dbmsHelper.getCreateIndexStatement(indexName, tableName, columnNames);
 
     executeQuery(query);
@@ -359,49 +363,48 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public void addFKConstraint(String tableName, String constraintName,
-          String keyColumn, String referenceTableName,
-          String referenceColumn, boolean ignoreFailure) throws SQLException {
+                              String keyColumn, String referenceTableName,
+                              String referenceColumn, boolean ignoreFailure) throws SQLException {
 
     addFKConstraint(tableName, constraintName, new String[]{keyColumn}, referenceTableName,
-            new String[]{referenceColumn}, false, ignoreFailure);
+        new String[]{referenceColumn}, false, ignoreFailure);
   }
-
   @Override
   public void addFKConstraint(String tableName, String constraintName,
-          String keyColumn, String referenceTableName,
-          String referenceColumn, boolean shouldCascadeOnDelete,
-          boolean ignoreFailure) throws SQLException {
+                              String keyColumn, String referenceTableName,
+                              String referenceColumn, boolean shouldCascadeOnDelete,
+                              boolean ignoreFailure) throws SQLException {
 
     addFKConstraint(tableName, constraintName, new String[]{keyColumn}, referenceTableName,
-            new String[]{referenceColumn}, shouldCascadeOnDelete, ignoreFailure);
+      new String[]{referenceColumn}, shouldCascadeOnDelete, ignoreFailure);
   }
 
   @Override
   public void addFKConstraint(String tableName, String constraintName,
-          String[] keyColumns, String referenceTableName,
-          String[] referenceColumns,
-          boolean ignoreFailure) throws SQLException {
+                              String[] keyColumns, String referenceTableName,
+                              String[] referenceColumns,
+                              boolean ignoreFailure) throws SQLException {
     addFKConstraint(tableName, constraintName, keyColumns, referenceTableName, referenceColumns, false, ignoreFailure);
   }
 
   @Override
   public void addFKConstraint(String tableName, String constraintName,
-          String[] keyColumns, String referenceTableName,
-          String[] referenceColumns, boolean shouldCascadeOnDelete,
-          boolean ignoreFailure) throws SQLException {
+                              String[] keyColumns, String referenceTableName,
+                              String[] referenceColumns, boolean shouldCascadeOnDelete,
+                              boolean ignoreFailure) throws SQLException {
     if (!tableHasForeignKey(tableName, referenceTableName, keyColumns, referenceColumns)) {
       String query = dbmsHelper.getAddForeignKeyStatement(tableName, constraintName,
-              Arrays.asList(keyColumns),
-              referenceTableName,
-              Arrays.asList(referenceColumns),
-              shouldCascadeOnDelete);
+          Arrays.asList(keyColumns),
+          referenceTableName,
+          Arrays.asList(referenceColumns),
+          shouldCascadeOnDelete);
 
       try {
         executeQuery(query, ignoreFailure);
       } catch (SQLException e) {
-        LOG.warn("Add FK constraint failed"
-                + ", constraintName = " + constraintName
-                + ", tableName = " + tableName, e.getMessage());
+        LOG.warn("Add FK constraint failed" +
+                ", constraintName = " + constraintName +
+                ", tableName = " + tableName, e.getMessage());
         if (!ignoreFailure) {
           throw e;
         }
@@ -411,13 +414,13 @@ public class DBAccessorImpl implements DBAccessor {
     }
   }
 
-  public boolean tableHasConstraint(String tableName, String constraintName) throws SQLException {
+  public boolean tableHasConstraint(String tableName, String constraintName) throws SQLException{
     // this kind of request is well lower level as we querying system tables, due that we need for some the name of catalog.
     String query = dbmsHelper.getTableConstraintsStatement(connection.getCatalog(), tableName);
     ResultSet rs = executeSelect(query);
-    if (rs != null) {
+    if (rs != null){
       while (rs.next()) {
-        if (rs.getString("CONSTRAINT_NAME").equalsIgnoreCase(constraintName)) {
+        if (rs.getString("CONSTRAINT_NAME").equalsIgnoreCase(constraintName)){
           return true;
         }
       }
@@ -427,7 +430,7 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public void addUniqueConstraint(String tableName, String constraintName, String... columnNames)
-          throws SQLException {
+    throws SQLException{
     if (!tableHasConstraint(tableName, constraintName)) {
       String query = dbmsHelper.getAddUniqueConstraintStatement(tableName, constraintName, columnNames);
       try {
@@ -442,25 +445,25 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   @Override
-  public void addPKConstraint(String tableName, String constraintName, boolean ignoreErrors, String... columnName) throws SQLException {
+  public void addPKConstraint(String tableName, String constraintName, boolean ignoreErrors, String... columnName) throws SQLException{
     if (!tableHasPrimaryKey(tableName, null) && tableHasColumn(tableName, columnName)) {
       String query = dbmsHelper.getAddPrimaryKeyConstraintStatement(tableName, constraintName, columnName);
 
       executeQuery(query, ignoreErrors);
     } else {
       LOG.warn("Primary constraint {} not altered to table {} as column {} not present or constraint already exists",
-              constraintName, tableName, columnName);
+        constraintName, tableName, columnName);
     }
   }
 
   @Override
-  public void addPKConstraint(String tableName, String constraintName, String... columnName) throws SQLException {
+  public void addPKConstraint(String tableName, String constraintName, String... columnName) throws SQLException{
     addPKConstraint(tableName, constraintName, false, columnName);
   }
 
   @Override
   public void renameColumn(String tableName, String oldColumnName,
-          DBColumnInfo columnInfo) throws SQLException {
+                           DBColumnInfo columnInfo) throws SQLException {
     //it is mandatory to specify type in column change clause for mysql
     String renameColumnStatement = dbmsHelper.getRenameColumnStatement(tableName, oldColumnName, columnInfo);
     executeQuery(renameColumnStatement);
@@ -485,7 +488,7 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public void alterColumn(String tableName, DBColumnInfo columnInfo)
-          throws SQLException {
+      throws SQLException {
     //varchar extension only (derby limitation, but not too much for others),
     if (dbmsHelper.supportsColumnTypeChange()) {
       String statement = dbmsHelper.getAlterColumnStatement(tableName,
@@ -494,9 +497,9 @@ public class DBAccessorImpl implements DBAccessor {
     } else {
       //use addColumn: add_tmp-update-drop-rename for Derby
       DBColumnInfo columnInfoTmp = new DBColumnInfo(
-              columnInfo.getName() + "_TMP",
-              columnInfo.getType(),
-              columnInfo.getLength());
+          columnInfo.getName() + "_TMP",
+          columnInfo.getType(),
+          columnInfo.getLength());
       String statement = dbmsHelper.getAddColumnStatement(tableName, columnInfoTmp);
       executeQuery(statement);
       updateTable(tableName, columnInfo, columnInfoTmp);
@@ -507,43 +510,32 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public void updateTable(String tableName, DBColumnInfo columnNameFrom,
-          DBColumnInfo columnNameTo) throws SQLException {
+      DBColumnInfo columnNameTo) throws SQLException {
     LOG.info("Executing query: UPDATE TABLE " + tableName + " SET "
-            + columnNameTo.getName() + "=" + columnNameFrom.getName());
+        + columnNameTo.getName() + "=" + columnNameFrom.getName());
 
     String statement = "SELECT * FROM " + tableName;
     int typeFrom = getColumnType(tableName, columnNameFrom.getName());
     int typeTo = getColumnType(tableName, columnNameTo.getName());
-    Statement dbStatement = null;
-    ResultSet rs = null;
-    try {
-    dbStatement = getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
-            ResultSet.CONCUR_UPDATABLE); 
-    rs = dbStatement.executeQuery(statement);
+    ResultSet rs = executeSelect(statement, ResultSet.TYPE_SCROLL_SENSITIVE,
+            ResultSet.CONCUR_UPDATABLE);
 
     while (rs.next()) {
       convertUpdateData(rs, columnNameFrom, typeFrom, columnNameTo, typeTo);
       rs.updateRow();
     }
-    } finally {
-      if (rs != null) {
-        rs.close();
-      }
-      if (dbStatement != null) {
-        dbStatement.close();
-      }
-    }
+    rs.close();
   }
 
   private void convertUpdateData(ResultSet rs, DBColumnInfo columnNameFrom,
-          int typeFrom,
-          DBColumnInfo columnNameTo, int typeTo) throws SQLException {
+      int typeFrom,
+      DBColumnInfo columnNameTo, int typeTo) throws SQLException {
     if (typeFrom == Types.BLOB && typeTo == Types.CLOB) {
       //BLOB-->CLOB
       Blob data = rs.getBlob(columnNameFrom.getName());
       if (data != null) {
         rs.updateClob(columnNameTo.getName(),
-                new BufferedReader(new InputStreamReader(data.getBinaryStream(), Charset.defaultCharset())));
+            new BufferedReader(new InputStreamReader(data.getBinaryStream())));
       }
     } else {
       Object data = rs.getObject(columnNameFrom.getName());
@@ -562,7 +554,7 @@ public class DBAccessorImpl implements DBAccessor {
 
     for (int i = 0; i < columnNames.length; i++) {
       builder.append(columnNames[i]);
-      if (i != columnNames.length - 1) {
+      if(i!=columnNames.length-1){
         builder.append(",");
       }
     }
@@ -571,7 +563,7 @@ public class DBAccessorImpl implements DBAccessor {
 
     for (int i = 0; i < values.length; i++) {
       builder.append(values[i]);
-      if (i != values.length - 1) {
+      if(i!=values.length-1){
         builder.append(",");
       }
     }
@@ -588,20 +580,18 @@ public class DBAccessorImpl implements DBAccessor {
       if (!ignoreFailure) {
         throw e;
       }
-    } finally {
-      if (statement != null) {
-        statement.close();
-      }
     }
 
     return rowsUpdated != 0;
   }
 
+
   @Override
   public int updateTable(String tableName, String columnName, Object value,
-          String whereClause) throws SQLException {
+                         String whereClause) throws SQLException {
 
-    StringBuilder query = new StringBuilder(String.format("UPDATE %s SET %s = ", tableName, columnName));
+    StringBuilder query = new StringBuilder
+      (String.format("UPDATE %s SET %s = ", tableName, columnName));
 
     // Only String and number supported.
     // Taken from: org.eclipse.persistence.internal.databaseaccess.appendParameterInternal
@@ -616,31 +606,24 @@ public class DBAccessorImpl implements DBAccessor {
     query.append(whereClause);
 
     Statement statement = getConnection().createStatement();
-    int res = -1;
-    try {
-      res = statement.executeUpdate(query.toString());
-    } finally {
-      if (statement != null) {
-        statement.close();
-      }
-    }
-    return res;
+
+    return statement.executeUpdate(query.toString());
   }
 
   @Override
-  public int executeUpdate(String query) throws SQLException {
-    return executeUpdate(query, false);
+  public int executeUpdate(String query) throws SQLException{
+    return  executeUpdate(query, false);
   }
 
   @Override
-  public int executeUpdate(String query, boolean ignoreErrors) throws SQLException {
+  public int executeUpdate(String query, boolean ignoreErrors) throws SQLException{
     Statement statement = getConnection().createStatement();
     try {
       return statement.executeUpdate(query);
-    } catch (SQLException e) {
-      LOG.warn("Error executing query: " + query + ", "
-              + "errorCode = " + e.getErrorCode() + ", message = " + e.getMessage());
-      if (!ignoreErrors) {
+    } catch (SQLException e){
+      LOG.warn("Error executing query: " + query + ", " +
+                 "errorCode = " + e.getErrorCode() + ", message = " + e.getMessage());
+      if (!ignoreErrors){
         throw e;
       }
     }
@@ -648,8 +631,8 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   @Override
-  public void executeQuery(String query, String tableName, String hasColumnName) throws SQLException {
-    if (tableHasColumn(tableName, hasColumnName)) {
+  public void executeQuery(String query, String tableName, String hasColumnName) throws SQLException{
+    if (tableHasColumn(tableName, hasColumnName)){
       executeQuery(query);
     }
   }
@@ -662,20 +645,10 @@ public class DBAccessorImpl implements DBAccessor {
   @Override
   public ResultSet executeSelect(String query) throws SQLException {
     Statement statement = getConnection().createStatement();
-    ResultSet rs = statement.executeQuery(query);
-    statement.closeOnCompletion();
-    return rs;
+    return statement.executeQuery(query);
   }
 
   @Override
-  public ResultSet executeSelect(String query, int resultSetType, int resultSetConcur) throws SQLException {
-    Statement statement = getConnection().createStatement(resultSetType, resultSetConcur);
-    ResultSet rs = statement.executeQuery(query);
-    statement.closeOnCompletion();
-    return rs;
-  }  
-  
-  @Override
   public void executeQuery(String query, boolean ignoreFailure) throws SQLException {
     LOG.info("Executing query: {}", query);
     Statement statement = getConnection().createStatement();
@@ -686,12 +659,8 @@ public class DBAccessorImpl implements DBAccessor {
         LOG.error("Error executing query: " + query, e);
         throw e;
       } else {
-        LOG.warn("Error executing query: " + query + ", "
-                + "errorCode = " + e.getErrorCode() + ", message = " + e.getMessage());
-      }
-    } finally {
-      if (statement != null) {
-        statement.close();
+        LOG.warn("Error executing query: " + query + ", " +
+          "errorCode = " + e.getErrorCode() + ", message = " + e.getMessage());
       }
     }
   }
@@ -702,8 +671,12 @@ public class DBAccessorImpl implements DBAccessor {
     executeQuery(query);
   }
 
-
   @Override
+  public ResultSet executeSelect(String query, int resultSetType, int resultSetConcur) throws SQLException {
+    Statement statement = getConnection().createStatement(resultSetType, resultSetConcur);
+    return statement.executeQuery(query);
+  }
+
   public void truncateTable(String tableName) throws SQLException {
     String query = "DELETE FROM " + tableName;
     executeQuery(query);
@@ -739,8 +712,8 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   @Override
-  public void dropUniqueConstraint(String tableName, String constraintName, boolean ignoreFailure) throws SQLException {
-    if (tableHasConstraint(convertObjectName(tableName), convertObjectName(constraintName))) {
+  public void dropUniqueConstraint(String tableName, String constraintName, boolean ignoreFailure) throws SQLException{
+    if (tableHasConstraint(convertObjectName(tableName), convertObjectName(constraintName))){
       String query = dbmsHelper.getDropUniqueConstraintStatement(tableName, constraintName);
       executeQuery(query, ignoreFailure);
     } else {
@@ -749,22 +722,22 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   @Override
-  public void dropUniqueConstraint(String tableName, String constraintName) throws SQLException {
+  public void dropUniqueConstraint(String tableName, String constraintName) throws SQLException{
     dropUniqueConstraint(tableName, constraintName, false);
   }
 
   @Override
-  public void dropPKConstraint(String tableName, String constraintName, String columnName) throws SQLException {
-    if (tableHasPrimaryKey(tableName, columnName)) {
-      String query = dbmsHelper.getDropPrimaryKeyStatement(convertObjectName(tableName), constraintName);
-      executeQuery(query, false);
-    } else {
-      LOG.warn("Primary key doesn't exists for {} table, skipping", tableName);
+  public void dropPKConstraint(String tableName, String constraintName, String columnName) throws SQLException{
+    if (tableHasPrimaryKey(tableName, columnName)){
+        String query = dbmsHelper.getDropPrimaryKeyStatement(convertObjectName(tableName), constraintName);
+        executeQuery(query, false);
+    } else{
+        LOG.warn("Primary key doesn't exists for {} table, skipping", tableName);
     }
   }
 
   @Override
-  public void dropPKConstraint(String tableName, String constraintName, boolean ignoreFailure) throws SQLException {
+  public void dropPKConstraint(String tableName, String constraintName, boolean ignoreFailure) throws SQLException{
     /*
      * Note, this is un-safe implementation as constraint name checking will work only for PostgresSQL,
      * MySQL and Oracle doesn't use constraint name for drop primary key
@@ -773,31 +746,24 @@ public class DBAccessorImpl implements DBAccessor {
     if (tableHasPrimaryKey(tableName, null)) {
       String query = dbmsHelper.getDropPrimaryKeyStatement(convertObjectName(tableName), constraintName);
       executeQuery(query, ignoreFailure);
-    } else {
+    } else{
       LOG.warn("Primary key doesn't exists for {} table, skipping", tableName);
     }
   }
 
   @Override
-  public void dropPKConstraint(String tableName, String constraintName) throws SQLException {
+  public void dropPKConstraint(String tableName, String constraintName) throws SQLException{
     dropPKConstraint(tableName, constraintName, false);
   }
 
   @Override
   /**
-   * Execute script with autocommit and error tolerance, like psql and sqlplus
-   * do by default
+   * Execute script with autocommit and error tolerance, like psql and sqlplus do by default
    */
   public void executeScript(String filePath) throws SQLException, IOException {
     BufferedReader br = new BufferedReader(new FileReader(filePath));
-    try {
-      ScriptRunner scriptRunner = new ScriptRunner(getConnection(), false, false);
-      scriptRunner.runScript(br);
-    } finally {
-      if (br != null) {
-        br.close();
-      }
-    }
+    ScriptRunner scriptRunner = new ScriptRunner(getConnection(), false, false);
+    scriptRunner.runScript(br);
   }
 
   @Override
@@ -813,55 +779,31 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   @Override
-  public boolean tableHasPrimaryKey(String tableName, String columnName) throws SQLException {
+  public boolean tableHasPrimaryKey(String tableName, String columnName) throws SQLException{
     ResultSet rs = getDatabaseMetaData().getPrimaryKeys(null, null, convertObjectName(tableName));
-    boolean res = false;
-    try {
-      if (rs != null && columnName != null) {
-        while (rs.next()) {
-          if (rs.getString("COLUMN_NAME").equalsIgnoreCase(columnName)) {
-            res = true;
-            break;
-          }
+    if (rs != null && columnName != null){
+      while (rs.next()){
+        if (rs.getString("COLUMN_NAME").equalsIgnoreCase(columnName)) {
+          return true;
         }
-      } else if (rs != null) {
-        res = rs.next();
-      }
-    } finally {
-      if (rs != null) {
-        rs.close();
       }
+    } else if (rs != null){
+      return rs.next();
     }
-    return res;
+    return false;
   }
 
   @Override
   public int getColumnType(String tableName, String columnName)
-          throws SQLException {
+      throws SQLException {
     // We doesn't require any actual result except metadata, so WHERE clause shouldn't match
-    int res;
-    String query;
-    Statement statement = null;
-    ResultSet rs = null;
-    ResultSetMetaData rsmd = null;
-    try {
-    query = String.format("SELECT %s FROM %s WHERE 1=2", columnName, convertObjectName(tableName));
-    statement = getConnection().createStatement();
-    rs = statement.executeQuery(query);
-    rsmd = rs.getMetaData();
-    res = rsmd.getColumnType(1);
-    } finally {
-      if (rs != null){
-        rs.close();
-      }
-      if (statement != null) {
-        statement.close();
-      }
-    }
-    return res;
+    String query = String.format("SELECT %s FROM %s WHERE 1=2", columnName, convertObjectName(tableName));
+    ResultSet rs = executeSelect(query);
+    ResultSetMetaData rsmd = rs.getMetaData();
+    return rsmd.getColumnType(1);
   }
 
-  private ResultSetMetaData getColumnMetadata(String tableName, String columnName) throws SQLException {
+  private ResultSetMetaData getColumnMetadata(String tableName, String columnName) throws SQLException{
     // We doesn't require any actual result except metadata, so WHERE clause shouldn't match
     String query = String.format("SELECT %s FROM %s WHERE 1=2", convertObjectName(columnName), convertObjectName(tableName));
     ResultSet rs = executeSelect(query);
@@ -870,20 +812,20 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public Class getColumnClass(String tableName, String columnName)
-          throws SQLException, ClassNotFoundException {
-    ResultSetMetaData rsmd = getColumnMetadata(tableName, columnName);
-    return Class.forName(rsmd.getColumnClassName(1));
+          throws SQLException, ClassNotFoundException{
+      ResultSetMetaData rsmd = getColumnMetadata(tableName, columnName);
+      return Class.forName(rsmd.getColumnClassName(1));
   }
 
   @Override
-  public boolean isColumnNullable(String tableName, String columnName) throws SQLException {
+  public boolean isColumnNullable(String tableName, String columnName) throws SQLException{
     ResultSetMetaData rsmd = getColumnMetadata(tableName, columnName);
     return !(rsmd.isNullable(1) == ResultSetMetaData.columnNoNulls);
   }
 
   @Override
   public void setColumnNullable(String tableName, DBAccessor.DBColumnInfo columnInfo, boolean nullable)
-          throws SQLException {
+      throws SQLException {
 
     String statement = dbmsHelper.getSetNullableStatement(tableName, columnInfo, nullable);
     executeQuery(statement);
@@ -900,7 +842,7 @@ public class DBAccessorImpl implements DBAccessor {
         executeQuery(query);
       } else {
         LOG.info("Column nullability property is not changed due to {} column from {} table is already in {} state, skipping",
-                columnName, tableName, (nullable) ? "nullable" : "not nullable");
+                   columnName, tableName, (nullable)?"nullable":"not nullable");
       }
     } catch (ClassNotFoundException e) {
       LOG.error("Could not modify table=[], column={}, error={}", tableName, columnName, e.getMessage());
@@ -912,22 +854,27 @@ public class DBAccessorImpl implements DBAccessor {
     // ToDo: create column with more random name
     String tempColumnName = columnName + "_temp";
 
-    switch (configuration.getDatabaseType()) {
+    switch (configuration.getDatabaseType()){
       case ORACLE:
-        if (String.class.equals(fromType)
-                && (toType.equals(Character[].class))
-                || toType.equals(char[].class)) {
+        // ToDo: add check, if target column is a part of constraint.
+        // oracle doesn't support direct type change from varchar2 -> clob
+        if (String.class.equals(fromType) && (Character[].class.equals(toType) || char[].class.equals(toType))){
           addColumn(tableName, new DBColumnInfo(tempColumnName, toType));
           executeUpdate(String.format("UPDATE %s SET %s = %s", convertObjectName(tableName),
-                  convertObjectName(tempColumnName), convertObjectName(columnName)));
+                                       convertObjectName(tempColumnName), convertObjectName(columnName)));
           dropColumn(tableName, columnName);
-          renameColumn(tableName, tempColumnName, new DBColumnInfo(columnName, toType));
+          renameColumn(tableName,tempColumnName, new DBColumnInfo(columnName, toType));
           return;
         }
-        break;
     }
 
     alterColumn(tableName, new DBColumnInfo(columnName, toType, null));
   }
 
+
+
+
+
+
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
index c7630ed..f3ddaff 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewEntity.java
@@ -802,7 +802,6 @@ public class ViewEntity implements ViewDefinition {
    *
    * @return the mask class name.
    */
-  @Override
   public String getMask() {
     return mask;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceImpl.java
index 28760a9..767911c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceImpl.java
@@ -33,7 +33,6 @@ import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
-import java.util.logging.Level;
 
 public class CredentialStoreServiceImpl implements CredentialStoreService {
   private static final String CREDENTIALS_SUFFIX = "credentials.jceks";
@@ -132,9 +131,8 @@ public class CredentialStoreServiceImpl implements CredentialStoreService {
   }
 
   private void createKeystore(String filename, String keystoreType) {
-    FileOutputStream out = null;
     try {
-      out = new FileOutputStream(filename);
+      FileOutputStream out = new FileOutputStream(filename);
       KeyStore ks = KeyStore.getInstance(keystoreType);
       ks.load(null, null);
       ks.store(out, masterService.getMasterSecret());
@@ -148,11 +146,6 @@ public class CredentialStoreServiceImpl implements CredentialStoreService {
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
-    } finally {
-      try {
-        out.close();
-      } catch (IOException ex) {
-      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
index 7c79f39..61b9327 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
@@ -98,10 +98,7 @@ import javax.inject.Provider;
 import javax.inject.Singleton;
 
 import java.beans.IntrospectionException;
-import java.io.Closeable;
 import java.io.File;
-import java.io.IOException;
-import java.net.URLClassLoader;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -114,7 +111,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
 
 /**
  * Registry for view and view instance definitions.
@@ -1537,31 +1533,28 @@ public class ViewRegistry {
     String extractedArchiveDirPath = extractedArchiveDirFile.getAbsolutePath();
 
     LOG.info("Reading view archive " + archiveFile + ".");
-    ClassLoader cl = null;
+
     try {
       // extract the archive and get the class loader
-      cl = extractor.extractViewArchive(viewDefinition, archiveFile, extractedArchiveDirFile);
+      ClassLoader cl = extractor.extractViewArchive(viewDefinition, archiveFile, extractedArchiveDirFile);
 
       ViewConfig viewConfig = archiveUtility.getViewConfigFromExtractedArchive(extractedArchiveDirPath,
           configuration.isViewValidationEnabled());
 
       if (viewConfig == null) {
         setViewStatus(viewDefinition, ViewEntity.ViewStatus.ERROR, "View configuration not found");
-      } else {
-        viewDefinition.setConfiguration(viewConfig);
-      }
+      } 
+      viewDefinition.setConfiguration(viewConfig);
 
       if (checkViewVersions(viewDefinition, serverVersion)) {
         setupViewDefinition(viewDefinition, cl);
 
         Set<ViewInstanceEntity> instanceDefinitions = new HashSet<ViewInstanceEntity>();
-        List<InstanceConfig> instanceConfigs = viewConfig.getInstances();
-        if (instanceConfigs != null) {
-          for (InstanceConfig instanceConfig : instanceConfigs) {
-            ViewInstanceEntity instanceEntity = createViewInstanceDefinition(viewConfig, viewDefinition, instanceConfig);
-            instanceEntity.setXmlDriven(true);
-            instanceDefinitions.add(instanceEntity);
-          }
+
+        for (InstanceConfig instanceConfig : viewConfig.getInstances()) {
+          ViewInstanceEntity instanceEntity = createViewInstanceDefinition(viewConfig, viewDefinition, instanceConfig);
+          instanceEntity.setXmlDriven(true);
+          instanceDefinitions.add(instanceEntity);
         }
         persistView(viewDefinition, instanceDefinitions);
 
@@ -1574,14 +1567,6 @@ public class ViewRegistry {
 
       setViewStatus(viewDefinition, ViewEntity.ViewStatus.ERROR, msg + " : " + e.getMessage());
       LOG.error(msg, e);
-    } finally {
-      if (cl instanceof Closeable) {
-        try {
-          ((URLClassLoader)cl).close();
-        } catch (IOException ex) {
-        }
-      }
-      
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
index a2e4d58..6a3ecf9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
@@ -19,6 +19,7 @@
 package org.apache.ambari.server.orm;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.matchers.JUnitMatchers.containsString;
 
 import java.sql.ResultSet;

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/test/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceTest.java
index 0652a52..877d2f4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceTest.java
@@ -21,6 +21,7 @@ import junit.framework.Assert;
 import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
index 09df011..ebe607b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
@@ -108,19 +108,19 @@ import org.springframework.security.core.GrantedAuthority;
  */
 public class ViewRegistryTest {
 
-  private static final String view_xml1 = "<view>\n" +
+  private static String view_xml1 = "<view>\n" +
       "    <name>MY_VIEW</name>\n" +
       "    <label>My View!</label>\n" +
       "    <version>1.0.0</version>\n" +
       "</view>";
 
-  private static final String view_xml2 = "<view>\n" +
+  private static String view_xml2 = "<view>\n" +
       "    <name>MY_VIEW</name>\n" +
       "    <label>My View!</label>\n" +
       "    <version>2.0.0</version>\n" +
       "</view>";
 
-  private static final String xml_valid_instance = "<view>\n" +
+  private static String xml_valid_instance = "<view>\n" +
       "    <name>MY_VIEW</name>\n" +
       "    <label>My View!</label>\n" +
       "    <version>1.0.0</version>\n" +
@@ -149,7 +149,7 @@ public class ViewRegistryTest {
       "    </instance>\n" +
       "</view>";
 
-  private static final String xml_invalid_instance = "<view>\n" +
+  private static String xml_invalid_instance = "<view>\n" +
       "    <name>MY_VIEW</name>\n" +
       "    <label>My View!</label>\n" +
       "    <version>1.0.0</version>\n" +
@@ -169,7 +169,7 @@ public class ViewRegistryTest {
       "    </instance>\n" +
       "</view>";
 
-  private static final String AUTO_VIEW_XML = "<view>\n" +
+  private static String AUTO_VIEW_XML = "<view>\n" +
       "    <name>MY_VIEW</name>\n" +
       "    <label>My View!</label>\n" +
       "    <version>1.0.0</version>\n" +
@@ -180,7 +180,7 @@ public class ViewRegistryTest {
       "    </auto-instance>\n" +
       "</view>";
 
-  private static final String AUTO_VIEW_WILD_STACK_XML = "<view>\n" +
+  private static String AUTO_VIEW_WILD_STACK_XML = "<view>\n" +
       "    <name>MY_VIEW</name>\n" +
       "    <label>My View!</label>\n" +
       "    <version>1.0.0</version>\n" +
@@ -191,7 +191,7 @@ public class ViewRegistryTest {
       "    </auto-instance>\n" +
       "</view>";
 
-  private static final String AUTO_VIEW_BAD_STACK_XML = "<view>\n" +
+  private static String AUTO_VIEW_BAD_STACK_XML = "<view>\n" +
       "    <name>MY_VIEW</name>\n" +
       "    <label>My View!</label>\n" +
       "    <version>1.0.0</version>\n" +

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b142b3a/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/commands/BlueprintCommands.java
----------------------------------------------------------------------
diff --git a/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/commands/BlueprintCommands.java b/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/commands/BlueprintCommands.java
index e568ecd..73000d0 100644
--- a/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/commands/BlueprintCommands.java
+++ b/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/commands/BlueprintCommands.java
@@ -24,8 +24,6 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import org.apache.ambari.groovy.client.AmbariClient;
 import org.apache.ambari.shell.completion.Blueprint;
@@ -170,19 +168,10 @@ public class BlueprintCommands implements CommandMarker {
 
   private String readContent(File file) {
     String content = null;
-    FileInputStream fis = null;
     try {
-      fis = new FileInputStream(file);
-      content = IOUtils.toString(fis);
+      content = IOUtils.toString(new FileInputStream(file));
     } catch (IOException e) {
       // not important
-    } finally {
-      if (fis != null) {
-        try {
-          fis.close();
-        } catch (IOException ex) {
-        }
-      }
     }
     return content;
   }