Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316221 - XMLSaveImpl.getDatatypeValue() throws NPE with Custom DataTypes
Summary: XMLSaveImpl.getDatatypeValue() throws NPE with Custom DataTypes
Status: RESOLVED WONTFIX
Alias: None
Product: EMF
Classification: Modeling
Component: XML/XMI (show other bugs)
Version: 2.5.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-08 19:10 EDT by Flavio Donze CLA
Modified: 2010-06-09 20:19 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Flavio Donze CLA 2010-06-08 19:10:33 EDT
Build Identifier: I20100527-1700

I have a Custom DataType defined, when I want to store my EObject as XMI file I get a NPE because the value of the DataType is null.

on the first null check "value" is not null, it is the custom data type.
After
String svalue = helper.convertToString(fac, d, value);
svalue now is null and
svalue = escape.convert(svalue);
then causes the NPE.

Here the stack trace:

java.lang.NullPointerException
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl$Escape.convert(XMLSaveImpl.java:3252)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.getDatatypeValue(XMLSaveImpl.java:3082)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveDataTypeSingle(XMLSaveImpl.java:1678)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1265)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2685)
	at org.eclipse.emf.ecore.xmi.impl.XMISaveImpl.writeTopObjects(XMISaveImpl.java:90)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:592)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:256)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:206)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
	at com.softmodeler.common.util.ExportUtil.exportObject(ExportUtil.java:315)
	at com.softmodeler.common.util.ExportUtil.exportObject(ExportUtil.java:296)
	at com.softmodeler.common.util.ExportUtil.export(ExportUtil.java:255)
	at com.softmodeler.ui.rcp.handler.ExportHandler.execute(ExportHandler.java:46)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:820)
	at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:806)
	at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:796)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.softmodeler.ui.rcp.RCPApplication.start(RCPApplication.java:113)
	at ch.scodi.scodi4p.ScodiRCPClient.start(ScodiRCPClient.java:25)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


Reproducible: Always
Comment 1 Ed Merks CLA 2010-06-09 12:49:51 EDT
Conversion to string is all about producing a readable and serializeable string value, so I just don't see how it makes sense to convert a non-null value to null; upon deserialization we won't do any special processing to turn it back into a non-null value either. I see no value/motivation to change the framework to accommodate such a thing.
Comment 2 Flavio Donze CLA 2010-06-09 16:13:57 EDT
I will then probably have to clean up my objects before I do an export.

But just consider this.

My Custom DataType is called ResourceType and contains a string field "path" which is the actual value of the DataType (returned in toString()).
In some cases an EObjects field of type ResourceType is set but the "path" field is still null.

In this case the NPE occurs. I think this can happen to similar datatypes as well.

I don't need those ResourceTypes to be serialized nor deserialized, since they are empty.
Comment 3 Ed Merks CLA 2010-06-09 20:19:22 EDT
I don't follow your comments.  We're simply never expecting a non-null value to convert to a null string.