You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Erich Duda (JIRA)" <ji...@apache.org> on 2017/05/30 10:21:04 UTC

[jira] [Created] (ARTEMIS-1190) Long/int type mismatch in JDBCSequentialFile.setWritePosition

Erich Duda created ARTEMIS-1190:
-----------------------------------

             Summary: Long/int type mismatch in JDBCSequentialFile.setWritePosition
                 Key: ARTEMIS-1190
                 URL: https://issues.apache.org/jira/browse/ARTEMIS-1190
             Project: ActiveMQ Artemis
          Issue Type: Bug
          Components: Broker
    Affects Versions: 2.1.0
            Reporter: Erich Duda


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

{code:java}
private long writePosition = 0;

void setWritePosition(int writePosition) {
   this.writePosition = writePosition;
}
{code}

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

{code:java}
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;
       }
    }
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)