sqoop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laszlo Bodor (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SQOOP-3306) Connection resource related issues in DBOutputFormat and OracleManager
Date Mon, 26 Mar 2018 11:38:00 GMT

     [ https://issues.apache.org/jira/browse/SQOOP-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Laszlo Bodor updated SQOOP-3306:
--------------------------------
    Description: 
A fortify scan showed 2 possible resource leaks.

*Overview* : The function getRecordWriter() in DBOutputFormat.java sometimes fails to release
a database resource allocated by getConnection() on line 117.
In the file DBOutputFormat.java similar issues were on line numbers 117

 

Connection should be closed before throwing IOException forward.
{code:java}
    try {

      Connection connection = dbConf.getConnection();

      PreparedStatement statement = null;

      statement = connection.prepareStatement(

                    constructQuery(tableName, fieldNames));

      return new org.apache.sqoop.mapreduce.db.DBOutputFormat.DBRecordWriter(

                     connection, statement);

    } catch (Exception ex) {

      throw new IOException(ex);

    }
{code}
 

*Overview* : The function makeConnection() in OracleManager.java sometimes fails to release
a database resource allocated by getConnection() on line 321.
In the file OracleManager.java similar issues were on line numbers 321

 

Some connection post setup steps could be extracted to a separate method which could be enclosed
by a try/catch.
{code:java}
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);     
setSessionTimeZone(connection);
connection.setAutoCommit(false);
{code}

  was:
A fortify scan showed 2 possible resource leaks.



*Overview* : The function getRecordWriter() in DBOutputFormat.java sometimes fails to release
a database resource allocated by getConnection() on line 117.
In the file DBOutputFormat.java similar issues were on line numbers 117

 

Connection should be closed before throwing IOException forward.
{code}

    try {

      Connection connection = dbConf.getConnection();

      PreparedStatement statement = null;

      statement = connection.prepareStatement(

                    constructQuery(tableName, fieldNames));

      return new org.apache.sqoop.mapreduce.db.DBOutputFormat.DBRecordWriter(

                     connection, statement);

    } catch (Exception ex) {

      throw new IOException(ex);

    }
{code}

 



*Overview* : The function makeConnection() in OracleManager.java sometimes fails to release
a database resource allocated by getConnection() on line 321.
In the file OracleManager.java similar issues were on line numbers 321

 

Some connection setup steps could extract to a separated method which could be enclosed by
a try/catch.
{code}
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);     setSessionTimeZone(connection);
connection.setAutoCommit(false);
{code}


> Connection resource related issues in DBOutputFormat and OracleManager
> ----------------------------------------------------------------------
>
>                 Key: SQOOP-3306
>                 URL: https://issues.apache.org/jira/browse/SQOOP-3306
>             Project: Sqoop
>          Issue Type: Bug
>    Affects Versions: 1.4.7
>            Reporter: Laszlo Bodor
>            Priority: Minor
>             Fix For: 1.5.0
>
>
> A fortify scan showed 2 possible resource leaks.
> *Overview* : The function getRecordWriter() in DBOutputFormat.java sometimes fails to
release a database resource allocated by getConnection() on line 117.
> In the file DBOutputFormat.java similar issues were on line numbers 117
>  
> Connection should be closed before throwing IOException forward.
> {code:java}
>     try {
>       Connection connection = dbConf.getConnection();
>       PreparedStatement statement = null;
>       statement = connection.prepareStatement(
>                     constructQuery(tableName, fieldNames));
>       return new org.apache.sqoop.mapreduce.db.DBOutputFormat.DBRecordWriter(
>                      connection, statement);
>     } catch (Exception ex) {
>       throw new IOException(ex);
>     }
> {code}
>  
> *Overview* : The function makeConnection() in OracleManager.java sometimes fails to
release a database resource allocated by getConnection() on line 321.
> In the file OracleManager.java similar issues were on line numbers 321
>  
> Some connection post setup steps could be extracted to a separate method which could
be enclosed by a try/catch.
> {code:java}
> connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);     
> setSessionTimeZone(connection);
> connection.setAutoCommit(false);
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message