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.

Bug 257992 - Resolving of branded layer.xml stack stops resolving for module after first resolved layer.xml.
Summary: Resolving of branded layer.xml stack stops resolving for module after first r...
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Module System (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P1 normal (vote)
Assignee: Tomas Hurka
URL:
Keywords: REGRESSION
Depends on: 229353
Blocks:
  Show dependency tree
 
Reported: 2016-02-15 14:13 UTC by jmichelberger
Modified: 2016-05-09 11:49 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Branding project, with layer.xml breaking loading. (9.66 KB, application/x-zip-compressed)
2016-05-02 14:20 UTC, jmichelberger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jmichelberger 2016-02-15 14:13:19 UTC
It seems that additional layer.xml files provided by the platform patch mechanism are not handled proper any more. I am doing a NetBeans platform update from 7.3 to 8.1 of my application. I have branding modules, adding layer.xml files for modules, which exists in default NetBeans modules.

e.g.
original org-netbeans-spi-navigator.jar with org/netbeans/navigator/resources/layer.xml
branded org-netbeans-spi-navigator.jar with org/netbeans/navigator/resources/layer_myapp_de.xml

On NetBeans platform 7.3 both files are loaded. No NetBeans platform 8.1 only layer_myapp_de.xml is loaded, which contains only "_hidden" information.

I digged a bit deeper and found in module core.startup org.netbeans.core.startup.NbInstaller.loadLayers() line 609 and following the loading code:
                for (String suffix : NbCollections.iterable(NbBundle.getLocalizingSuffixes())) {
                    String resource = base + suffix + ext;
                    Enumeration<URL> en = m.findResources(resource);
                    if (en.hasMoreElements()) {
                        URL u = en.nextElement();
                        theseurls.add(u);
                        foundSomething = true;
                        if (en.hasMoreElements()) {
                            String patchesClassPath = System.getProperty("netbeans.patches." + m.getCodeNameBase()); // NOI18N
                            assert patchesClassPath != null : "At most one resource per module: " + m; // NOI18N
                            Util.err.log(Level.INFO, "Using {0} as layer for {1} not {2}", new Object[]{u, m.getCodeNameBase(), en.nextElement()}); // NOI18N
                        }
                        break;
                    }

The for loop probes all localization suffixes and calls Module.findResources() with the assembled name of the layer.xml.
For my module and branding I expect Module.findResource() attempts for (at least) layer_myapp_de.xml, layer_de.xml, layer.xml, but first attempt for layer_myapp_de.xml is successful and the break line stops subsequent Module.findResource() calls. 
Result is that the expected stack of layer.xml files is not loaded and resulting System.FileSystem is incomplete and corrupt.

I found the changeset introducing that "break" in Bug 229353 https://netbeans.org/bugzilla/show_bug.cgi?id=229353.

Removing that "break" will help and load all layer.xml files again.

Regards.
  Jörg
Comment 1 Jaroslav Tulach 2016-05-02 12:32:20 UTC
Would you be so kind and attach simple sample application so we can verify our future fix?
Comment 2 Jaroslav Tulach 2016-05-02 12:38:58 UTC
This could be a potential fix - it only breaks when one is using netbeans.patches.cnb properties - so in production it could work as before.


--- a/NbInstaller.java
+++ b/NbInstaller.java
@@ -613,14 +613,16 @@
                         URL u = en.nextElement();
                         theseurls.add(u);
                         foundSomething = true;
-                        if (en.hasMoreElements()) {
                             String patchesClassPath = System.getProperty("netbeans.patches." + m.getCodeNameBase()); // NOI18N
+                        if (en.hasMoreElements()) {
                             assert patchesClassPath != null : "At most one resource per module: " + m; // NOI18N
                             Util.err.log(Level.INFO, "Using {0} as layer for {1} not {2}", new Object[]{u, m.getCodeNameBase(), en.nextElement()}); // NOI18N
                         }
+                        if (patchesClassPath != null) {
                         break;
                     }
                 }
+                }
                 if (! foundSomething) {
                     // Should never happen (we already checked in prepare() for base layer)...
                     Util.err.fine("Module layer not found: " + s);
Comment 3 jmichelberger 2016-05-02 14:20:59 UTC
Created attachment 159512 [details]
Branding project, with layer.xml breaking loading.

Project with branding, carrying layer.xml in org/netbeans/core/windows/resources which should hide ResetWindowsAction in menu window.
Existence of layer.xml breaks loading.
Comment 4 jmichelberger 2016-05-02 14:23:26 UTC
Sorry for late provided example application.
Comment 5 Tomas Hurka 2016-05-09 11:43:21 UTC
Thanks for the sample application.
Comment 6 Tomas Hurka 2016-05-09 11:49:16 UTC
Fixed in profiler-main

changeset:   296566:445334c2ab59
user:        Tomas Hurka <thurka@netbeans.org>
date:        Mon May 09 13:47:59 2016 +0200
summary:     bugfix #257992, break command removed - we don't want to break 'for' cycle with suffixes