Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-17544

NPE JDBCUpsertOutputFormat

    XMLWordPrintableJSON

Details

    Description

      Encountered a situation where I get an NPE from JDBCUpsertOutputFormat.
      This occurs when close is called before open.

      This happened because I had a sink where it had a final field of type JDBCUpsertOutputFormat.

      The open operation of my sink was slow (blocked on something else) and open on the JDBCUpsertOutputFormat had not yet been called.
      In the mean time the job was cancelled, which caused close on my sink to be called, which then
      called close on the JDBCUpsertOutputFormat .
      This throws an NPE due to a lack of a guard on an internal field that is only initialised in the JDBCUpsertOutputFormat open operation.

      The close method already guards one potentially null value ..

      if (this.scheduledFuture != null) {
      

      But needs the additional guard below ...

      if (jdbcWriter != null)   // << THIS LINE NEEDED TO GUARD UNINITIALISE VAR
         try {
            jdbcWriter.close();
         } catch (SQLException e) {
            LOG.warn("Close JDBC writer failed.", e);
         }
      
      

      See also FLINK-17545

      Attachments

        Issue Links

          Activity

            People

              fsk119 Shengkai Fang
              johnlon John Lonergan
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: