|Summary:||Jre7Compat cannot find getPseudoColumns with zero parameters|
|Product:||Tomcat 7||Reporter:||Stev Frank <annih.apache.org>|
|Component:||Catalina||Assignee:||Tomcat Developers Mailing List <dev>|
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"); with 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