bloritsch 01/11/26 11:45:02 Modified: src/org/apache/cocoon Main.java src/org/apache/cocoon/components/xslt XSLTProcessorImpl.java src/org/apache/cocoon/util StringUtils.java Tokenizer.java Log: Fix index and tokenizer issues with null strings Revision Changes Path 1.29 +5 -1 xml-cocoon2/src/org/apache/cocoon/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- Main.java 2001/10/25 17:58:13 1.28 +++ Main.java 2001/11/26 19:45:01 1.29 @@ -35,7 +35,7 @@ * Command line entry point. * * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> - * @version CVS $Revision: 1.28 $ $Date: 2001/10/25 17:58:13 $ + * @version CVS $Revision: 1.29 $ $Date: 2001/11/26 19:45:01 $ */ public class Main { @@ -566,6 +566,10 @@ } public String translateURI(String uri) throws Exception { + if (null == uri || "".equals(uri)) { + log.warn("translate empty uri"); + return ""; + } HashMap parameters = new HashMap(); parameters.put("user-agent", userAgent); parameters.put("accept", accept); 1.13 +3 -1 xml-cocoon2/src/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java Index: XSLTProcessorImpl.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- XSLTProcessorImpl.java 2001/11/09 06:22:26 1.12 +++ XSLTProcessorImpl.java 2001/11/26 19:45:01 1.13 @@ -108,8 +108,10 @@ public void dispose() { - if (this.manager != null) + if (this.manager != null) { this.manager.release((Component)store); + this.manager.release((Component)entityResolver); + } } public void configure(Configuration conf) 1.4 +6 -11 xml-cocoon2/src/org/apache/cocoon/util/StringUtils.java Index: StringUtils.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/util/StringUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- StringUtils.java 2001/10/02 19:38:57 1.3 +++ StringUtils.java 2001/11/26 19:45:02 1.4 @@ -14,7 +14,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a> * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> - * @version CVS $Revision: 1.3 $ $Date: 2001/10/02 19:38:57 $ + * @version CVS $Revision: 1.4 $ $Date: 2001/11/26 19:45:02 $ */ public class StringUtils { @@ -36,15 +36,7 @@ * @return An array of token */ public static String[] split(String line, String delimiter) { - Tokenizer tokenizer = new Tokenizer(line, delimiter); - int tokenCount = tokenizer.countTokens(); - String[] result = new String[tokenCount]; - - for (int i = 0; i < tokenCount; i++) { - result[i] = tokenizer.nextToken(); - } - - return result; + return Tokenizer.tokenize(line, delimiter, false); } /** @@ -88,9 +80,12 @@ int i; char[] ca = a.toCharArray(); char[] cb = b.toCharArray(); - for (i = 0; (i < ca.length) || (i < cb.length); i++) { + int len = ( ca.length < cb.length ) ? ca.length : cb.length; + + for (i = 0; i < len; i++) { if (ca[i] != cb[i]) break; } + return i; } 1.4 +4 -1 xml-cocoon2/src/org/apache/cocoon/util/Tokenizer.java Index: Tokenizer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/util/Tokenizer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Tokenizer.java 2001/10/11 07:28:25 1.3 +++ Tokenizer.java 2001/11/26 19:45:02 1.4 @@ -232,8 +232,11 @@ Tokenizer tokenizer = new Tokenizer(str, delim, returnTokens); String[] tokens = new String[tokenizer.countTokens()]; - for (int i = 0; i < tokens.length; i++) + int i = 0; + while (tokenizer.hasMoreTokens()) { tokens[i] = tokenizer.nextToken(); + i++; + } return tokens; }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]