提交 a36a99c3 编写于 作者: L lancea

7038565: address Findbugs issue in BatchUpdateException

Reviewed-by: alanb, forax
上级 a80d33b6
/* /*
* Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2011, 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
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package java.sql; package java.sql;
import java.util.Arrays;
/** /**
* The subclass of {@link SQLException} thrown when an error * The subclass of {@link SQLException} thrown when an error
* occurs during a batch update operation. In addition to the * occurs during a batch update operation. In addition to the
...@@ -77,8 +79,7 @@ public class BatchUpdateException extends SQLException { ...@@ -77,8 +79,7 @@ public class BatchUpdateException extends SQLException {
*/ */
public BatchUpdateException( String reason, String SQLState, int vendorCode, public BatchUpdateException( String reason, String SQLState, int vendorCode,
int[] updateCounts ) { int[] updateCounts ) {
super(reason, SQLState, vendorCode); this(reason, SQLState, vendorCode, updateCounts, null);
this.updateCounts = updateCounts;
} }
/** /**
...@@ -105,8 +106,7 @@ public class BatchUpdateException extends SQLException { ...@@ -105,8 +106,7 @@ public class BatchUpdateException extends SQLException {
*/ */
public BatchUpdateException(String reason, String SQLState, public BatchUpdateException(String reason, String SQLState,
int[] updateCounts) { int[] updateCounts) {
super(reason, SQLState); this(reason, SQLState, 0, updateCounts, null);
this.updateCounts = updateCounts;
} }
/** /**
...@@ -132,8 +132,7 @@ public class BatchUpdateException extends SQLException { ...@@ -132,8 +132,7 @@ public class BatchUpdateException extends SQLException {
* @since 1.2 * @since 1.2
*/ */
public BatchUpdateException(String reason, int[] updateCounts) { public BatchUpdateException(String reason, int[] updateCounts) {
super(reason); this(reason, null, 0, updateCounts, null);
this.updateCounts = updateCounts;
} }
/** /**
...@@ -156,8 +155,7 @@ public class BatchUpdateException extends SQLException { ...@@ -156,8 +155,7 @@ public class BatchUpdateException extends SQLException {
* @since 1.2 * @since 1.2
*/ */
public BatchUpdateException(int[] updateCounts) { public BatchUpdateException(int[] updateCounts) {
super(); this(null, null, 0, updateCounts, null);
this.updateCounts = updateCounts;
} }
/** /**
...@@ -172,8 +170,7 @@ public class BatchUpdateException extends SQLException { ...@@ -172,8 +170,7 @@ public class BatchUpdateException extends SQLException {
* @since 1.2 * @since 1.2
*/ */
public BatchUpdateException() { public BatchUpdateException() {
super(); this(null, null, 0, null, null);
this.updateCounts = null;
} }
/** /**
...@@ -191,8 +188,7 @@ public class BatchUpdateException extends SQLException { ...@@ -191,8 +188,7 @@ public class BatchUpdateException extends SQLException {
* @since 1.6 * @since 1.6
*/ */
public BatchUpdateException(Throwable cause) { public BatchUpdateException(Throwable cause) {
super(cause); this(null, null, 0, null, cause);
this.updateCounts = null;
} }
/** /**
...@@ -218,8 +214,7 @@ public class BatchUpdateException extends SQLException { ...@@ -218,8 +214,7 @@ public class BatchUpdateException extends SQLException {
* @since 1.6 * @since 1.6
*/ */
public BatchUpdateException(int []updateCounts , Throwable cause) { public BatchUpdateException(int []updateCounts , Throwable cause) {
super(cause); this(null, null, 0, updateCounts, cause);
this.updateCounts = updateCounts;
} }
/** /**
...@@ -243,8 +238,7 @@ public class BatchUpdateException extends SQLException { ...@@ -243,8 +238,7 @@ public class BatchUpdateException extends SQLException {
* @since 1.6 * @since 1.6
*/ */
public BatchUpdateException(String reason, int []updateCounts, Throwable cause) { public BatchUpdateException(String reason, int []updateCounts, Throwable cause) {
super(reason,cause); this(reason, null, 0, updateCounts, cause);
this.updateCounts = updateCounts;
} }
/** /**
...@@ -269,8 +263,7 @@ public class BatchUpdateException extends SQLException { ...@@ -269,8 +263,7 @@ public class BatchUpdateException extends SQLException {
*/ */
public BatchUpdateException(String reason, String SQLState, public BatchUpdateException(String reason, String SQLState,
int []updateCounts, Throwable cause) { int []updateCounts, Throwable cause) {
super(reason,SQLState,cause); this(reason, SQLState, 0, updateCounts, cause);
this.updateCounts = updateCounts;
} }
/** /**
...@@ -297,8 +290,8 @@ public class BatchUpdateException extends SQLException { ...@@ -297,8 +290,8 @@ public class BatchUpdateException extends SQLException {
*/ */
public BatchUpdateException(String reason, String SQLState, int vendorCode, public BatchUpdateException(String reason, String SQLState, int vendorCode,
int []updateCounts,Throwable cause) { int []updateCounts,Throwable cause) {
super(reason,SQLState,vendorCode,cause); super(reason, SQLState, vendorCode, cause);
this.updateCounts = updateCounts; this.updateCounts = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
} }
/** /**
...@@ -332,7 +325,7 @@ public class BatchUpdateException extends SQLException { ...@@ -332,7 +325,7 @@ public class BatchUpdateException extends SQLException {
* @since 1.3 * @since 1.3
*/ */
public int[] getUpdateCounts() { public int[] getUpdateCounts() {
return updateCounts; return (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
} }
/** /**
...@@ -340,7 +333,7 @@ public class BatchUpdateException extends SQLException { ...@@ -340,7 +333,7 @@ public class BatchUpdateException extends SQLException {
* @serial * @serial
* @since 1.2 * @since 1.2
*/ */
private int[] updateCounts; private final int[] updateCounts;
private static final long serialVersionUID = 5977529877145521757L; private static final long serialVersionUID = 5977529877145521757L;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册