Project: mulestudio
Issue STUDIO-2586: DataMapper: Exception generated when using an invalid JSON file
Steps to reproduce: 1.- Create a JSON to XML mapping 2.- Use a base JSON file with a bad structure 3.- Generate defaults for the XML Issue: this exception is thrown in the error log {code} java.lang.RuntimeException: java.lang.RuntimeException: Provided JSON file contains syntax errors: Expected EOF at line 2 column 1 com.mulesoft.mule.datamapper.ui.wizard.JSONMetadataPropertiesPanel$FromExampleMetadataGenerator.generateMetadata(JSONMetadataPropertiesPanel.java:180) com.mulesoft.mule.datamapper.ui.wizard.BaseMetadataPropertiesPanel.generateMetadata(BaseMetadataPropertiesPanel.java:231) com.mulesoft.mule.datamapper.ui.wizard.InputOutputSelectionPage$14.widgetSelected(InputOutputSelectionPage.java:516) org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248) org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) org.eclipse.swt.widgets.Display.sendEvent(Display.java:4134) org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458) org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481) org.eclipse.swt.widgets.Widget.sendSelectionEvent(Widget.java:1531) org.eclipse.swt.widgets.Link.textView_clickOnLink_atIndex(Link.java:117) org.eclipse.swt.widgets.Display.windowProc(Display.java:5807) org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) org.eclipse.swt.widgets.Widget.callSuper(Widget.java:221) org.eclipse.swt.widgets.Widget.mouseDownSuper(Widget.java:1093) org.eclipse.swt.widgets.Widget.mouseDown(Widget.java:1085) org.eclipse.swt.widgets.Control.mouseDown(Control.java:2538) org.eclipse.swt.widgets.Display.windowProc(Display.java:5493) org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) org.eclipse.swt.widgets.Widget.callSuper(Widget.java:221) org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2102) org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2299) org.eclipse.swt.widgets.Display.windowProc(Display.java:5557) org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5002) org.eclipse.swt.widgets.Display.applicationProc(Display.java:5151) org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method) org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128) org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3616) org.eclipse.jface.window.Window.runEventLoop(Window.java:825) org.eclipse.jface.window.Window.open(Window.java:801) com.mulesoft.mule.datamapper.ui.view.DataMapperView.launchDMWizard(DataMapperView.java:568) com.mulesoft.mule.datamapper.ui.view.DataMapperView$5.launchNewDataMapperFlow(DataMapperView.java:228) com.mulesoft.mule.datamapper.ui.editor.DataMapperEditor$3.handleEvent(DataMapperEditor.java:218) org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) org.eclipse.swt.widgets.Display.sendEvent(Display.java:4134) org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458) org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481) org.eclipse.swt.widgets.Widget.sendSelectionEvent(Widget.java:1531) org.eclipse.swt.widgets.Link.textView_clickOnLink_atIndex(Link.java:117) org.eclipse.swt.widgets.Display.windowProc(Display.java:5807) org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) org.eclipse.swt.widgets.Widget.callSuper(Widget.java:221) org.eclipse.swt.widgets.Widget.mouseDownSuper(Widget.java:1093) org.eclipse.swt.widgets.Widget.mouseDown(Widget.java:1085) org.eclipse.swt.widgets.Control.mouseDown(Control.java:2538) org.eclipse.swt.widgets.Display.windowProc(Display.java:5493) org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) org.eclipse.swt.widgets.Widget.callSuper(Widget.java:221) org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2102) org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2299) org.eclipse.swt.widgets.Display.windowProc(Display.java:5557) org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5002) org.eclipse.swt.widgets.Display.applicationProc(Display.java:5151) org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method) org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128) org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3616) org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353) org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629) org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) org.eclipse.equinox.launcher.Main.run(Main.java:1438) Caused by: java.lang.RuntimeException: Provided JSON file contains syntax errors: Expected EOF at line 2 column 1 com.mulesoft.mule.datamapper.ui.editor.metadata.service.impl.JsonSchemaGenerator.createSchema(JsonSchemaGenerator.java:63) com.mulesoft.mule.datamapper.ui.wizard.JSONMetadataPropertiesPanel$FromExampleMetadataGenerator.generateMetadata(JSONMetadataPropertiesPanel.java:162)	... 76 more Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected EOF at line 2 column 1 com.google.gson.JsonParser.parse(JsonParser.java:65) com.mulesoft.mule.datamapper.ui.editor.metadata.service.impl.JsonSchemaGenerator.createSchema(JsonSchemaGenerator.java:57)	... 77 more Caused by: com.google.gson.stream.MalformedJsonException: Expected EOF at line 2 column 1 com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1298) com.google.gson.stream.JsonReader.peek(JsonReader.java:390) com.google.gson.JsonParser.parse(JsonParser.java:60)	... 78 more {code}
Story points: 8