Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 207567 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/jira/ui/html/HTML2TextReader.java (-2 / +4 lines)
Lines 88-94 Link Here
88
88
89
	/**
89
	/**
90
	 * Transforms the HTML text from the reader to formatted text.
90
	 * Transforms the HTML text from the reader to formatted text.
91
	 * 
91
	 *
92
	 * @param reader
92
	 * @param reader
93
	 *            the reader
93
	 *            the reader
94
	 * @param presentation
94
	 * @param presentation
Lines 140-146 Link Here
140
	@Override
140
	@Override
141
	protected String computeSubstitution(int c) throws IOException {
141
	protected String computeSubstitution(int c) throws IOException {
142
142
143
		if (c == '<')
143
		if (c == -1) {
144
			return null;
145
		} else if (c == '<')
144
			return processHTMLTag();
146
			return processHTMLTag();
145
		else if (fIgnore)
147
		else if (fIgnore)
146
			return EMPTY_STRING;
148
			return EMPTY_STRING;
(-)src/org/eclipse/mylyn/jira/tests/HTML2TextReaderTest.java (+43 lines)
Lines 8-14 Link Here
8
package org.eclipse.mylyn.jira.tests;
8
package org.eclipse.mylyn.jira.tests;
9
9
10
import java.io.IOException;
10
import java.io.IOException;
11
import java.io.Reader;
11
import java.io.StringReader;
12
import java.io.StringReader;
13
import java.util.concurrent.Callable;
14
import java.util.concurrent.ExecutionException;
15
import java.util.concurrent.ExecutorService;
16
import java.util.concurrent.Executors;
17
import java.util.concurrent.FutureTask;
18
import java.util.concurrent.TimeUnit;
19
import java.util.concurrent.TimeoutException;
12
20
13
import junit.framework.TestCase;
21
import junit.framework.TestCase;
14
22
Lines 49-52 Link Here
49
		assertEquals(" ", new String(chars, 0, len));
57
		assertEquals(" ", new String(chars, 0, len));
50
	}
58
	}
51
59
60
	public void testHeadCpuLoop() {
61
		assertTrue(testCpuLoop("b <head> a "));
62
	}
63
64
	public void testPreCpuLoop() {
65
		assertTrue(testCpuLoop("b <pre> b "));
66
	}
67
68
	private boolean testCpuLoop(final String text) {
69
		ExecutorService executor = Executors.newFixedThreadPool(1);
70
		FutureTask<Boolean> future = new FutureTask<Boolean>(new Callable<Boolean>() {
71
			public Boolean call() {
72
				Reader stringReader = new StringReader(text);
73
74
				HTML2TextReader html2TextReader = new HTML2TextReader(stringReader, null);
75
				try {
76
					char[] chars = new char[text.length()];
77
					int len = html2TextReader.read(chars, 0, chars.length);
78
					return true;
79
				} catch (Throwable e) {
80
					return false;
81
				}
82
			}
83
		});
84
		try {
85
			executor.execute(future);
86
87
			return future.get(2, TimeUnit.SECONDS);
88
89
		} catch (Throwable e) {
90
			future.cancel(true);
91
		}
92
		return false;
93
	}
94
52
}
95
}

Return to bug 207567