From: Dave B. <bla...@us...> - 2012-03-13 14:41:16
|
Update of /cvsroot/sblim/jsr48-client/src/javax/wbem In directory vz-cvs-3.sog:/tmp/cvs-serv17641/src/javax/wbem Modified Files: WBEMException.java Log Message: 3490032 - TCK: WBEMException must validate error ID Index: WBEMException.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/javax/wbem/WBEMException.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- WBEMException.java 11 Mar 2010 15:08:41 -0000 1.12 +++ WBEMException.java 13 Mar 2012 14:41:14 -0000 1.13 @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2006, 2010 + * (C) Copyright IBM Corp. 2006, 2012 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE @@ -21,6 +21,7 @@ * 2958941 2010-02-25 blaschke-oss Sync up javax.wbem.* javadoc with JSR48 1.0.0 * 2958990 2010-02-25 blaschke-oss Remove WBEMException.CIM_ERR_TYPE_MISMATCH * 2959039 2010-02-25 blaschke-oss Fix WBEMException.toString() logic + * 3490032 2012-02-21 blaschke-oss TCK: WBEMException must validate error ID */ package javax.wbem; @@ -211,12 +212,12 @@ /* 10 */"CIM_ERR_INVALID_SUPERCLASS", /* 11 */"CIM_ERR_ALREADY_EXISTS", /* 12 */"CIM_ERR_NO_SUCH_PROPERTY", - /* 13 */"13", + /* 13 */null, /* 14 */"CIM_ERR_QUERY_LANGUAGE_NOT_SUPPORTED", /* 15 */"CIM_ERR_INVALID_QUERY", /* 16 */"CIM_ERR_METHOD_NOT_AVAILABLE", /* 17 */"CIM_ERR_METHOD_NOT_FOUND", - /* 18 */"18", + /* 18 */null, /* 19 */"CIM_ERR_INVALID_RESPONSE_DESTINATION", /* 20 */"CIM_ERR_NAMESPACE_NOT_EMPTY", /* 21 */"CIM_ERR_INVALID_ENUMERATION_CONTEXT", @@ -285,6 +286,7 @@ */ public WBEMException(int pID, String pMessage, CIMInstance[] pErrors, Throwable pCause) { super(pMessage, pCause); + if (!isValidID(pID)) throw new IllegalArgumentException("Invalid error ID!"); this.iErrorID = pID; this.iCimErrors = pErrors; } @@ -346,7 +348,19 @@ * @return A <code>String</code> representation of the exception ID. */ private String getCIMMessage() { - return (this.iErrorID >= 0 && this.iErrorID < MESSAGES.length) ? MESSAGES[this.iErrorID] - : String.valueOf(this.iErrorID); + return isValidID(this.iErrorID) ? MESSAGES[this.iErrorID] : String.valueOf(this.iErrorID); + } + + /** + * Returns validity of error ID. + * + * @param pID + * The error ID. + * + * @return <code>true</code> if error ID is valid, <code>false</code> + * otherwise. + */ + private boolean isValidID(int pID) { + return pID >= 0 && pID < MESSAGES.length && MESSAGES[pID] != null; } } |