You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2004/05/23 18:19:34 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionFactoryPooledImpl.java

brianm      2004/05/23 09:19:34

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        ConnectionFactoryPooledImpl.java
  Log:
  Better reporting on sql problems, patch submitted by Robert Sfeir
  
  Submitted by: Robert Sfeir
  
  Revision  Changes    Path
  1.12      +3 -10     db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java
  
  Index: ConnectionFactoryPooledImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ConnectionFactoryPooledImpl.java	22 May 2004 09:51:26 -0000	1.11
  +++ ConnectionFactoryPooledImpl.java	23 May 2004 16:19:34 -0000	1.12
  @@ -208,18 +208,11 @@
                   try
                   {
                       rset.close();
  -                }
  -                catch (Exception t)
  -                {
  -                    // ignored
  -                }
  -                try
  -                {
                       stmt.close();
                   }
  -                catch (Exception t)
  +                catch (SQLException t)
                   {
  -                    // ignored
  +                    log.error("Either the statement or resultSet were already closed.", t);
                   }
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionFactoryPooledImpl.java

Posted by Brian McCallister <mc...@forthillcompany.com>.
Noted, fixing.

Sorry i stuck my editor in where it didn't belong =)

-Brian

On May 25, 2004, at 4:00 AM, Armin Waibel wrote:

> Hi Brian,
>
> the leading thought for this construct was to guarantee to do a  
> stmt.close call, no matter what happens when the rset.close call is  
> done (critical is stmt.close). E.g stmt was used two or more times  
> (this is allowed), then the rset can be closed automatic and maybe  
> throw an exception on additional close calls (e.g. when wrapped  
> classes are used), but the stmt is still open.
> A far-fetched scenario?
>
> regards,
> Armin
>
> brianm@apache.org wrote:
>> brianm      2004/05/23 09:19:34
>>   Modified:    src/java/org/apache/ojb/broker/accesslayer
>>                         ConnectionFactoryPooledImpl.java
>>   Log:
>>   Better reporting on sql problems, patch submitted by Robert Sfeir
>>     Submitted by: Robert Sfeir
>>     Revision  Changes    Path
>>   1.12      +3 -10      
>> db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>> ConnectionFactoryPooledImpl.java
>>     Index: ConnectionFactoryPooledImpl.java
>>   ===================================================================
>>   RCS file:  
>> /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>> ConnectionFactoryPooledImpl.java,v
>>   retrieving revision 1.11
>>   retrieving revision 1.12
>>   diff -u -r1.11 -r1.12
>>   --- ConnectionFactoryPooledImpl.java	22 May 2004 09:51:26 -0000	1.11
>>   +++ ConnectionFactoryPooledImpl.java	23 May 2004 16:19:34 -0000	1.12
>>   @@ -208,18 +208,11 @@
>>                    try
>>                    {
>>                        rset.close();
>>   -                }
>>   -                catch (Exception t)
>>   -                {
>>   -                    // ignored
>>   -                }
>>   -                try
>>   -                {
>>                        stmt.close();
>>                    }
>>   -                catch (Exception t)
>>   +                catch (SQLException t)
>>                    {
>>   -                    // ignored
>>   +                    log.error("Either the statement or resultSet  
>> were already closed.", t);
>>                    }
>>                }
>>            }
>>        
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionFactoryPooledImpl.java

Posted by Armin Waibel <ar...@apache.org>.
Hi Robert, Brian,

now it looks nearly fine to me (maybe bad design for real software 
architects) ;-)

Robert Sfeir wrote:

> We shouldn't be catching exception, that's just nasty.
> 

I agree, after 1.0 or 1.1 we should rethink kernel exception handling 
(low priority IMO). But sometimes it's useful to catch exceptions 
without rethrow ;-)


> What should be done is that we need to simplify the try catch block in  
> this case, and just do a check to see if either rs or stmt are null and  
> just not do anything if either is null.  That won't throw NPE, but just  
> catching Exception and not doing anything about it is just bad, since  
> you won't know if there is another problem.  

In method 'validateConnection' we only interested in connection state 
(valid or invalid) no need to throw the exception, because connection 
will be destroyed if state is invalid. The reason will be logged. In 
method 'destroyObject' we not interested throwing an exception, because 
we can't do more than close the connection.

I will add the 'null' checks for ConnectionFactoryPooledImpl - thanks 
for the hint.

regards,
Armin

