Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-11083

Long/int type mismatch in JDBCSequentialFile.setWritePosition

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.1.0.ER1
    • 7.1.0.DR18
    • ActiveMQ
    • None

      In the JDBCSequentialFile.setWritePosition there is mismatch between types. The parameter of the method has type int but the private field has type long.

      private long writePosition = 0;
      
      void setWritePosition(int writePosition) {
         this.writePosition = writePosition;
      }
      

      Because of this in JDBCSequentialFileFactoryDriver.loadFile the long is unnecessarily retype to int.

      public void loadFile(JDBCSequentialFile file) throws SQLException {
          synchronized (connection) {
             connection.setAutoCommit(false);
             readLargeObject.setLong(1, file.getId());
      
             try (ResultSet rs = readLargeObject.executeQuery()) {
                if (rs.next()) {
                   Blob blob = rs.getBlob(1);
                   if (blob != null) {
                      file.setWritePosition((int) blob.length());
                   } else {
                      logger.warn("ERROR NO BLOB FOR FILE" + "File: " + file.getFileName() + " " + file.getId());
                   }
                }
                connection.commit();
             } catch (SQLException e) {
                connection.rollback();
                throw e;
             }
          }
      }
      

            eduda_jira Erich Duda (Inactive)
            eduda_jira Erich Duda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: