jQAssistant / jqassistant

Your Software. Your Structures. Your Rules.
https://jqassistant.org/
GNU General Public License v3.0
198 stars 35 forks source link

NullPointerException when resource to be scanned doesn't exist #42

Closed jensnerche closed 10 years ago

jensnerche commented 10 years ago

When in an integration test scanURLs(URL...) is called with a non-existing file, a NPE occures:

java.lang.NullPointerException at com.buschmais.jqassistant.core.scanner.impl.FileScannerImpl$5.getName(FileScannerImpl.java:285) at com.buschmais.jqassistant.core.scanner.impl.FileScannerImpl$5.getName(FileScannerImpl.java:265) at com.buschmais.jqassistant.core.scanner.impl.FileScannerImpl$AbstractIterable$1.hasNext(FileScannerImpl.java:53) at com.buschmais.jqassistant.plugin.common.test.AbstractPluginIT.scanURLs(AbstractPluginIT.java:216) at com.buschmais.jqassistant.plugin.common.test.AbstractPluginIT.scanURLs(AbstractPluginIT.java:203)

jensnerche commented 10 years ago

Maybe the cause is not that the file does not exists. I've just created one and the NPE still occures. UPDATE: there was a typo. The cause is that the file does not exist, so the URL is null which leads to the NPE.

DirkMahler commented 10 years ago

It seems that a null value is passed to the AbstractPluginIT.scanUrls() - are they created using Class.getResource() with a wrong resource name?. Nevertheless the file scanner should not exit with an NPE but with a dedicated exception.

jensnerche commented 10 years ago

Yes, the URL is null - no wonder, the file does not exist...