Bug 63778 - Jre7Compat cannot find getPseudoColumns with zero parameters
Summary: Jre7Compat cannot find getPseudoColumns with zero parameters
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.94
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2019-09-27 19:09 UTC by Stev Frank
Modified: 2019-10-01 14:54 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Stev Frank 2019-09-27 19:09:10 UTC
The class org.apache.tomcat.util.compat.Jre7Compat fails to find the method java.sql.DatabaseMetaData.getPseudoColumns() with zero parameters in it's static initializer which leads to the remaining methods like ResultSet.getObject() not being looked up and referenced at all. This causes NullPointerExceptions which are especially hard to diagnose because exceptions in all the JreCompat classes are just thrown into the nether.
The method Jre7Compat is trying to find expects 4 String parameters.
The actual call to the looked up method in org.apache.tomcat.util.compat.Jre7Compat.getPseudoColumns(...) is done correctly with all 4 String parameters provided.

What I feel should be done about this:

1. Replace
m9 = DatabaseMetaData.class.getMethod("getPseudoColumns");
m9 = DatabaseMetaData.class.getMethod("getPseudoColumns",String.class,String.class,String.class,String.class);

2. Never simply ignore and void exceptions! I understand that there should not be tons of error messages every time you start up tomcat with an older version of Java but there has to be another way.

We noticed this problem with 7.0.94 but the code looks identical in the current git branch.
Comment 1 Guoxiong Li 2019-09-28 06:57:29 UTC
Catching the exception without handling them is not a good habit. It could hide some problem such as this bug.

I submit a PR to solve the bug. https://github.com/apache/tomcat/pull/209
Hope it could help.
Comment 2 Mark Thomas 2019-10-01 14:54:50 UTC
Thanks for the report.

The original issue has been fixed in 7.0.x and I have added some logging to the JreCompat classes that should detect if further bugs like this creep in in the future.

The fix will be in 7.0.97 onwards