[flaptor-util commit] r191 - fixed small bugs: create temp dir hung when the first attempt failed; filterXml returned n...

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 24, 2009, 2:24:07 PM3/24/09
to flaptor-o...@googlegroups.com
Author: jhandl
Date: Tue Mar 24 11:22:52 2009
New Revision: 191

Modified:
trunk/src/com/flaptor/util/DomUtil.java
trunk/src/com/flaptor/util/FileUtil.java
trunk/src/com/flaptor/util/HtmlParser.java

Log:
fixed small bugs: create temp dir hung when the first attempt failed;
filterXml returned null for null data


Modified: trunk/src/com/flaptor/util/DomUtil.java
==============================================================================
--- trunk/src/com/flaptor/util/DomUtil.java (original)
+++ trunk/src/com/flaptor/util/DomUtil.java Tue Mar 24 11:22:52 2009
@@ -125,7 +125,7 @@
*/
public static final String filterXml(final String text) {
if (text == null) {
- return null;
+ return "";
}
StringBuffer buffer = null;
for (int i = 0; i < text.length(); i++) {

Modified: trunk/src/com/flaptor/util/FileUtil.java
==============================================================================
--- trunk/src/com/flaptor/util/FileUtil.java (original)
+++ trunk/src/com/flaptor/util/FileUtil.java Tue Mar 24 11:22:52 2009
@@ -438,7 +438,7 @@
FileInputStream is = null;
try {
is = new FileInputStream(f);
- //XXX TODO: see comment about serializtion in createChecksum
+ //XXX TODO: see comment about serialization in createChecksum
is.read(checksum2);
return java.util.Arrays.equals(checksum1, checksum2);
}
@@ -453,7 +453,7 @@
* @param suffix a string to use at the end of the directory's name.
* @return a newly created (empty) directory on the system's tmp
directory.
*/
- public static File createTempDir (final String prefix, final String
suffix) {
+ public static File createTempDir (final String prefix, final String
suffix) throws IOException {
File retVal = null;
java.util.Random random = new
java.util.Random(System.currentTimeMillis());
int retry = 0;
@@ -461,7 +461,11 @@
retVal = new File(System.getProperty("java.io.tmpdir") +
File.separator + prefix + random.nextInt() + suffix);
if (!retVal.mkdir()) {
retVal = null;
+ retry++;
}
+ }
+ if (null == retVal) {
+ throw new IOException("Can't create a temporary directory
in "+System.getProperty("java.io.tmpdir"));
}
retVal.deleteOnExit();
return retVal;

Modified: trunk/src/com/flaptor/util/HtmlParser.java
==============================================================================
--- trunk/src/com/flaptor/util/HtmlParser.java (original)
+++ trunk/src/com/flaptor/util/HtmlParser.java Tue Mar 24 11:22:52 2009
@@ -113,7 +113,7 @@
for (int i = 0; i < processors; i++) {
DOMParser parser = new org.cyberneko.html.parsers.DOMParser();
try {
-
parser.setFeature("http://cyberneko.org/html/features/scanner/ignore-specified-charset",
true);
+
parser.setFeature("http://cyberneko.org/html/features/scanner/ignore-specified-charset",
false);

parser.setProperty("http://cyberneko.org/html/properties/default-encoding","UTF-8");
} catch (Exception e) {
logger.error("Setting nekohtml parser encoding options",
e);

Reply all
Reply to author
Forward
0 new messages