17
17
import java .io .InputStream ;
18
18
import java .util .Map ;
19
19
20
+ import org .apache .logging .log4j .LogManager ;
21
+ import org .apache .logging .log4j .Logger ;
20
22
import org .eclipse .emf .common .util .EList ;
21
23
import org .eclipse .emf .common .util .URI ;
22
24
import org .eclipse .emf .ecore .EObject ;
31
33
*/
32
34
class DirectLinkingEObjectInputStream extends EObjectInputStream {
33
35
36
+ private static final Logger LOGGER = LogManager .getLogger (DirectLinkingEObjectInputStream .class );
37
+
34
38
DirectLinkingEObjectInputStream (final InputStream inputStream , final Map <?, ?> options ) throws IOException {
35
39
super (inputStream , options );
36
40
}
@@ -52,13 +56,19 @@ public EObject readEObject(final Resource context) throws IOException {
52
56
EObject eObject = context .getContents ().get (readCompressedInt ());
53
57
count --;
54
58
while (count > 0 ) {
55
- EStructuralFeature feature = eObject .eClass ().getEStructuralFeature (readCompressedInt ());
59
+ int next = readCompressedInt ();
60
+ EStructuralFeature feature = eObject .eClass ().getEStructuralFeature (next );
56
61
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
+ }
60
69
} 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
+
62
72
}
63
73
}
64
74
return eObject ;
0 commit comments