提交 8b13914c 编写于 作者: I igerasim

8074657: Missing space on a boundary of concatenated strings

Summary: Added missing spaces, fixed indentation, replaced StringBuffer with StringBuilder
Reviewed-by: martin, rriggs
上级 370fb4a4
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -66,7 +66,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -66,7 +66,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* value of this <code>SerialBlob</code> object. * value of this <code>SerialBlob</code> object.
* @serial * @serial
*/ */
private byte buf[]; private byte[] buf;
/** /**
* The internal representation of the <code>Blob</code> object on which this * The internal representation of the <code>Blob</code> object on which this
...@@ -102,12 +102,13 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -102,12 +102,13 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @throws SerialException if an error occurs during serialization * @throws SerialException if an error occurs during serialization
* @throws SQLException if a SQL errors occurs * @throws SQLException if a SQL errors occurs
*/ */
public SerialBlob(byte[] b) throws SerialException, SQLException { public SerialBlob(byte[] b)
throws SerialException, SQLException {
len = b.length; len = b.length;
buf = new byte[(int)len]; buf = new byte[(int)len];
for(int i = 0; i < len; i++) { for(int i = 0; i < len; i++) {
buf[i] = b[i]; buf[i] = b[i];
} }
origLen = len; origLen = len;
} }
...@@ -132,19 +133,17 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -132,19 +133,17 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* to this constructor is a <code>null</code>. * to this constructor is a <code>null</code>.
* @see java.sql.Blob * @see java.sql.Blob
*/ */
public SerialBlob (Blob blob) throws SerialException, SQLException { public SerialBlob (Blob blob)
throws SerialException, SQLException {
if (blob == null) { if (blob == null) {
throw new SQLException("Cannot instantiate a SerialBlob " + throw new SQLException(
"object with a null Blob object"); "Cannot instantiate a SerialBlob object with a null Blob object");
} }
len = blob.length(); len = blob.length();
buf = blob.getBytes(1, (int)len ); buf = blob.getBytes(1, (int)len );
this.blob = blob; this.blob = blob;
//if ( len < 10240000)
// len = 10240000;
origLen = len; origLen = len;
} }
...@@ -245,7 +244,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -245,7 +244,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* value from the database * value from the database
*/ */
public long position(byte[] pattern, long start) public long position(byte[] pattern, long start)
throws SerialException, SQLException { throws SerialException, SQLException {
isValid(); isValid();
if (start < 1 || start > len) { if (start < 1 || start > len) {
return -1; return -1;
...@@ -290,7 +290,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -290,7 +290,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* value from the database * value from the database
*/ */
public long position(Blob pattern, long start) public long position(Blob pattern, long start)
throws SerialException, SQLException { throws SerialException, SQLException {
isValid(); isValid();
return position(pattern.getBytes(1, (int)(pattern.length())), start); return position(pattern.getBytes(1, (int)(pattern.length())), start);
} }
...@@ -316,8 +316,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -316,8 +316,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @see #getBytes * @see #getBytes
*/ */
public int setBytes(long pos, byte[] bytes) public int setBytes(long pos, byte[] bytes)
throws SerialException, SQLException { throws SerialException, SQLException {
return (setBytes(pos, bytes, 0, bytes.length)); return setBytes(pos, bytes, 0, bytes.length);
} }
/** /**
...@@ -352,7 +352,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -352,7 +352,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @see #getBytes * @see #getBytes
*/ */
public int setBytes(long pos, byte[] bytes, int offset, int length) public int setBytes(long pos, byte[] bytes, int offset, int length)
throws SerialException, SQLException { throws SerialException, SQLException {
isValid(); isValid();
if (offset < 0 || offset > bytes.length) { if (offset < 0 || offset > bytes.length) {
...@@ -369,7 +369,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -369,7 +369,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
if ((length + offset) > bytes.length) { if ((length + offset) > bytes.length) {
throw new SerialException("Invalid OffSet. Cannot have combined offset " + throw new SerialException("Invalid OffSet. Cannot have combined offset " +
"and length that is greater that the Blob buffer"); "and length that is greater that the Blob buffer");
} }
int i = 0; int i = 0;
...@@ -402,7 +402,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -402,7 +402,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @see #getBinaryStream * @see #getBinaryStream
*/ */
public java.io.OutputStream setBinaryStream(long pos) public java.io.OutputStream setBinaryStream(long pos)
throws SerialException, SQLException { throws SerialException, SQLException {
isValid(); isValid();
if (this.blob != null) { if (this.blob != null) {
return this.blob.setBinaryStream(pos); return this.blob.setBinaryStream(pos);
...@@ -425,17 +426,16 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -425,17 +426,16 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* if {@code free} had previously been called on this object * if {@code free} had previously been called on this object
*/ */
public void truncate(long length) throws SerialException { public void truncate(long length) throws SerialException {
isValid(); isValid();
if (length > len) { if (length > len) {
throw new SerialException throw new SerialException(
("Length more than what can be truncated"); "Length more than what can be truncated");
} else if((int)length == 0) { } else if((int)length == 0) {
buf = new byte[0]; buf = new byte[0];
len = length; len = length;
} else { } else {
len = length; len = length;
buf = this.getBytes(1, (int)len); buf = this.getBytes(1, (int)len);
} }
} }
...@@ -466,8 +466,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -466,8 +466,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
throw new SerialException("Invalid position in BLOB object set"); throw new SerialException("Invalid position in BLOB object set");
} }
if (length < 1 || length > len - pos + 1) { if (length < 1 || length > len - pos + 1) {
throw new SerialException("length is < 1 or pos + length >" throw new SerialException(
+ "total number of bytes"); "length is < 1 or pos + length > total number of bytes");
} }
return new ByteArrayInputStream(buf, (int) pos - 1, (int) length); return new ByteArrayInputStream(buf, (int) pos - 1, (int) length);
} }
...@@ -536,14 +536,13 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -536,14 +536,13 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
public Object clone() { public Object clone() {
try { try {
SerialBlob sb = (SerialBlob) super.clone(); SerialBlob sb = (SerialBlob) super.clone();
sb.buf = (buf != null) ? Arrays.copyOf(buf, (int)len) : null; sb.buf = (buf != null) ? Arrays.copyOf(buf, (int)len) : null;
sb.blob = null; sb.blob = null;
return sb; return sb;
} catch (CloneNotSupportedException ex) { } catch (CloneNotSupportedException ex) {
// this shouldn't happen, since we are Cloneable // this shouldn't happen, since we are Cloneable
throw new InternalError(); throw new InternalError();
} }
} }
/** /**
...@@ -554,15 +553,15 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -554,15 +553,15 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
throws IOException, ClassNotFoundException { throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields(); ObjectInputStream.GetField fields = s.readFields();
byte[] tmp = (byte[])fields.get("buf", null); byte[] tmp = (byte[])fields.get("buf", null);
if (tmp == null) if (tmp == null)
throw new InvalidObjectException("buf is null and should not be!"); throw new InvalidObjectException("buf is null and should not be!");
buf = tmp.clone(); buf = tmp.clone();
len = fields.get("len", 0L); len = fields.get("len", 0L);
if (buf.length != len) if (buf.length != len)
throw new InvalidObjectException("buf is not the expected size"); throw new InvalidObjectException("buf is not the expected size");
origLen = fields.get("origLen", 0L); origLen = fields.get("origLen", 0L);
blob = (Blob) fields.get("blob", null); blob = (Blob) fields.get("blob", null);
} }
/** /**
...@@ -590,8 +589,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -590,8 +589,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
*/ */
private void isValid() throws SerialException { private void isValid() throws SerialException {
if (buf == null) { if (buf == null) {
throw new SerialException("Error: You cannot call a method on a " throw new SerialException("Error: You cannot call a method on a " +
+ "SerialBlob instance once free() has been called."); "SerialBlob instance once free() has been called.");
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册