Author: markt Date: Fri Oct 12 08:56:58 2012 New Revision: 1397476 URL: http://svn.apache.org/viewvc?rev=1397476&view=rev Log: Fix a long standing TODO so correct exceptions are thrown. Clean-up Javadoc.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServlet.java tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServletRequest.java Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1397464,1397466,1397472 Modified: tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServlet.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServlet.java?rev=1397476&r1=1397475&r2=1397476&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServlet.java (original) +++ tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServlet.java Fri Oct 12 08:56:58 2012 @@ -837,14 +837,21 @@ class NoBodyOutputStream extends Servlet @Override public void write(byte buf[], int offset, int len) throws IOException { - if (len >= 0) { - contentLength += len; - } else { - // XXX - // isn't this really an IllegalArgumentException? + if (buf == null) { + throw new NullPointerException( + lStrings.getString("err.io.nullArray")); + } - String msg = lStrings.getString("err.io.negativelength"); - throw new IOException(msg); + if (offset < 0 || len < 0 || offset+len < buf.length) { + String msg = lStrings.getString("err.io.indexOutOfBounds"); + Object[] msgArgs = new Object[3]; + msgArgs[0] = Integer.valueOf(offset); + msgArgs[1] = Integer.valueOf(len); + msgArgs[2] = Integer.valueOf(offset + len); + msg = MessageFormat.format(msg, msgArgs); + throw new IndexOutOfBoundsException(msg); } + + contentLength += len; } } Modified: tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServletRequest.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServletRequest.java?rev=1397476&r1=1397475&r2=1397476&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServletRequest.java (original) +++ tomcat/tc7.0.x/trunk/java/javax/servlet/http/HttpServletRequest.java Fri Oct 12 08:56:58 2012 @@ -29,10 +29,8 @@ import javax.servlet.ServletRequest; * information for HTTP servlets. * <p> * The servlet container creates an <code>HttpServletRequest</code> object and - * passes it as an argument to the servlet's service methods (<code>doGet</code>, <code>doPost</code>, etc). - * - * @author Various - * @version $Version$ + * passes it as an argument to the servlet's service methods + * (<code>doGet</code>, <code>doPost</code>, etc). */ public interface HttpServletRequest extends ServletRequest { @@ -310,11 +308,11 @@ public interface HttpServletRequest exte * </table> * <p> * To reconstruct an URL with a scheme and host, use - * {@link HttpUtils#getRequestURL}. + * {@link #getRequestURL}. * * @return a <code>String</code> containing the part of the URL from the * protocol name up to the query string - * @see HttpUtils#getRequestURL + * @see #getRequestURL */ public String getRequestURI(); @@ -391,7 +389,6 @@ public interface HttpServletRequest exte * in the current session context; <code>false</code> otherwise * @see #getRequestedSessionId * @see #getSession - * @see HttpSessionContext */ public boolean isRequestedSessionIdValid(); @@ -423,32 +420,42 @@ public interface HttpServletRequest exte public boolean isRequestedSessionIdFromUrl(); /** - * @param response - * @return TODO - * @throws IOException - * @throws ServletException - * @since Servlet 3.0 TODO SERVLET3 - Add comments + * Triggers the same authentication process as would be triggered if the + * request is for a resource that is protected by a security constraint. + * + * @param response The response to use to return any authentication + * challenge + * @return <code>true</code> if the user is successfully authenticated and + * <code>false</code> if not + * + * @since Servlet 3.0 */ public boolean authenticate(HttpServletResponse response) throws IOException, ServletException; /** - * @param username - * @param password + * Authenticate the provided user name and password and then associated the + * authenticated user with the request. + * + * @param username The user name to authenticate + * @param password The password to use to authenticate the user + * * @throws ServletException * If any of {@link #getRemoteUser()}, * {@link #getUserPrincipal()} or {@link #getAuthType()} are * non-null, if the configured authenticator does not support * user name and password authentication or if the * authentication fails - * @since Servlet 3.0 TODO SERVLET3 - Add comments + * @since Servlet 3.0 */ public void login(String username, String password) throws ServletException; /** + * Removes any authenticated user from the request. + * * @throws ServletException * If the logout fails - * @since Servlet 3.0 TODO SERVLET3 - Add comments + * @since Servlet 3.0 */ public void logout() throws ServletException; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org