Cannot invoke "org.openide.filesystems.FileObject.getMIMEType()"
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 17
### What happened
I'm getting a java.lang.NullPointerException when opening a .JSON file in NetBeans. Note the file opens correctly just this Silent Error is thrown.
The error is:
_Cannot invoke "org.openide.filesystems.FileObject.getMIMEType()" because "this.internalFo" is null_
I believe it is because there are no Code Templates for JSON and the Code Templates window is open. Although not tested, I believe the same error will be thrown if other Code Templates sections don't have any code templates defined.
### How to reproduce
1. Open the Code Templates window (_Window>Code Templates_)
2. Create a JSON file with some dummy JSON data and give the file the extension: .json
3. In _Tools>Options>Editor>Code Templates>JSON_ make sure there are no templates
4. Open the .json file in NetBeans.
5. Silent Error (**Unexpected Exception**) is thrown
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Linux Mint 19.3 Cinnamon - Linux Kernel 5.4.0-144-generic
### JDK
openjdk version "17.0.6" 2023-01-17 OpenJDK Runtime Environment (build 17.0.6+10-Ubuntu-0ubuntu118.04.1)
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
This error can be eliminated by adding a Code Template to the Code Templates (JSON) section.
### Are you willing to submit a pull request?
No
Contributor guide
Research direction
Start by reproducing the issue through Window > Code Templates, then open an empty JSON template section and a .json file as described. Trace the Code Templates window and JSON editor interaction that produces the internalFo null error; done means opening the file no longer throws the silent Unexpected Exception when the section has no templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100