Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-137

Writing blob with size -1

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.1.8
    • 1.3.0
    • Other
    • None
    • Sprint connector/j 1.3.0

    Description

      When trying to write a blob via an input stream of unknown size, you most likely end up with an initialization of the JPA Blob field like:

      public final void setDocument(InputStream inputStream, EntityManager entityManager) {
              HibernateEntityManager hibernateEntityManager = entityManager.unwrap(HibernateEntityManager.class);
              Session session = hibernateEntityManager.getSession();
              LobHelper lobHelper = session.getLobHelper();
              this.document = lobHelper.createBlob(inputStream, -1);
      }

      while this works for the MySQL Java Connector, it does not for the MariaDB Java Client.
      The following patch fixes this issue:

      --- ./src/main/java/org/mariadb/jdbc/internal/common/query/parameters/ParameterWriter.java.orig	2015-02-09 17:01:52.494722950 +0100
      +++ ./src/main/java/org/mariadb/jdbc/internal/common/query/parameters/ParameterWriter.java	2015-02-09 17:13:43.683386990 +0100
      @@ -91,7 +91,7 @@
       
               for (;;) {
                   int bytesToRead = (int)Math.min(bytesLeft, buffer.length);
      -            if(bytesToRead == 0)
      +            if(bytesToRead <= 0)
                       break;
                   len = is.read(buffer,0, bytesToRead);
                   if (len <= 0)

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            fcorneli Frank Cornelis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.