Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8273683

Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert.

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P5
    • Resolution: Approved
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      This is change clarifies existing behavior for methods that are seldom used, if at all.

      Description

      Summary

      SerialBlob:setBytes and SerialClob:setString javadocs need to be updated to better align with the Blob and Clob interfaces

      Problem

      The methods SerialBlob:setBytes and SerialClob:setString javadocs needed updated to better align with the respective methods on the Blob and Clob interface.

      Solution

      Clarify the javadoc for the methods SerialBlob:setBytes and SerialClob:setString methods

      Specification

      SerialBlob javadoc updates:

      diff --git a/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialBlob.java b/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialBlob.java
      index ff64e6ccc86..00781a43bf2 100644
      --- a/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialBlob.java
      +++ b/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialBlob.java
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -305,13 +305,12 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
            * @param pos the position in the SQL <code>BLOB</code> value at which
            *     to start writing. The first position is <code>1</code>;
            *     must not be less than <code>1</code> nor greater than
      -     *     the length of this <code>SerialBlob</code> object.
      +     *     the length+1 of this {@code SerialBlob} object.
            * @param bytes the array of bytes to be written to the <code>BLOB</code>
            *        value that this <code>Blob</code> object represents
            * @return the number of bytes written
            * @throws SerialException if there is an error accessing the
      -     *     <code>BLOB</code> value; or if an invalid position is set; if an
      -     *     invalid offset value is set;
      +     *     {@code BLOB} value; or if an invalid position is set;
            * if {@code free} had previously been called on this object
            * @throws SQLException if there is an error accessing the <code>BLOB</code>
            *         value from the database
      @@ -327,27 +326,27 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
            * <code>BLOB</code> value that this <code>Blob</code> object represents
            * and returns the number of bytes written.
            * Writing starts at position <code>pos</code> in the <code>BLOB</code>
      -     * value; <i>len</i> bytes from the given byte array are written.
      +     * value; {@code length} bytes from the given byte array are written.
            *
            * @param pos the position in the <code>BLOB</code> object at which
            *     to start writing. The first position is <code>1</code>;
            *     must not be less than <code>1</code> nor greater than
      -     *     the length of this <code>SerialBlob</code> object.
      +     *     the length+1 of this {@code SerialBlob} object.
            * @param bytes the array of bytes to be written to the <code>BLOB</code>
            *     value
      -     * @param offset the offset in the <code>byte</code> array at which
      -     *     to start reading the bytes. The first offset position is
      +     * @param offset the offset into the array {@code bytes} at which
      +     *     to start reading the bytes to be set. The first offset position is
            *     <code>0</code>; must not be less than <code>0</code> nor greater
      -     *     than the length of the <code>byte</code> array
      +     *     than the length of the array {@code bytes}
            * @param length the number of bytes to be written to the
      -     *     <code>BLOB</code> value from the array of bytes <i>bytes</i>.
      +     *     <code>BLOB</code> value from the array of bytes {@code bytes}
            *
            * @return the number of bytes written
            * @throws SerialException if there is an error accessing the
            *     <code>BLOB</code> value; if an invalid position is set; if an
      -     *     invalid offset value is set; if number of bytes to be written
      -     *     is greater than the <code>SerialBlob</code> length; or the combined
      -     *     values of the length and offset is greater than the Blob buffer;
      +     *     invalid offset value is set; or the combined values of the
      +     *     {@code length} and {@code offset} is greater than the length of
      +     *     {@code bytes};
            * if {@code free} had previously been called on this object
            * @throws SQLException if there is an error accessing the <code>BLOB</code>
            *         value from the database.
      @@ -361,26 +360,34 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
                   throw new SerialException("Invalid offset in byte array set");
               }

      SeriaClob javadoc updates:

      diff --git a/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialClob.java b/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialClob.java
      index 48ee5ea878f..814316f2257 100644
      --- a/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialClob.java
      +++ b/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialClob.java
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -368,15 +368,12 @@ public class SerialClob implements Clob, Serializable, Cloneable {
            * @param pos the position at which to start writing to the <code>CLOB</code>
            *         value that this <code>SerialClob</code> object represents; the first
            *         position is <code>1</code>; must not be less than <code>1</code> nor
      -     *         greater than the length of this <code>SerialClob</code> object
      +     *         greater than the length+1 of this {@code SerialClob} object
            * @param str the string to be written to the <code>CLOB</code>
            *        value that this <code>SerialClob</code> object represents
            * @return the number of characters written
            * @throws SerialException if there is an error accessing the
      -     *     <code>CLOB</code> value; if an invalid position is set; if an
      -     *     invalid offset value is set; if number of bytes to be written
      -     *     is greater than the <code>SerialClob</code> length; or the combined
      -     *     values of the length and offset is greater than the Clob buffer;
      +     *     {@code CLOB} value; if an invalid position is set;
            * if the {@code free} method had been previously called on this object
            */
           public int setString(long pos, String str) throws SerialException {
      @@ -391,7 +388,7 @@ public class SerialClob implements Clob, Serializable, Cloneable {
            * @param pos the position at which to start writing to the <code>CLOB</code>
            *         value that this <code>SerialClob</code> object represents; the first
            *         position is <code>1</code>; must not be less than <code>1</code> nor
      -     *         greater than the length of this <code>SerialClob</code> object
      +     *         greater than the length+1 of this {@code SerialClob} object
            * @param str the string to be written to the <code>CLOB</code>
            *        value that this <code>Clob</code> object represents
            * @param offset the offset into <code>str</code> to start reading
      @@ -400,42 +397,50 @@ public class SerialClob implements Clob, Serializable, Cloneable {
            * @return the number of characters written
            * @throws SerialException if there is an error accessing the
            *     <code>CLOB</code> value; if an invalid position is set; if an
      -     *     invalid offset value is set; if number of bytes to be written
      -     *     is greater than the <code>SerialClob</code> length; or the combined
      -     *     values of the length and offset is greater than the Clob buffer;
      +     *     invalid offset value is set; or the combined values of the
      +     *     {@code length} and {@code offset} is greater than the length of
      +     *     {@code str};
            * if the {@code free} method had been previously called on this object
            */
           public int setString(long pos, String str, int offset, int length)
               throws SerialException {

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              lancea Lance Andersen
              Reporter:
              webbuggrp Webbug Group
              Reviewed By:
              Joe Wang, Naoto Sato
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: