I found a patter matcher bug that seems to be an edge case, but is causing an NPE when I try to use <isc:loadDS="DynamicDS_10" /> on a JSP when a DynamicDS_1 already exists.
It appears that the
actually returns the pointer to "DynamicDS_1" instead (I don't have the source code to be exactly sure).
SmartClient Version: v9.1p_2014-08-06/Pro Deployment (built 2014-08-06)
Browsers: all (server-side issue)
To reproduce, you need over 10 datasources, including 1 and 10. Here are two classes that will replicate the issue:
This dynamic generator in production would be pulling fields from the database, but this is hardcoded for test case purposes.
This class will create 12 of the above classes and register them. After doing so, it will create an NPE.
It appears that the
Code:
getDynamicDataSource("DynamicDS_10", new DSRequest())
SmartClient Version: v9.1p_2014-08-06/Pro Deployment (built 2014-08-06)
Browsers: all (server-side issue)
To reproduce, you need over 10 datasources, including 1 and 10. Here are two classes that will replicate the issue:
This dynamic generator in production would be pulling fields from the database, but this is hardcoded for test case purposes.
Code:
public class DynamicDSGeneratorTestCase implements DynamicDSGenerator { private static Logger log = new Logger(DynamicDSGeneratorTestCase.class.getName()); private String dynamicDSName; public void setDynamicDSName(final String dynamicDSName) { this.dynamicDSName = dynamicDSName; } @Override public DataSource getDataSource(final String paramString, final DSRequest paramDSRequest) { if (dynamicDSName.equals(paramString)) { try { final StringWriter stringWriter = new StringWriter(); stringWriter.write("<DataSource ID=\"" + dynamicDSName + "\" titleField=\"name\" " + "serverConstructor=\"spring:rankingSummaryColumnsDataSource\">\n"); stringWriter.write("<fields> \n"); stringWriter.write("<field name=\"date\" title=\"Date\" type=\"text\" />"); stringWriter.write("<field name=\"transcription\" " + "title=\"Transcription\" type=\"text\" />"); stringWriter.write("</fields>\n</DataSource>"); return DataSource.fromXML(stringWriter.toString()); } catch (final Exception e) { log.error("Problems when creating dynamic server side datasource.", e); } } return null; } }
Code:
public class DynamicDSGeneratorTestCaseRegistrar { public void registerMultipleDataSources() { final DynamicDSGeneratorTestCase dynamicDSGeneratorTestCase = new DynamicDSGeneratorTestCase(); final String dynamicDSName = "DynamicDS"; for (int i = 1; i < 13; i++) { final String dynamicDSId = dynamicDSName + "_" + i; dynamicDSGeneratorTestCase.setDynamicDSName(dynamicDSId); DataSource.addDynamicDSGenerator(dynamicDSGeneratorTestCase, dynamicDSId); } //returns dynamicDS_1, causing getDataSource() to fail the first if statement and return null final DataSource ds = DataSource.getDynamicDataSource("DynamicDS_10", new DSRequest()); //NPE System.out.println(ds.toString()); } }
Comment