commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlel...@apache.org
Subject cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator ValidatorAction.java
Date Tue, 13 Apr 2004 05:49:22 GMT
rleland     2004/04/12 22:49:22

  Modified:    validator/src/share/org/apache/commons/validator Tag:
                        VALIDATOR_1_1_2_BRANCH ValidatorAction.java
  Log:
  PR: 28257 Backported patch David made to use reader instead of InputStream
   to work around bug in JWS 1.4 under JRE prior to 1.3.1_05
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.20.2.1  +16 -19    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.20
  retrieving revision 1.20.2.1
  diff -u -r1.20 -r1.20.2.1
  --- ValidatorAction.java	21 Feb 2004 17:10:29 -0000	1.20
  +++ ValidatorAction.java	13 Apr 2004 05:49:22 -0000	1.20.2.1
  @@ -21,8 +21,10 @@
   
   package org.apache.commons.validator;
   
  +import java.io.BufferedReader;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.InputStreamReader;
   import java.io.Serializable;
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
  @@ -428,32 +430,27 @@
               return null;
           }
   
  -        StringBuffer function = new StringBuffer();
  +        StringBuffer buffer = new StringBuffer();
  +        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
           try {
  -            int bufferSize = is.available();
  -            int bytesRead;
  -            while (bufferSize > 0) {
  -                byte[] buffer = new byte[bufferSize];
  -                bytesRead = is.read(buffer, 0, bufferSize);
  -                if (bytesRead > 0) {
  -                    String functionPart = new String(buffer,0,bytesRead);
  -                    function.append(functionPart);
  -                }
  -                bufferSize = is.available();
  +            String line = null;
  +            while ((line = reader.readLine()) != null) {
  +                buffer.append(line + "\n");
               }
   
           } catch(IOException e) {
  -            log.error("readJavascriptFile()", e);
  +            log.error("Error reading javascript file.", e);
   
           } finally {
               try {
  -                is.close();
  +                reader.close();
               } catch(IOException e) {
  -                log.error("readJavascriptFile()", e);
  +                log.error("Error closing stream to javascript file.", e);
               }
           }
  -        String strFunction = function.toString();
  -        return strFunction.equals("") ? null : strFunction;
  +        
  +        String function = buffer.toString();
  +        return function.equals("") ? null : function;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message