Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-1190

Long/int type mismatch in JDBCSequentialFile.setWritePosition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.5, 2.1.0
    • 2.2.0
    • Broker
    • None

    Description

      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;
             }
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            eduda Erich Duda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: