]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2975 remove useless connection initialization in ActiveRecord PostgreSQL adapter
authorsimonbrandhof <simon.brandhof@gmail.com>
Tue, 15 Nov 2011 07:32:16 +0000 (08:32 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Tue, 15 Nov 2011 07:32:16 +0000 (08:32 +0100)
The connection is already initialized by Commons DBCP

sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/postgresql/connection_methods.rb

index e4f9095cf4e57d4c8771814e7828a20b649c56b2..d1e062a7fa6c6c1dab40e71d507b55f670d6e9b2 100644 (file)
@@ -295,7 +295,7 @@ public final class JRubyFacade {
 
   public Connection getConnection() {
     try {
-      return getContainer().getComponentByType(DatabaseConnector.class).getConnection();
+      return getContainer().getComponentByType(Database.class).getDataSource().getConnection();
     } catch (Exception e) {
       /* activerecord does not correctly manage exceptions when connection can not be opened. */
       return null;
index 715a63ae7c8bfef05c1be1b3f72df58a6faefe71..323b3bc3c302509b69ea5d47a4438919d1810360 100644 (file)
@@ -11,7 +11,11 @@ class ActiveRecord::Base
       config[:url] << config[:pg_params] if config[:pg_params]
       config[:driver] ||= "org.postgresql.Driver"
       conn = jdbc_connection(config)
-      conn.execute("SET SEARCH_PATH TO #{config[:schema_search_path]}") if config[:schema_search_path]
+
+      #sonar
+      # Not required because connection is already initialized by the pool (Commons DBCP)
+      #conn.execute("SET SEARCH_PATH TO #{config[:schema_search_path]}") if config[:schema_search_path]
+      #/sonar
       conn
     end
     alias_method :jdbcpostgresql_connection, :postgresql_connection