Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    NullPointerException in SQLDataSource.getSQLClause with customSQL field

    SmartClient Version: v13.1p_2026-04-24/Enterprise Deployment (built 2026-04-24)

    I’m encountering an intermittent NullPointerException in my custom server dataSource when working with SQLDataSource.getSQLClause:

    Code:
    Caused by: java.lang.NullPointerException
        at com.isomorphic.datasource.IncludeFromDefinition.create(IncludeFromDefinition.java:118)
        at com.isomorphic.datasource.DSRequest.buildIncludeFromDefinitions(DSRequest.java:8527)
        at com.isomorphic.datasource.DSRequest.buildFieldData(DSRequest.java:5947)
        at com.isomorphic.sql.SQLDataSource.getSQLClause(SQLDataSource.java:5707)
        at com.isomorphic.sql.SQLDataSource.getSQLClause(SQLDataSource.java:5671)
    The exception occurs when executing:

    Code:
    SQLDataSource.getSQLClause(SQLClauseType.Values, dsRequest)
    where dsRequest is built server-side, of type update, with criteria composed of a single primary key and some dynamic fields.
    In some cases, these values contain only one field to update, but that field may be customSQL, so it will not appear in the generated SQL (and that’s exactly what I want to detect, to avoid executing a useless update).

    Normally everything works, but I’d say I can frequently reproduce this error if I trigger two requests close together. The dataSource uses my custom serverConstructor via Spring.

    Do you happen to have any idea what could be causing the problem? I’m not really sure how to debug this further.

    #2
    I forgot to mention that these update requests are created (under certain conditions) as a result of a fetch- one for each record in the dataList returned by the fetch. In this case, there are 75 records, so 75 DSRequests of type update are created.

    I want to discard the unnecessary ones using that check, which occasionally fails, and then execute the remaining ones using SQLDataSource.executeAsBatch.

    In practice, I’m able to reproduce the issue with two fetches triggered close together, and it seems that the error always occurs on the 75th DSRequest of type update.

    Comment


      #3
      The problem is earlier in the processing - we tried calling DataSourceManager.get() to get an instance of your DataSource, but something crashed. The later NPE isn't the problem - once we can't get the DataSource, there's no way to complete the request.

      Since this is happening with two nearly-concurrent requests, we would guess that your Spring serverConstructor has some sort of concurrency bug and threw an exception during DataSource creation.

      If you look earlier in the log for something like "Couldn't create DataSource" or "Failed to create data source" you should see us logging whatever exception your Spring code threw.

      Comment

      Working...
      X