Skip to content

Commit b4f66d4

Browse files
authored
Merge pull request #1115 from markdomeng/newlogging
Improve logging in DirectLinkingEObjectInputStream.readEObject
2 parents a844184 + 382f8a2 commit b4f66d4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/persistence/DirectLinkingEObjectInputStream.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import java.io.InputStream;
1818
import java.util.Map;
1919

20+
import org.apache.logging.log4j.LogManager;
21+
import org.apache.logging.log4j.Logger;
2022
import org.eclipse.emf.common.util.EList;
2123
import org.eclipse.emf.common.util.URI;
2224
import org.eclipse.emf.ecore.EObject;
@@ -31,6 +33,8 @@
3133
*/
3234
class DirectLinkingEObjectInputStream extends EObjectInputStream {
3335

36+
private static final Logger LOGGER = LogManager.getLogger(DirectLinkingEObjectInputStream.class);
37+
3438
DirectLinkingEObjectInputStream(final InputStream inputStream, final Map<?, ?> options) throws IOException {
3539
super(inputStream, options);
3640
}
@@ -52,13 +56,19 @@ public EObject readEObject(final Resource context) throws IOException {
5256
EObject eObject = context.getContents().get(readCompressedInt());
5357
count--;
5458
while (count > 0) {
55-
EStructuralFeature feature = eObject.eClass().getEStructuralFeature(readCompressedInt());
59+
int next = readCompressedInt();
60+
EStructuralFeature feature = eObject.eClass().getEStructuralFeature(next);
5661
count--;
57-
if (feature.isMany()) {
58-
eObject = ((EList<EObject>) eObject.eGet(feature, false)).get(readCompressedInt());
59-
count--;
62+
if (feature != null) {
63+
if (feature.isMany()) {
64+
eObject = ((EList<EObject>) eObject.eGet(feature, false)).get(readCompressedInt());
65+
count--;
66+
} else {
67+
eObject = (EObject) eObject.eGet(feature, false);
68+
}
6069
} else {
61-
eObject = (EObject) eObject.eGet(feature, false);
70+
LOGGER.error(String.format("Failed to get EStructuralFeature for Eclass : %s, at readCompressedInt : %d", eObject.eClass(), next));
71+
6272
}
6373
}
6474
return eObject;

0 commit comments

Comments
 (0)