Author: markt Date: Sat Nov 24 18:50:30 2012 New Revision: 1413239 URL: http://svn.apache.org/viewvc?rev=1413239&view=rev Log: Additional checks when in non-blocking mode i18n messages
Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties?rev=1413239&r1=1413238&r2=1413239&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties Sat Nov 24 18:50:30 2012 @@ -16,9 +16,10 @@ upgrade.sis.isFinished.ise=It is illegal to call isFinished() when the ServletInputStream is not in non-blocking mode (i.e. setReadListener() must be called first) upgrade.sis.isReady.ise=It is illegal to call isReady() when the ServletInputStream is not in non-blocking mode (i.e. setReadListener() must be called first) upgrade.sis.readListener.null=It is illegal to pass null to setReadListener() -upgrade.sis.read.ise=It is illegal to call any of the read() methods without first checking that there is data available by calling isReady() +upgrade.sis.read.ise=It is illegal to call any of the read() methods in non-blocking mode without first checking that there is data available by calling isReady() upgrade.sos.canWrite.ise=It is illegal to call canWrite() when the ServletOutputStream is not in non-blocking mode (i.e. setWriteListener() must be called first) upgrade.sos.writeListener.null=It is illegal to pass null to setWriteListener() +upgrade.sis.write.ise=It is illegal to call any of the write() methods in non-blocking mode without first checking that there is space available by calling canWrite() apr.error=Unexpected error [{0}] reading data from the APR/native socket. Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java?rev=1413239&r1=1413238&r2=1413239&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java Sat Nov 24 18:50:30 2012 @@ -21,22 +21,33 @@ import java.io.IOException; import javax.servlet.ServletOutputStream; import javax.servlet.WriteListener; +import org.apache.tomcat.util.res.StringManager; + public abstract class UpgradeServletOutputStream extends ServletOutputStream { + protected static final StringManager sm = + StringManager.getManager(Constants.Package); + + // Start in blocking-mode private volatile WriteListener listener = null; private byte[] buffer; @Override public final boolean canWrite() { + if (listener == null) { + throw new IllegalStateException( + sm.getString("upgrade.sos.canWrite.is")); + } + return buffer == null; } @Override public final void setWriteListener(WriteListener listener) { if (listener == null) { - // TODO i18n - throw new IllegalArgumentException(); + throw new IllegalArgumentException( + sm.getString("upgrade.sos.writeListener.null")); } this.listener = listener; } @@ -59,8 +70,8 @@ public abstract class UpgradeServletOutp private void preWriteChecks() { if (buffer != null) { - // TODO i18n - throw new IllegalStateException(); + throw new IllegalStateException( + sm.getString("upgrade.sis.write.ise")); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org