If I missed the if(stmt !=
> null) sorry, was not my intent, might have been going too fast for my  
> own good.
> 
> R
> 
> On May 25, 2004, at 7:23 AM, Brian McCallister wrote:
> 
>> Changed back to follow original intention (left debugs in =)
>>
>> -Brian
>>
>> On May 25, 2004, at 4:00 AM, Armin Waibel wrote:
>>
>>> Hi Brian,
>>>
>>> the leading thought for this construct was to guarantee to do a  
>>> stmt.close call, no matter what happens when the rset.close call is  
>>> done (critical is stmt.close). E.g stmt was used two or more times  
>>> (this is allowed), then the rset can be closed automatic and maybe  
>>> throw an exception on additional close calls (e.g. when wrapped  
>>> classes are used), but the stmt is still open.
>>> A far-fetched scenario?
>>>
>>> regards,
>>> Armin
>>>
>>> brianm@apache.org wrote:
>>>
>>>> brianm      2004/05/23 09:19:34
>>>>   Modified:    src/java/org/apache/ojb/broker/accesslayer
>>>>                         ConnectionFactoryPooledImpl.java
>>>>   Log:
>>>>   Better reporting on sql problems, patch submitted by Robert Sfeir
>>>>     Submitted by: Robert Sfeir
>>>>     Revision  Changes    Path
>>>>   1.12      +3 -10      
>>>> db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>>>> ConnectionFactoryPooledImpl.java
>>>>     Index: ConnectionFactoryPooledImpl.java
>>>>   ===================================================================
>>>>   RCS file:  
>>>> /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>>>> ConnectionFactoryPooledImpl.java,v
>>>>   retrieving revision 1.11
>>>>   retrieving revision 1.12
>>>>   diff -u -r1.11 -r1.12
>>>>   --- ConnectionFactoryPooledImpl.java    22 May 2004 09:51:26  
>>>> -0000    1.11
>>>>   +++ ConnectionFactoryPooledImpl.java    23 May 2004 16:19:34  
>>>> -0000    1.12
>>>>   @@ -208,18 +208,11 @@
>>>>                    try
>>>>                    {
>>>>                        rset.close();
>>>>   -                }
>>>>   -                catch (Exception t)
>>>>   -                {
>>>>   -                    // ignored
>>>>   -                }
>>>>   -                try
>>>>   -                {
>>>>                        stmt.close();
>>>>                    }
>>>>   -                catch (Exception t)
>>>>   +                catch (SQLException t)
>>>>                    {
>>>>   -                    // ignored
>>>>   +                    log.error("Either the statement or resultSet  
>>>> were already closed.", t);
>>>>                    }
>>>>                }
>>>>            }
>>>>        
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
> Robert S. Sfeir
> Technical Lead
> HHS Portal
> robert_sfeir@sra.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionFactoryPooledImpl.java

Posted by Robert Sfeir <ro...@codepuccino.com>.
We shouldn't be catching exception, that's just nasty.

What should be done is that we need to simplify the try catch block in  
this case, and just do a check to see if either rs or stmt are null and  
just not do anything if either is null.  That won't throw NPE, but just  
catching Exception and not doing anything about it is just bad, since  
you won't know if there is another problem.  If I missed the if(stmt !=  
null) sorry, was not my intent, might have been going too fast for my  
own good.

R

On May 25, 2004, at 7:23 AM, Brian McCallister wrote:

> Changed back to follow original intention (left debugs in =)
>
> -Brian
>
> On May 25, 2004, at 4:00 AM, Armin Waibel wrote:
>
>> Hi Brian,
>>
>> the leading thought for this construct was to guarantee to do a  
>> stmt.close call, no matter what happens when the rset.close call is  
>> done (critical is stmt.close). E.g stmt was used two or more times  
>> (this is allowed), then the rset can be closed automatic and maybe  
>> throw an exception on additional close calls (e.g. when wrapped  
>> classes are used), but the stmt is still open.
>> A far-fetched scenario?
>>
>> regards,
>> Armin
>>
>> brianm@apache.org wrote:
>>> brianm      2004/05/23 09:19:34
>>>   Modified:    src/java/org/apache/ojb/broker/accesslayer
>>>                         ConnectionFactoryPooledImpl.java
>>>   Log:
>>>   Better reporting on sql problems, patch submitted by Robert Sfeir
>>>     Submitted by: Robert Sfeir
>>>     Revision  Changes    Path
>>>   1.12      +3 -10      
>>> db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>>> ConnectionFactoryPooledImpl.java
>>>     Index: ConnectionFactoryPooledImpl.java
>>>   ===================================================================
>>>   RCS file:  
>>> /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>>> ConnectionFactoryPooledImpl.java,v
>>>   retrieving revision 1.11
>>>   retrieving revision 1.12
>>>   diff -u -r1.11 -r1.12
>>>   --- ConnectionFactoryPooledImpl.java	22 May 2004 09:51:26  
>>> -0000	1.11
>>>   +++ ConnectionFactoryPooledImpl.java	23 May 2004 16:19:34  
>>> -0000	1.12
>>>   @@ -208,18 +208,11 @@
>>>                    try
>>>                    {
>>>                        rset.close();
>>>   -                }
>>>   -                catch (Exception t)
>>>   -                {
>>>   -                    // ignored
>>>   -                }
>>>   -                try
>>>   -                {
>>>                        stmt.close();
>>>                    }
>>>   -                catch (Exception t)
>>>   +                catch (SQLException t)
>>>                    {
>>>   -                    // ignored
>>>   +                    log.error("Either the statement or resultSet  
>>> were already closed.", t);
>>>                    }
>>>                }
>>>            }
>>>        
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
Robert S. Sfeir
Technical Lead
HHS Portal
robert_sfeir@sra.com


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionFactoryPooledImpl.java

