finishing up my commits (7855-7858) which could be helpful for

not declaring inside loops (helps GC of some VMs)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7859 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
sixcooler 14 years ago
parent 9170a434ed
commit a311596881

@ -1390,14 +1390,16 @@ public final class HTTPDFileHandler {
final Pattern p = Pattern.compile("(href=\"|src=\")([^\"]+)|(href='|src=')([^']+)|(url\\(')([^']+)|(url\\(\")([^\"]+)|(url\\()([^\\)]+)"); final Pattern p = Pattern.compile("(href=\"|src=\")([^\"]+)|(href='|src=')([^']+)|(url\\(')([^']+)|(url\\(\")([^\"]+)|(url\\()([^\\)]+)");
final Matcher m = p.matcher(sbuffer); final Matcher m = p.matcher(sbuffer);
final StringBuffer result = new StringBuffer(80); final StringBuffer result = new StringBuffer(80);
String init, url;
MultiProtocolURI target;
while (m.find()) { while (m.find()) {
String init = null; init = null;
if(m.group(1) != null) init = m.group(1); if(m.group(1) != null) init = m.group(1);
if(m.group(3) != null) init = m.group(3); if(m.group(3) != null) init = m.group(3);
if(m.group(5) != null) init = m.group(5); if(m.group(5) != null) init = m.group(5);
if(m.group(7) != null) init = m.group(7); if(m.group(7) != null) init = m.group(7);
if(m.group(9) != null) init = m.group(9); if(m.group(9) != null) init = m.group(9);
String url = null; url = null;
if(m.group(2) != null) url = m.group(2); if(m.group(2) != null) url = m.group(2);
if(m.group(4) != null) url = m.group(4); if(m.group(4) != null) url = m.group(4);
if(m.group(6) != null) url = m.group(6); if(m.group(6) != null) url = m.group(6);
@ -1423,7 +1425,7 @@ public final class HTTPDFileHandler {
} else { } else {
// relative path of form href="relative/path" // relative path of form href="relative/path"
try { try {
MultiProtocolURI target = new MultiProtocolURI(proxyurl.getHost() + directory + "/" + url); target = new MultiProtocolURI(proxyurl.getHost() + directory + "/" + url);
m.appendReplacement(result, init + "/proxy.html?url=" + target.toString()); m.appendReplacement(result, init + "/proxy.html?url=" + target.toString());
} }
catch (MalformedURLException e) {} catch (MalformedURLException e) {}

@ -832,6 +832,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// format information for further usage // format information for further usage
final Map<String, byte[]> files = new HashMap<String, byte[]>(); final Map<String, byte[]> files = new HashMap<String, byte[]>();
byte[] fileContent;
for (final FileItem item : items) { for (final FileItem item : items) {
if (item.isFormField()) { if (item.isFormField()) {
// simple text // simple text
@ -845,7 +846,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
} else { } else {
// file // file
args.put(item.getFieldName(), item.getName()); args.put(item.getFieldName(), item.getName());
final byte[] fileContent = FileUtils.read(item.getInputStream()); fileContent = FileUtils.read(item.getInputStream());
item.getInputStream().close(); item.getInputStream().close();
files.put(item.getFieldName(), fileContent); files.put(item.getFieldName(), fileContent);
} }
@ -1261,10 +1262,11 @@ public final class HTTPDemon implements serverHandler, Cloneable {
//read custom headers //read custom headers
final Iterator<ResponseHeader.Entry> it = responseHeader.getAdditionalHeaderProperties().iterator(); final Iterator<ResponseHeader.Entry> it = responseHeader.getAdditionalHeaderProperties().iterator();
ResponseHeader.Entry e;
while(it.hasNext()) { while(it.hasNext()) {
//Append user properties to the main String //Append user properties to the main String
//TODO: Should we check for user properites. What if they intersect properties that are already in header? //TODO: Should we check for user properites. What if they intersect properties that are already in header?
final ResponseHeader.Entry e = it.next(); e = it.next();
header.append(e.getKey()).append(": ").append(e.getValue()).append("\r\n"); header.append(e.getKey()).append(": ").append(e.getValue()).append("\r\n");
} }

@ -686,8 +686,11 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
// start dialog // start dialog
byte[] requestBytes = null; byte[] requestBytes = null;
boolean terminate = false; boolean terminate = false;
String reqCmd; String reqCmd, tmp;
String reqProtocol = "HTTP"; String reqProtocol = "HTTP";
Object result;
Object[] parameter;
Method commandMethod;
final long situationDependentKeepAliveTimeout = keepAliveTimeout; final long situationDependentKeepAliveTimeout = keepAliveTimeout;
while (this.in != null && while (this.in != null &&
this.controlSocket != null && this.controlSocket != null &&
@ -706,7 +709,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
// of the commandObject // of the commandObject
if (this.request.trim().length() == 0) this.request = "EMPTY"; if (this.request.trim().length() == 0) this.request = "EMPTY";
final Object[] parameter = new Object[2]; parameter = new Object[2];
// get the rest of the request parameters // get the rest of the request parameters
final int pos = this.request.indexOf(' '); final int pos = this.request.indexOf(' ');
@ -738,7 +741,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
this.controlSocket.setSoTimeout(this.socketTimeout); this.controlSocket.setSoTimeout(this.socketTimeout);
// exec command and return value // exec command and return value
Method commandMethod = commandObjMethodCache.get(reqProtocol + "_" + reqCmd); commandMethod = commandObjMethodCache.get(reqProtocol + "_" + reqCmd);
if (commandMethod == null) { if (commandMethod == null) {
try { try {
commandMethod = this.commandObj.getClass().getMethod(reqCmd, sessionCallType); commandMethod = this.commandObj.getClass().getMethod(reqCmd, sessionCallType);
@ -749,7 +752,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
} }
} }
Object result = null; result = null;
try { try {
result = commandMethod.invoke(this.commandObj, parameter); result = commandMethod.invoke(this.commandObj, parameter);
} catch (final OutOfMemoryError e) { } catch (final OutOfMemoryError e) {
@ -786,7 +789,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
} }
writeLine((String) result); writeLine((String) result);
} else if (result instanceof InputStream) { } else if (result instanceof InputStream) {
String tmp = send(this.out, (InputStream) result); tmp = send(this.out, (InputStream) result);
if ((tmp.length() > 4) && (tmp.toUpperCase().startsWith("PASS"))) { if ((tmp.length() > 4) && (tmp.toUpperCase().startsWith("PASS"))) {
log(true, "PASS ********"); log(true, "PASS ********");
} else { } else {

@ -46,10 +46,10 @@ public class SnippetExtractor {
TreeSet<Integer> positions; TreeSet<Integer> positions;
int linenumber = 0; int linenumber = 0;
int fullmatchcounter = 0; int fullmatchcounter = 0;
lookup: for (StringBuilder sentence: sentences) { lookup: for (final StringBuilder sentence: sentences) {
hs = WordTokenizer.hashSentence(sentence.toString(), null); hs = WordTokenizer.hashSentence(sentence.toString(), null);
positions = new TreeSet<Integer>(); positions = new TreeSet<Integer>();
for (byte[] word: queryhashes) { for (final byte[] word: queryhashes) {
pos = hs.get(word); pos = hs.get(word);
if (pos != null) { if (pos != null) {
positions.add(pos); positions.add(pos);

Loading…
Cancel
Save