Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-01-31 23:24:10 -0500
committerspingel2011-01-31 23:24:10 -0500
commit26dc6c6831690e9a37bd6fc46a12c309449214e1 (patch)
treefca4f5590aefbb4ee7c5b0867fdfee64284c07cb
parente56fc8e3539fd4cb48d8b7f259328c7726862d20 (diff)
downloadorg.eclipse.mylyn.tasks-26dc6c6831690e9a37bd6fc46a12c309449214e1.tar.gz
org.eclipse.mylyn.tasks-26dc6c6831690e9a37bd6fc46a12c309449214e1.tar.xz
org.eclipse.mylyn.tasks-26dc6c6831690e9a37bd6fc46a12c309449214e1.zip
REOPENED - bug 268456: reading of task data fails with fatal error
https://bugs.eclipse.org/bugs/show_bug.cgi?id=268456
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java15
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/XmlExternalizationTest.java15
3 files changed, 23 insertions, 9 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java
index dceb6f2d0..02c1d353b 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java
@@ -116,6 +116,8 @@ public class TaskDataExternalizer {
if (pointer < header.length) {
// skip at most the number of bytes remaining in the header
long skip = Math.min(header.length - pointer, n);
+ // never skip more bytes than underlying stream
+ skip = super.skip(skip);
pointer += skip;
return skip;
} else {
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java
index 6e1775883..4b951d6ec 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java
@@ -241,10 +241,19 @@ public class TaskDataStoreTest extends TestCase {
file.deleteOnExit();
storage.putTaskData(file, state);
- try {
+ if (System.getProperty("java.version").compareTo("1.5") <= 0) {
+ // Java 1.5 fails to parse C1 characters with XML 1.1
+ try {
+ TaskDataState state2 = storage.getTaskDataState(file);
+ fail("Expected CoreException, got '" + state2.getRepositoryData().getRoot().toString() + "'");
+ } catch (CoreException expected) {
+ }
+ } else {
+ // Java 1.6 is apparently able to parse C1 characters with XML 1.1
TaskDataState state2 = storage.getTaskDataState(file);
- fail("Expected CoreException, got " + state2);
- } catch (CoreException expected) {
+ assertEquals(state.getRepositoryData().getRoot().toString(), state2.getRepositoryData()
+ .getRoot()
+ .toString());
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/XmlExternalizationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/XmlExternalizationTest.java
index de0cbd45c..35ee29840 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/XmlExternalizationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/XmlExternalizationTest.java
@@ -80,6 +80,7 @@ public class XmlExternalizationTest extends TestCase {
}
public void testWriteandReadBadCharacterXml10() throws Exception {
+ System.err.println("= XML 1.0 =");
for (int i = 0; i < 0xFFFF; i++) {
char badChar = (char) i;
@@ -100,15 +101,15 @@ public class XmlExternalizationTest extends TestCase {
SimpleCharacterReader readHandler = new SimpleCharacterReader();
parser.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException exception) throws SAXException {
- exception.printStackTrace();
+ System.err.println(exception.getMessage());
}
public void fatalError(SAXParseException exception) throws SAXException {
- exception.printStackTrace();
+ System.err.println(exception.getMessage());
}
public void error(SAXParseException exception) throws SAXException {
- exception.printStackTrace();
+ System.err.println(exception.getMessage());
}
});
parser.setContentHandler(readHandler);
@@ -119,6 +120,7 @@ public class XmlExternalizationTest extends TestCase {
}
public void testWriteandReadBadCharacterXml11() throws Exception {
+ System.err.println("= XML 1.1 =");
for (int i = 0; i < 0xFFFF; i++) {
char badChar = (char) i;
@@ -139,19 +141,20 @@ public class XmlExternalizationTest extends TestCase {
SimpleCharacterReader readHandler = new SimpleCharacterReader();
parser.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException exception) throws SAXException {
- exception.printStackTrace();
+ System.err.println(exception.getMessage());
}
public void fatalError(SAXParseException exception) throws SAXException {
- exception.printStackTrace();
+ System.err.println(exception.getMessage());
}
public void error(SAXParseException exception) throws SAXException {
- exception.printStackTrace();
+ System.err.println(exception.getMessage());
}
});
parser.setContentHandler(readHandler);
parser.parse(new InputSource(new ByteArrayInputStream(out.toByteArray())));
+
char character = readHandler.getCharacter();
assertEquals(badChar, character);
}

Back to the top