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.

View | Details | Raw Unified | Return to bug 208919
Collapse All | Expand All

(-)a/core.startup/src/org/netbeans/core/startup/layers/ParsingLayerCacheManager.java (-15 / +17 lines)
Lines 222-241 Link Here
222
            fileOrFolder(qname, attrs);
222
            fileOrFolder(qname, attrs);
223
        } else if (qname.equals("file")) {
223
        } else if (qname.equals("file")) {
224
            MemFileOrFolder mfof = fileOrFolder(qname, attrs);
224
            MemFileOrFolder mfof = fileOrFolder(qname, attrs);
225
            if (!(mfof instanceof MemFile)) { // a collision between modules
225
            if (!(mfof instanceof MemFile)) { 
226
                throw new ClassCastException("mfof: " + mfof + " stack: " + curr); // NOI18N
226
                // a collision between modules
227
            } else {
228
                buf.setLength(0);
229
                ref = null;
230
                String u = attrs.getValue("url");
231
                if (u != null) {
232
                    try {
233
                        ref = new URL(base, u);
234
                    } catch (MalformedURLException mfue) {
235
                        throw (SAXException) new SAXException(mfue.toString()).initCause(mfue);
236
                    }
237
                }
238
                weight = 0;
227
            }
239
            }
228
            buf.setLength(0);
229
            ref = null;
230
            String u = attrs.getValue("url");
231
            if (u != null) {
232
                try {
233
                    ref = new URL(base, u);
234
                } catch (MalformedURLException mfue) {
235
                    throw (SAXException) new SAXException(mfue.toString()).initCause(mfue);
236
                }
237
            }
238
            weight = 0;
239
        } else if (qname.equals("attr")) {
240
        } else if (qname.equals("attr")) {
240
            attrCount++;
241
            attrCount++;
241
            MemAttr attr = new MemAttr();
242
            MemAttr attr = new MemAttr();
Lines 341-348 Link Here
341
    }
342
    }
342
    
343
    
343
    public void endElement(String ns, String lname, String qname) throws SAXException {
344
    public void endElement(String ns, String lname, String qname) throws SAXException {
344
        if (qname.equals("file")) {
345
        Object poke;
345
            MemFile file = (MemFile) curr.peek();
346
        if (qname.equals("file") && (poke = curr.peek()) instanceof MemFile) {
347
            MemFile file = (MemFile) poke;
346
            if (weight /* #23609: reversed, so not > */>= file.weight) {
348
            if (weight /* #23609: reversed, so not > */>= file.weight) {
347
                file.weight = weight;
349
                file.weight = weight;
348
                file.contents = null;
350
                file.contents = null;
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/layers/CacheManagerTestBaseHid.java (-6 / +6 lines)
Lines 145-156 Link Here
145
        List<URL> urls = Arrays.asList(
145
        List<URL> urls = Arrays.asList(
146
            loadResource("data/folder2.xml"),
146
            loadResource("data/folder2.xml"),
147
            loadResource("data/folder1.xml"));
147
            loadResource("data/folder1.xml"));
148
        try {
148
        
149
            FileSystem f = BinaryCacheManagerTest.store(m, urls);
149
        FileSystem f = BinaryCacheManagerTest.store(m, urls);
150
            fail("Should throw an exception");
150
        final FileObject fld = f.findResource("folder");
151
        } catch (IOException ex) {
151
        
152
            // OK, collision
152
        assertTrue("Is folder", fld.isFolder());
153
        }
153
        assertEquals("No content", 0, fld.getSize());
154
    }
154
    }
155
    
155
    
156
    private void checkLastModified (FileSystem f, String file, String resource) throws Exception {
156
    private void checkLastModified (FileSystem f, String file, String resource) throws Exception {
(-)a/o.n.bootstrap/test/unit/data/layers/data/folder2.xml (-1 / +1 lines)
Lines 1-5 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
2
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
3
<filesystem>
3
<filesystem>
4
    <file name="folder"/>
4
    <file name="folder">NotEmpty</file>
5
</filesystem>
5
</filesystem>
(-)a/openide.filesystems/src/org/openide/filesystems/XMLFileSystem.java (-12 / +5 lines)
Lines 615-621 Link Here
615
        private boolean isFolder;
615
        private boolean isFolder;
616
        private String uri;
616
        private String uri;
617
617
618
        public ResourceElem(boolean isFolder, URL[] urlContext) {
618
        public ResourceElem(boolean isFolder, URL... urlContext) {
619
            this.isFolder = isFolder;
619
            this.isFolder = isFolder;
620
            this.urlContext.addAll(Arrays.asList(urlContext));
620
            this.urlContext.addAll(Arrays.asList(urlContext));
621
621
Lines 625-643 Link Here
625
            }
625
            }
626
        }
626
        }
627
627
628
        public ResourceElem(boolean isFolder, URL urlContext) {
628
        ResourceElem addChild(String name, ResourceElem child) {
629
            this.isFolder = isFolder;
629
            if (!isFolder) {
630
            this.urlContext.add(urlContext);
631
632
            if (isFolder) {
633
                children = new ArrayList<ResourceElem>();
630
                children = new ArrayList<ResourceElem>();
634
                names = new ArrayList<String>();
631
                names = new ArrayList<String>();
635
            }
632
                content = null;
636
        }
633
                isFolder = true;
637
638
        ResourceElem addChild(String name, ResourceElem child) {
639
            if (!isFolder) {
640
                throw new IllegalArgumentException("not a folder"); // NOI18N
641
            }
634
            }
642
            assert name != null && name.indexOf("/") == -1:(child.isFolder ? "<folder name=":"<file name=")+name+" ...";//NOI18N
635
            assert name != null && name.indexOf("/") == -1:(child.isFolder ? "<folder name=":"<file name=")+name+" ...";//NOI18N
643
636
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/RepositoryTest.java (-1 / +3 lines)
Lines 56-61 Link Here
56
import java.util.Arrays;
56
import java.util.Arrays;
57
import java.util.Collections;
57
import java.util.Collections;
58
import java.util.Enumeration;
58
import java.util.Enumeration;
59
import java.util.List;
59
import java.util.concurrent.atomic.AtomicInteger;
60
import java.util.concurrent.atomic.AtomicInteger;
60
import java.util.concurrent.atomic.AtomicReference;
61
import java.util.concurrent.atomic.AtomicReference;
61
import org.netbeans.junit.NbTestCase;
62
import org.netbeans.junit.NbTestCase;
Lines 96-102 Link Here
96
        });
97
        });
97
        FileObject r = FileUtil.getConfigRoot();
98
        FileObject r = FileUtil.getConfigRoot();
98
        assertTrue(r.isValid());
99
        assertTrue(r.isValid());
99
        assertEquals(4, r.getChildren().length);  // org.openide.filesystems.resources.layer.xml, test-layer-1.xml, test-layer-2.xml, test/generated-layer.xml
100
        List<FileObject> arr = Arrays.asList(r.getChildren());
101
        assertEquals("Four " + arr, 4, arr.size());  // org.openide.filesystems.resources.layer.xml, test-layer-1.xml, test-layer-2.xml, test/generated-layer.xml
100
        assertNotNull(r.getFileObject("foo"));
102
        assertNotNull(r.getFileObject("foo"));
101
        assertNotNull(r.getFileObject("bar"));
103
        assertNotNull(r.getFileObject("bar"));
102
    }
104
    }

Return to bug 208919