From 80a7989e8c4e5a42157d594d1e63d63ce34cb363 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 29 May 2013 12:02:19 +0200 Subject: [PATCH] fixed ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.util.List; in robots.txt servlet --- htroot/robots.java | 61 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/htroot/robots.java b/htroot/robots.java index d18723345..df87cf5e7 100644 --- a/htroot/robots.java +++ b/htroot/robots.java @@ -37,44 +37,43 @@ public class robots { if (rbc.isProfileDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.PROFILE, "1"); if (rbc.isLockedDisallowed() || rbc.isDirsDisallowed()) { - final List[] p = getFiles(env.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT)); + final String htrootPath = env.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT); + final List htrootFiles = new ArrayList(); + final List htrootDirs = new ArrayList(); + final File htroot = new File(htrootPath); + if (htroot.exists()) { + final String[] htroots = htroot.list(); + File file; + for (int i=0, dot; i < htroots.length; i++) { + if (htroots[i].equals("www")) continue; + file = new File(htroot, htroots[i]); + if (file.isDirectory()) { + htrootDirs.add(htroots[i]); + } else if ( + ((dot = htroots[i].lastIndexOf('.')) < 2 || + htroots[i].charAt(dot - 2) == '_' && htroots[i].charAt(dot - 1) == 'p') && + !(htroots[i].endsWith("java") || htroots[i].endsWith("class")) + ) { + htrootFiles.add(htroots[i]); + } + } + } + if (rbc.isLockedDisallowed()) { - prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.LOCKED, p[0].size()); - for (int i=0; i[] getFiles(final String htrootPath) { - final File htroot = new File(htrootPath); - if (!htroot.exists()) return null; - final List htrootFiles = new ArrayList(); - final List htrootDirs = new ArrayList(); - final String[] htroots = htroot.list(); - File file; - for (int i=0, dot; i < htroots.length; i++) { - if (htroots[i].equals("www")) continue; - file = new File(htroot, htroots[i]); - if (file.isDirectory()) { - htrootDirs.add(htroots[i]); - } else if ( - ((dot = htroots[i].lastIndexOf('.')) < 2 || - htroots[i].charAt(dot - 2) == '_' && htroots[i].charAt(dot - 1) == 'p') && - !(htroots[i].endsWith("java") || htroots[i].endsWith("class")) - ) { - htrootFiles.add(htroots[i]); - } - } - return (List[]) new Object[] { htrootFiles, htrootDirs }; - } }