rleland 2003/11/16 19:34:50
Modified: validator/src/share/org/apache/commons/validator
ValidatorAction.java
Log:
Bug 23972
Non printing characters were coming from buffer not
being read completely.
I thought I checked this change in back in October,
but it isn't in CVS.
Revision Changes Path
1.16 +13 -10
jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorAction.java
Index: ValidatorAction.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorAction.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ValidatorAction.java 21 Aug 2003 21:43:05 -0000 1.15
+++ ValidatorAction.java 17 Nov 2003 03:34:50 -0000 1.16
@@ -440,18 +440,21 @@
}
if (is == null) {
+ log.debug(" Unable to read javascript name "+javascriptFileName);
return null;
}
StringBuffer function = new StringBuffer();
try {
int bufferSize = is.available();
-
+ int bytesRead;
while (bufferSize > 0) {
byte[] buffer = new byte[bufferSize];
- is.read(buffer, 0, bufferSize);
- String functionPart = new String(buffer);
- function.append(functionPart);
+ bytesRead = is.read(buffer, 0, bufferSize);
+ if (bytesRead > 0) {
+ String functionPart = new String(buffer,0,bytesRead);
+ function.append(functionPart);
+ }
bufferSize = is.available();
}
@@ -465,8 +468,8 @@
log.error("readJavascriptFile()", e);
}
}
-
- return function.toString().equals("") ? null : function.toString();
+ String strFunction = function.toString();
+ return strFunction.equals("") ? null : strFunction;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]