eclipse / swtchart

Eclipse Public License 2.0
45 stars 41 forks source link

org.eclipse.swtchart.extensions bundle activation prints unnecessary exception to syserr #380

Closed tvlehton closed 8 months ago

tvlehton commented 8 months ago

Problem

Every time bundle org.eclipse.swtchart.extensions is activated, it will print out the following exception stack trace for failed loading of .eclipseswtchartsettings from the user's home directory.

java.io.FileNotFoundException: C:\Users\MyUserName\.eclipseswtchartsettings (The system cannot find the file specified)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:111)
    at org.eclipse.jface.preference.PreferenceStore.load(PreferenceStore.java:367)
    at org.eclipse.swtchart.extensions.core.ResourceSupport.getPreferenceStore(ResourceSupport.java:102)
    at org.eclipse.swtchart.extensions.internal.mappings.MappingsIO.restoreSettings(MappingsIO.java:101)
    at org.eclipse.swtchart.extensions.Activator.start(Activator.java:42)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:813)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:805)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:762)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
    at org.eclipse.osgi.container.Module.doStart(Module.java:605)
    at org.eclipse.osgi.container.Module.start(Module.java:468)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
    at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
    at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:484)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    at myproduct.MyEditor(MyEditor.java:line)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:158)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:365)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
...

The print comes from https://github.com/eclipse/swtchart/blame/9b90a7cf89cfabb37bb977fe4b24d13f56880d52/org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/core/ResourceSupport.java#L117 and it was introduced in cce835a94f8d4d62888c9b2e52b08665afe1861b of #280.

Expected outcome

I personally feel that it is pointless to print the exception stack trace when the file does not exist, i.e. upon FileNotFoundException, as seen in the stack trace above. Any other IOException is probably worth printing out.

Mailaender commented 2 months ago

This is still a problem https://github.com/flathub/com.lablicate.OpenChrom/issues/9. The error message is really spammy. You can't see anything else printed before because it repeats so many times.