Posted by Brian McCallister <mc...@forthillcompany.com>.
Changed back to follow original intention (left debugs in =)

-Brian

On May 25, 2004, at 4:00 AM, Armin Waibel wrote:

> Hi Brian,
>
> the leading thought for this construct was to guarantee to do a  
> stmt.close call, no matter what happens when the rset.close call is  
> done (critical is stmt.close). E.g stmt was used two or more times  
> (this is allowed), then the rset can be closed automatic and maybe  
> throw an exception on additional close calls (e.g. when wrapped  
> classes are used), but the stmt is still open.
> A far-fetched scenario?
>
> regards,
> Armin
>
> brianm@apache.org wrote:
>> brianm      2004/05/23 09:19:34
>>   Modified:    src/java/org/apache/ojb/broker/accesslayer
>>                         ConnectionFactoryPooledImpl.java
>>   Log:
>>   Better reporting on sql problems, patch submitted by Robert Sfeir
>>     Submitted by: Robert Sfeir
>>     Revision  Changes    Path
>>   1.12      +3 -10      
>> db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>> ConnectionFactoryPooledImpl.java
>>     Index: ConnectionFactoryPooledImpl.java
>>   ===================================================================
>>   RCS file:  
>> /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ 
>> ConnectionFactoryPooledImpl.java,v
>>   retrieving revision 1.11
>>   retrieving revision 1.12
>>   diff -u -r1.11 -r1.12
>>   --- ConnectionFactoryPooledImpl.java	22 May 2004 09:51:26 -0000	1.11
>>   +++ ConnectionFactoryPooledImpl.java	23 May 2004 16:19:34 -0000	1.12
>>   @@ -208,18 +208,11 @@
>>                    try
>>                    {
>>                        rset.close();
>>   -                }
>>   -                catch (Exception t)
>>   -                {
>>   -                    // ignored
>>   -                }
>>   -                try
>>   -                {
>>                        stmt.close();
>>                    }
>>   -                catch (Exception t)
>>   +                catch (SQLException t)
>>                    {
>>   -                    // ignored
>>   +                    log.error("Either the statement or resultSet  
>> were already closed.", t);
>>                    }
>>                }
>>            }
>>        
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionFactoryPooledImpl.java

Posted by Armin Waibel <ar...@apache.org>.
Hi Brian,

the leading thought for this construct was to guarantee to do a 
stmt.close call, no matter what happens when the rset.close call is done 
(critical is stmt.close). E.g stmt was used two or more times (this is 
allowed), then the rset can be closed automatic and maybe throw an 
exception on additional close calls (e.g. when wrapped classes are 
used), but the stmt is still open.
A far-fetched scenario?

regards,
Armin

brianm@apache.org wrote:
> brianm      2004/05/23 09:19:34
> 
>   Modified:    src/java/org/apache/ojb/broker/accesslayer
>                         ConnectionFactoryPooledImpl.java
>   Log:
>   Better reporting on sql problems, patch submitted by Robert Sfeir
>   
>   Submitted by: Robert Sfeir
>   
>   Revision  Changes    Path
>   1.12      +3 -10     db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java
>   
>   Index: ConnectionFactoryPooledImpl.java
>   ===================================================================
>   RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java,v
>   retrieving revision 1.11
>   retrieving revision 1.12
>   diff -u -r1.11 -r1.12
>   --- ConnectionFactoryPooledImpl.java	22 May 2004 09:51:26 -0000	1.11
>   +++ ConnectionFactoryPooledImpl.java	23 May 2004 16:19:34 -0000	1.12
>   @@ -208,18 +208,11 @@
>                    try
>                    {
>                        rset.close();
>   -                }
>   -                catch (Exception t)
>   -                {
>   -                    // ignored
>   -                }
>   -                try
>   -                {
>                        stmt.close();
>                    }
>   -                catch (Exception t)
>   +                catch (SQLException t)
>                    {
>   -                    // ignored
>   +                    log.error("Either the statement or resultSet were already closed.", t);
>                    }
>                }
>            }
>   
>   
>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org