Skip to content

Improve loggin in DirectLinkingEObjectInputStream.readEObject #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 16, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.io.InputStream;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
Expand All @@ -31,6 +33,8 @@
*/
class DirectLinkingEObjectInputStream extends EObjectInputStream {

private static final Logger LOGGER = LogManager.getLogger(DirectLinkingEObjectInputStream.class);

DirectLinkingEObjectInputStream(final InputStream inputStream, final Map<?, ?> options) throws IOException {
super(inputStream, options);
}
Expand All @@ -52,13 +56,19 @@ public EObject readEObject(final Resource context) throws IOException {
EObject eObject = context.getContents().get(readCompressedInt());
count--;
while (count > 0) {
EStructuralFeature feature = eObject.eClass().getEStructuralFeature(readCompressedInt());
int next = readCompressedInt();
EStructuralFeature feature = eObject.eClass().getEStructuralFeature(next);
count--;
if (feature.isMany()) {
eObject = ((EList<EObject>) eObject.eGet(feature, false)).get(readCompressedInt());
count--;
if (feature != null) {
if (feature.isMany()) {
eObject = ((EList<EObject>) eObject.eGet(feature, false)).get(readCompressedInt());
count--;
} else {
eObject = (EObject) eObject.eGet(feature, false);
}
} else {
eObject = (EObject) eObject.eGet(feature, false);
LOGGER.error(String.format("Failed to get EStructuralFeature for Eclass : %s, at readCompressedInt : %d", eObject.eClass(), next));

}
}
return eObject;
Expand Down