This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
We have run into this issue. Wanted to customize resource provided by one module, by another module dependent on it. xml/core module has in its jar (among other files) (under resources/templates folder) file named: 'emptyXML.xml.template' When we are referring to the file from other module (dependent on xml/core) by the nbresloc protocol: <file name="someNewName" url="nbresloc:/org/netbeans/modules/xml/core/resources/templates/emptyXML.xml.template"/> Then during runtime the file is not found, it is thrown an exception that there is not found resource: 'nbresloc:/org/netbeans/modules/xml/core/resources/templates/emptyXML/xml.template' Look at the the second to last dot, it was changed to a slash. If you look into the implementation (the core/src/../NbURLStreamHandlerFactory), you'll see the reason, all dots except the last one are replaced by slashes. Is there any workaround? Could you fix it the way, you provide new protocol unless this existing one can be adjusted.
Or could you require those modules don't provide more than one dot (for extension only) in the layers?
reassigne to Jesse
If URL contains at last one '/' do not substitute '.' by '/'. I declined to workaround it in XML module layer.
Will just have to stop using NbBundle.getLocalizedFile, I guess; it is simply unusable for this scenario (and not a very smart API in general, but very old and won't change it now). Can mostly copy and paste that code, simplifying it (cannot use NbBundle's cache any more). Or can use a special-case code path in case the nbresloc file contains >1 '.' after the last '/'.
It is not the NbBundle.getLocalizedFile which bothers. But that I can't use that protocol if need to reuse some file from dependent module in xml layer. See the scenario I described at the beginning. (We are customizing the locations of templates, moving some of them into different folders, it would be useful to be able just to reuse the original files -> now we need to copy them).
Well I have a working patch but it looks like I am too late to put it into 4.1, since that is being branched right now and I am still running commit validation. :-( If you feel this issue is important to you (and you cannot use a simple workaround, such as was suggested in issue #54045) you may be justified in raising priority to P2, in which case I would be permitted to merge the fix to the release41 branch. BTW: I believe the old nbresloc impl also has an obscure bug relating to resources with a '.' in a nonterminal path component, e.g. "nbresloc:/some.dir/file" would not be correctly brandable. I have covered this possibility as well in the unit test which confirms the fix of the bug you reported. Note that the patch makes the nbresloc protocol handler not use NbBundle.getLocalizingFile at all; this also means that the cache which NbB.gLF maintains will not be used. I don't know if that would have any significant effect on startup time; would be nice to have some comparative measurement done for that.
Created attachment 21319 [details] The patch
Thanks for the patch and fixing of the issue, I think it is OK to have it in next release.
OK. committed * Up-To-Date 1.10 core/src/org/netbeans/core/NbURLStreamHandlerFactory.java added * Up-To-Date 1.1 core/test/unit/src/org/netbeans/core/NbURLStreamHandlerFactoryTest.java committed * Up-To-Date 1.58 openide/src/org/openide/util/NbBundle.java