提交 7d1dcd7c 编写于 作者: K kshefov

8059411: RowSetWarning does not correctly chain warnings

Reviewed-by: darcy, smarks, mchung, lancea
Contributed-by: maxim.soloviev@oracle.com
上级 58b292ae
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2014, 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
...@@ -50,14 +50,11 @@ import java.sql.SQLException; ...@@ -50,14 +50,11 @@ import java.sql.SQLException;
* The inherited methods <code>getMessage</code>, <code>getSQLState</code>, * The inherited methods <code>getMessage</code>, <code>getSQLState</code>,
* and <code>getErrorCode</code> retrieve information contained in a * and <code>getErrorCode</code> retrieve information contained in a
* <code>RowSetWarning</code> object. * <code>RowSetWarning</code> object.
*
* @since 1.5
*/ */
public class RowSetWarning extends SQLException { public class RowSetWarning extends SQLException {
/**
* RowSetWarning object handle.
*/
private RowSetWarning rwarning;
/** /**
* Constructs a <code>RowSetWarning</code> object * Constructs a <code>RowSetWarning</code> object
* with the given value for the reason; SQLState defaults to null, * with the given value for the reason; SQLState defaults to null,
...@@ -109,7 +106,7 @@ public class RowSetWarning extends SQLException { ...@@ -109,7 +106,7 @@ public class RowSetWarning extends SQLException {
* @param reason a <code>String</code> giving a description of the * @param reason a <code>String</code> giving a description of the
* warning; * warning;
* @param SQLState an XOPEN code identifying the warning; if a non standard * @param SQLState an XOPEN code identifying the warning; if a non standard
* XPOEN <i>SQLState</i> is supplied, no exception is thrown. * XOPEN <i>SQLState</i> is supplied, no exception is thrown.
* @param vendorCode a database vendor-specific warning code * @param vendorCode a database vendor-specific warning code
*/ */
public RowSetWarning(java.lang.String reason, java.lang.String SQLState, int vendorCode) { public RowSetWarning(java.lang.String reason, java.lang.String SQLState, int vendorCode) {
...@@ -126,7 +123,15 @@ public class RowSetWarning extends SQLException { ...@@ -126,7 +123,15 @@ public class RowSetWarning extends SQLException {
* @see #setNextWarning * @see #setNextWarning
*/ */
public RowSetWarning getNextWarning() { public RowSetWarning getNextWarning() {
return rwarning; SQLException warning = getNextException();
if ( warning == null || warning instanceof RowSetWarning) {
return (RowSetWarning)warning;
} else {
// The chained value isn't a RowSetWarning.
// This is a programming error by whoever added it to
// the RowSetWarning chain. We throw a Java "Error".
throw new Error("RowSetWarning chain holds value that is not a RowSetWarning: ");
}
} }
/** /**
...@@ -139,7 +144,7 @@ public class RowSetWarning extends SQLException { ...@@ -139,7 +144,7 @@ public class RowSetWarning extends SQLException {
* @see #getNextWarning * @see #getNextWarning
*/ */
public void setNextWarning(RowSetWarning warning) { public void setNextWarning(RowSetWarning warning) {
rwarning = warning; setNextException(warning);
} }
static final long serialVersionUID = 6678332766434564774L; static final long serialVersionUID = 6678332766434564774L;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册