[pal-cvs 2051] CVS-Update: libraries/portletoutputoptimizer/src/main/java/jp/sf/pal/pooptimizer committed by shinsuke

アーカイブの一覧に戻る

Shinsuke SUGAYA shins****@users*****
2007年 1月 28日 (日) 00:22:00 JST


Update of /cvsroot/pal/libraries/portletoutputoptimizer/src/main/java/jp/sf/pal/pooptimizer
In directory sf-cvs:/tmp/cvs-serv22449/src/main/java/jp/sf/pal/pooptimizer

Modified Files:
	OptimizerFilter.java 
Log Message:
fixed out of array exception

libraries/portletoutputoptimizer/src/main/java/jp/sf/pal/pooptimizer/OptimizerFilter.java 1.1 -> 1.2 (modified)
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/pal/libraries/portletoutputoptimizer/src/main/java/jp/sf/pal/pooptimizer/OptimizerFilter.java.diff?r1=1.1&r2=1.2

===================================================================
RCS file: libraries/portletoutputoptimizer/src/main/java/jp/sf/pal/pooptimizer/OptimizerFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- OptimizerFilter.java	2006/11/28 21:55:05	1.1
+++ OptimizerFilter.java	2007/01/27 15:22:00	1.2
@@ -118,45 +118,49 @@
             byte[] bytes = new byte[BLOCK_SIZE];
             try {
                 int length = reader.read(bytes);
-                String str = new String(bytes, 0, length,
-                        bufferedResponseStream.getEncoding());
-                int beginBodyIndex = str.indexOf("<body");
-                if (beginBodyIndex >= 0) {
-                    str = str.substring(beginBodyIndex).replaceFirst(
-                            "<body[^>]*>", "");
-                    int endBodyIndex = str.indexOf("</body");
-                    if (endBodyIndex >= 0) {
-                        writer.write(str.substring(0, endBodyIndex));
+                if (length != -1) {
+                    String str = new String(bytes, 0, length,
+                            bufferedResponseStream.getEncoding());
+                    int beginBodyIndex = str.indexOf("<body");
+                    if (beginBodyIndex >= 0) {
+                        str = str.substring(beginBodyIndex).replaceFirst(
+                                "<body[^>]*>", "");
+                        int endBodyIndex = str.indexOf("</body");
+                        if (endBodyIndex >= 0) {
+                            writer.write(str.substring(0, endBodyIndex));
+                        } else {
+                            length = reader.read(bytes);
+                            while (length != -1) {
+                                str = new String(bytes, 0, length,
+                                        bufferedResponseStream.getEncoding());
+                                endBodyIndex = str.indexOf("</body");
+                                if (endBodyIndex >= 0) {
+                                    writer
+                                            .write(str.substring(0,
+                                                    endBodyIndex));
+                                    break;
+                                } else {
+                                    if (length != 0) {
+                                        writer.write(str);
+                                    }
+                                    length = reader.read(bytes);
+                                }
+                            }
+                        }
                     } else {
+                        if (length != -1) {
+                            writer.write(str);
+                        }
                         length = reader.read(bytes);
                         while (length != -1) {
                             str = new String(bytes, 0, length,
                                     bufferedResponseStream.getEncoding());
-                            endBodyIndex = str.indexOf("</body");
-                            if (endBodyIndex >= 0) {
-                                writer.write(str.substring(0, endBodyIndex));
-                                break;
-                            } else {
-                                if (length != 0) {
-                                    writer.write(str);
-                                }
-                                length = reader.read(bytes);
+                            if (length != 0) {
+                                writer.write(str);
                             }
+                            length = reader.read(bytes);
                         }
                     }
-                } else {
-                    if (length != -1) {
-                        writer.write(str);
-                    }
-                    length = reader.read(bytes);
-                    while (length != -1) {
-                        str = new String(bytes, 0, length,
-                                bufferedResponseStream.getEncoding());
-                        if (length != 0) {
-                            writer.write(str);
-                        }
-                        length = reader.read(bytes);
-                    }
                 }
                 writer.flush();
             } finally {



pal-cvs メーリングリストの案内
アーカイブの一覧に戻る