提交 027937e1 编写于 作者: L lancea

7133815: address the findbug errors in CachedRowSetImpl, SerialStruct,...

7133815: address the findbug errors in CachedRowSetImpl,  SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
Reviewed-by: forax
上级 2bb4c57b
......@@ -6431,7 +6431,8 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
* @see #setKeyColumns
*/
public int[] getKeyColumns() throws SQLException {
return keyCols;
int[]keyColumns = this.keyCols;
return (keyColumns == null) ? null : Arrays.copyOf(keyColumns, keyColumns.length);
}
......
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -27,6 +27,7 @@ package com.sun.rowset.internal;
import java.sql.*;
import java.io.*;
import java.util.Arrays;
/**
* The abstract base class from which the classes <code>Row</code>
......@@ -65,7 +66,8 @@ public abstract class BaseRow implements Serializable, Cloneable {
* original values
*/
public Object[] getOrigRow() {
return origVals;
Object[] origRow = this.origVals;
return (origRow == null) ? null: Arrays.copyOf(origRow, origRow.length);
}
/**
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -25,6 +25,7 @@
package javax.sql.rowset.serial;
import java.sql.*;
import java.util.Arrays;
import java.util.Map;
/**
......@@ -119,7 +120,7 @@ public class SQLInputImpl implements SQLInput {
"object with null parameters");
}
// assign our local reference to the attribute stream
attrib = attributes;
attrib = Arrays.copyOf(attributes, attributes.length);
// init the index point before the head of the stream
idx = -1;
// set the map
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -25,11 +25,10 @@
package javax.sql.rowset.serial;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.*;
import javax.sql.*;
import java.io.*;
import java.lang.String;
import java.math.*;
import java.util.Map;
import java.util.Vector;
......@@ -444,16 +443,15 @@ public class SQLOutputImpl implements SQLOutput {
* will need to track if a field is SQL null for itself
*/
if (x == null) {
attribs.add(x);
return;
attribs.add(null);
} else {
/*
* We have to write out a SerialStruct that contains
* the name of this class otherwise we don't know
* what to re-instantiate during readSQL()
*/
attribs.add(new SerialStruct(x, map));
}
/*
* We have to write out a SerialStruct that contains
* the name of this class otherwise we don't know
* what to re-instantiate during readSQL()
*/
attribs.add(new SerialStruct(x, map));
}
/**
......@@ -470,10 +468,10 @@ public class SQLOutputImpl implements SQLOutput {
@SuppressWarnings("unchecked")
public void writeRef(Ref x) throws SQLException {
if (x == null) {
attribs.add(x);
return;
attribs.add(null);
} else {
attribs.add(new SerialRef(x));
}
attribs.add(new SerialRef(x));
}
/**
......@@ -490,10 +488,10 @@ public class SQLOutputImpl implements SQLOutput {
@SuppressWarnings("unchecked")
public void writeBlob(Blob x) throws SQLException {
if (x == null) {
attribs.add(x);
return;
attribs.add(null);
} else {
attribs.add(new SerialBlob(x));
}
attribs.add(new SerialBlob(x));
}
/**
......@@ -510,10 +508,10 @@ public class SQLOutputImpl implements SQLOutput {
@SuppressWarnings("unchecked")
public void writeClob(Clob x) throws SQLException {
if (x == null) {
attribs.add(x);
return;
attribs.add(null);
} else {
attribs.add(new SerialClob(x));
}
attribs.add(new SerialClob(x));
}
/**
......@@ -554,10 +552,10 @@ public class SQLOutputImpl implements SQLOutput {
@SuppressWarnings("unchecked")
public void writeArray(Array x) throws SQLException {
if (x == null) {
attribs.add(x);
return;
attribs.add(null);
} else {
attribs.add(new SerialArray(x, map));
}
attribs.add(new SerialArray(x, map));
}
/**
......@@ -574,11 +572,10 @@ public class SQLOutputImpl implements SQLOutput {
@SuppressWarnings("unchecked")
public void writeURL(java.net.URL url) throws SQLException {
if (url == null) {
attribs.add(url);
return;
attribs.add(null);
} else {
attribs.add(new SerialDatalink(url));
}
attribs.add(new SerialDatalink(url));
}
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -29,6 +29,7 @@ import java.sql.*;
import javax.sql.*;
import java.io.*;
import java.math.*;
import java.util.Arrays;
import java.util.Map;
import java.util.Vector;
......@@ -174,7 +175,8 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
* @throws SerialException if an error occurs
*/
public Object[] getAttributes() throws SerialException {
return attribs;
Object[] val = this.attribs;
return (val == null) ? null : Arrays.copyOf(val, val.length);
}
/**
......@@ -197,7 +199,8 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
public Object[] getAttributes(Map<String,Class<?>> map)
throws SerialException
{
return attribs;
Object[] val = this.attribs;
return (val == null) ? null : Arrays.copyOf(val, val.length);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册