Bug 861907 - NPE thrown in SqlTableGatewayListener.getDbConn() causes the listener to stop polling
NPE thrown in SqlTableGatewayListener.getDbConn() causes the listener to stop...
Status: ON_QA
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: JBossESB (Show other bugs)
5.2.0 GA,5.3.0 GA
Unspecified Unspecified
high Severity high
: ---
: ---
Assigned To: tcunning
:
Depends On:
Blocks: 862048
  Show dependency treegraph
 
Reported: 2012-10-01 06:12 EDT by Adam Kovari
Modified: 2015-08-31 23:04 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBESB-3853 Major Closed NPE thrown in SqlTableGatewayListener.getDbConn() causes the listener to stop polling 2016-02-02 21:44 EST
JBoss Issue Tracker JBESB-3854 Major Closed NPE in SqlTableGatewayListener when Oracle goes down 2016-02-02 21:44 EST

  None (edit)
Description Adam Kovari 2012-10-01 06:12:41 EDT
Description of problem:
Listener is not fetching the data from the database after the Data source disconnect and reconnect. To resolve the issue we have to redeploy the esb.

Version-Release number of selected component (if applicable):
JBoss SOA-P 5.2.0

How reproducible:
always

Steps to Reproduce:
1. deploy ESB project which uses SQL listener
2. restart database, wait few minutes
3. notice that SQL listener is stopped
  
Actual results:
SQL listener not polling

Expected results:
SQL listener polling

Additional info:
Proposed fix:
Index: src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	(revision 37737)
+++ src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	(working copy)
@@ -507,7 +507,7 @@
         	    RS.close();
         	
                 oConn.rollback();
-            } catch (final SQLException sqle) {
+            } catch (Exception ex) {
             	refreshDatasource();
             }
Comment 1 Rick Wagner 2012-10-01 14:28:09 EDT
This BZ is for SOA-P 5.2.  Please be aware there is an associated BZ for SOA-P 5.3. (BZ 862055)

This BZ is currently associated with SOA-P 5.2 Rollup SOA_5.2_2_2012.

The SOA-P 5.3 BZ (BZ 862055) is currently associated with Rollup SOA_5.3_2_2012.
Comment 2 JBoss JIRA Server 2012-10-02 02:27:01 EDT
Tadayoshi Sato <tadayosi@gmail.com> made a comment on jira JBESB-3853

Proposed fix by Martin Weiler:
Index: src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	(revision 37737)
+++ src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	(working copy)
@@ -507,7 +507,7 @@
         	    RS.close();
         	
                 oConn.rollback();
-            } catch (final SQLException sqle) {
+            } catch (Exception ex) {
             	refreshDatasource();
             }
Comment 3 JBoss JIRA Server 2012-10-02 02:27:33 EDT
Tadayoshi Sato <tadayosi@gmail.com> made a comment on jira JBESB-3853

Proposed fix by Martin Weiler:
{code}
Index: src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	(revision 37737)
+++ src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	(working copy)
@@ -507,7 +507,7 @@
         	    RS.close();
         	
                 oConn.rollback();
-            } catch (final SQLException sqle) {
+            } catch (Exception ex) {
             	refreshDatasource();
             }
{code}
Comment 4 JBoss JIRA Server 2012-10-02 02:34:30 EDT
Tadayoshi Sato <tadayosi@gmail.com> made a comment on jira JBESB-3853

In the source code of JBoss ESB 4.10, the following object {{"oConn"}} can be null and subsequently a NPE can happen because after the first successful invocation of {{getDbConn()}} the datasource gets out of service.
{code}
473         final JdbcCleanConn oConn = getDbConn();
{code}
After the initial run of {{getDbConn()}} the {{JdbcCleanConn}} object is cached to_the {{dbConn}} field, so the following if block won't be executed subsequently.
{code}
544     protected JdbcCleanConn getDbConn() {
545       DataSource oDS = null;
546         if (null == _dbConn) {
...
566           _dbConn = new JdbcCleanConn(oDS, transacted);
567         }
{code}
And rushing directly into the following line with shortage of the datasource will raise a {{SQLException}} and execute {{releaseDBConnection()}} in the catch block, where is exactly the place of resetting the {{dbConn}} field to null.
{code}
569         if ((null != _dbConn) && (_dbConn.getStatements().size() == 0)) {
570           try {
571             prepareStatements(); 
572           } catch (SQLException e) {
573             releaseDBConnection();
574         _   logger.warn("Exception preparing statements", e);
575           }
576         }
{code}
That's why we will have a NPE at the following line 509 and eventually {{SqlTableGatewayListener}} will stop.
{code}
471     protected List<Map<String, Object>> pollForCandidates() {
...
473         final JdbcCleanConn oConn = getDbConn();
...
509                 oConn.rollback();
{code}
So, I'd say the {{SqlTableGatewayListener}} can terminate forever regardless of the datasource being recovered later in such a scenario that the datasource becomes unavailable temporarily and have failed to make prepared statements by chance.
Comment 5 JBoss JIRA Server 2012-10-02 04:01:17 EDT
Tadayoshi Sato <tadayosi@gmail.com> made a comment on jira JBESB-3853

It seems to be a direct consequence of the changes applied for:
https://issues.jboss.org/browse/JBESB-3282
https://issues.jboss.org/browse/SOA-2012

--> https://source.jboss.org/changelog/JBossESB?cs=32667
Comment 6 JBoss JIRA Server 2012-10-02 09:20:06 EDT
Tom Cunningham <tcunning@redhat.com> updated the status of jira JBESB-3854 to Resolved
Comment 7 JBoss JIRA Server 2012-10-02 12:06:48 EDT
Tom Cunningham <tcunning@redhat.com> updated the status of jira JBESB-3853 to Resolved
Comment 8 JBoss JIRA Server 2012-10-02 12:06:48 EDT
Tom Cunningham <tcunning@redhat.com> made a comment on jira JBESB-3853

Committed to 4.11 CP and to trunk.
Comment 9 JBoss JIRA Server 2012-10-02 12:06:56 EDT
Tom Cunningham <tcunning@redhat.com> updated the status of jira JBESB-3853 to Closed
Comment 10 JBoss JIRA Server 2012-10-02 12:07:03 EDT
Tom Cunningham <tcunning@redhat.com> updated the status of jira JBESB-3854 to Closed

Note You need to log in before you can comment on or make changes to this bug.