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 144166 - [65cat] IllegalArgumentException: Duplicate in children list: LICENSE.txt
Summary: [65cat] IllegalArgumentException: Duplicate in children list: LICENSE.txt
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jiri Skrivanek
URL: http://statistics.netbeans.org/except...
Keywords:
: 151450 151452 152682 153398 153776 159724 160761 161289 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-16 13:31 UTC by sunbiz
Modified: 2009-04-10 14:03 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 92496


Attachments
stacktrace (1.79 KB, text/plain)
2008-08-16 13:31 UTC, sunbiz
Details
stack trace (1.54 KB, text/plain)
2008-10-02 06:18 UTC, athompson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sunbiz 2008-08-16 13:31:22 UTC
Build: NetBeans IDE Dev (Build 080815)
VM: Java HotSpot(TM) Client VM, 11.0-b15, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b28
OS: Windows Vista, 6.0, x86

User Comments: 
Expanding the contents of a library jar (avalon-framework-4.2.0.jar) inside a free-form web project

Stacktrace: 
java.lang.IllegalArgumentException: Duplicate in children list: LICENSE.txt
        at org.openide.filesystems.Ordering.getOrder(Ordering.java:97)
        at org.openide.filesystems.FileUtil.getOrder(FileUtil.java:1802)
        at org.openide.loaders.FolderChildren$1R.run(FolderChildren.java:161)
        at org.openide.loaders.FolderChildren.refreshChildren(FolderChildren.java:184)
        at org.openide.loaders.FolderChildren.addNotify(FolderChildren.java:269)
        at org.openide.nodes.Children.callAddNotify(Children.java:525)
Comment 1 sunbiz 2008-08-16 13:31:26 UTC
Created attachment 67625 [details]
stacktrace
Comment 2 Exceptions Reporter 2008-08-28 18:03:25 UTC
This issue has already 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=92496
Comment 3 Jiri Skrivanek 2008-09-02 15:28:08 UTC
I cannot reproduce it in recent builds.
Comment 4 athompson 2008-09-29 21:32:49 UTC
same problem here.  perhaps it's a linux thing.
Comment 5 athompson 2008-09-29 21:43:58 UTC
i think it may have to do with having the same classes in 2 different jar files.  for example, i have 'tasks.jar' and
'tasks-with-dependencies.jar'.  the i can explore every folder except "com.thompsonlogic.tasks" in the latter file. 
this folder contains the exact same classes as the same package in 'tasks.jar'.

long story short: this is just a wild guess, but i think the items in the tree are being cached by holding them in a map
keyed by their path name.  the error occurs because multiple items have the same path name.  the key should be jar file
name + path name.
Comment 6 athompson 2008-09-29 21:45:28 UTC
Product Version: NetBeans IDE Dev (Build 200809290201)
Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15
System: Linux version 2.6.18-92.1.13.el5 running on i386; UTF-8; en_US (nb)
Userdir: /rhome/users/athompson/.netbeans/dev
Comment 7 Jiri Skrivanek 2008-09-30 09:16:56 UTC
I changed exception message to print all children. But I am not able to reproduce the problem even with two jars with
the same content. If you see the exception again in newer builds, please, attach a new stack trace with list of
children. Reassigning to 'nodes' if someone have an idea what could be wrong.
Comment 8 t_h 2008-09-30 10:03:14 UTC
Original report could be caused by error in implementation of Node.setChildren() (which was fixed recently). However,
last exception report seems ok from Nodes point of view
Comment 9 Jesse Glick 2008-09-30 13:29:49 UTC
I suspect a bug (race condition perhaps?) in FolderChildren, but it is hard to tell without a test case to reproduce.
Comment 10 Quality Engineering 2008-09-30 17:21:45 UTC
Integrated into 'main-golden', will be available in build *200809301401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/d5ba8c25f5b8
User: Jiri Skrivanek <jskrivanek@netbeans.org>
Log: #144166 - Print children in failure reports.
Comment 11 athompson 2008-10-01 14:45:33 UTC
i don't see any logging in the 9/30 1401 build.  i'll try with the next build when it's available.
Comment 12 Jiri Skrivanek 2008-10-01 14:53:36 UTC
There should be just more detailed message in IllegalArgumentException.
Comment 13 athompson 2008-10-02 06:18:51 UTC
Created attachment 71018 [details]
stack trace
Comment 14 athompson 2008-10-02 06:30:39 UTC
'tables.sql' and 'triggers.sql' are in the root of each jar file.
Comment 15 athompson 2008-10-02 07:28:56 UTC
sorry, false alarm.  the problem isn't that there are files with the same name in multiple jars.  the problem is that
the maven assembly plugin is adding is adding duplicate files to the jar; it has nothing to do with netbeans.

on the other hand, if it's technically possible to add duplicate files to a jar you might want to handle it, even if it
makes no sense.
Comment 16 Jesse Glick 2008-10-02 19:13:53 UTC
Sounds like a bug rather for JarFileSystem. If it is possible for a ZIP to contain duplicate entries, JFS should handle
this gracefully, perhaps printing a warning (or throwing IOException somewhere?) but not passing on the problem to
higher layers like DataFolder.
Comment 17 Jaroslav Tulach 2008-10-03 10:00:36 UTC
I guess Jesse is right, this cannot be a bug in FolderChildren as they do only:
  final FileObject[] arr = folder.getPrimaryFile().getChildren();
  FolderOrder order = FolderOrder.findFor(folder.getPrimaryFile());
  Arrays.sort(arr, order);
So the filesystem must have returned duplicated entry.
Comment 18 Jiri Skrivanek 2008-10-03 10:15:59 UTC
If it is possible for a ZIP to contain duplicate entries and a concrete jar contains duplicate entries, it is correct
that filesystem returns all entries including duplicate ones. IMO, it is up to FolderChildren to handle such situation.
Comment 19 Jesse Glick 2008-10-03 17:15:42 UTC
It is a bug in JFS. All clients of Filesystems naturally expect that there will be at most one child FileObject with a
given name (i.e. nameExt) in a given folder at a given time. Breaking this invariant would cause mayhem.

The possibility of such a situation in ZIP files seems to be an oversight (you could not unpack such a ZIP all at
once!), arguably a bug in the code that writes the ZIP file; clearly there is a bug in Maven for attempting to write the
same file twice.
Comment 20 Jiri Skrivanek 2008-10-06 09:00:30 UTC
OK, I will add some warning to JarFileSystem that a jar contains duplicate entries.
Comment 21 Jiri Skrivanek 2008-10-15 09:54:56 UTC
Fixed. If duplicate entries found in jar, it is immediately reported to the user.

http://hg.netbeans.org/core-main/rev/4ae1db6577e0
Comment 22 Quality Engineering 2008-10-16 04:12:32 UTC
Integrated into 'main-golden', will be available in build *200810160201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4ae1db6577e0
User: Jiri Skrivanek <jskrivanek@netbeans.org>
Log: #144166 - If duplicate entries found in jar, it is immediately reported to the user.
Comment 23 Jiri Skrivanek 2008-10-27 13:08:04 UTC
*** Issue 151450 has been marked as a duplicate of this issue. ***
Comment 24 Jiri Skrivanek 2008-10-27 13:09:12 UTC
*** Issue 151452 has been marked as a duplicate of this issue. ***
Comment 25 Milos Kleint 2008-11-09 14:45:44 UTC
*** Issue 152682 has been marked as a duplicate of this issue. ***
Comment 26 Milos Kleint 2008-11-09 16:25:43 UTC
*** Issue 152682 has been marked as a duplicate of this issue. ***
Comment 27 _ mriem 2008-11-09 16:35:51 UTC
After reading the source of the fix, I think it is not the correct way to handle this. Completely invalidating the 
entire JAR file causes a regression bug that prevents users that could work with 6.1 to work with 6.5 and above.

I don't think it is necessarily Maven that is causing the problem. I think it is the creator of the JAR file. And 
hence that is something you cannot fix if you don't deal with it at this level.

So, I am reopening the issue since I don't think the fix is helpful at all. I think the fix should remove the 2nd 
entry and then signal the user it found a duplicate entry with a suggestion to contact the author of the JAR file
and then still return the cache.
Comment 28 Jiri Skrivanek 2008-11-11 08:56:06 UTC
I don't think your suggestion makes a difference. Once a jar is invalid (contains duplicate entries) it should be fixed.
Duplicate entry is printed in error message, so why to show content of malformed jar. I don't see any use case of it.
Comment 29 Jiri Skrivanek 2008-11-19 08:18:07 UTC
*** Issue 153398 has been marked as a duplicate of this issue. ***
Comment 30 Jiri Skrivanek 2008-11-24 15:05:29 UTC
*** Issue 153776 has been marked as a duplicate of this issue. ***
Comment 31 Jiri Skrivanek 2009-03-20 18:37:02 UTC
*** Issue 160761 has been marked as a duplicate of this issue. ***
Comment 32 Jesse Glick 2009-03-20 19:28:38 UTC
I agree with vkraemer and mriem that more graceful handling would be in order. Sometimes a JAR with duplicate entries
appears in a Maven repo, etc. It is generally perfectly usable if you simply ignore the extra entries and pick the first
one you find of a given name. Logging the fact that the JAR has this problem, e.g. a one-line WARNING to log file, would
be appropriate, in case the user has some chance to contact the creator of the JAR and get the root problem fixed.
Comment 33 Vince Kraemer 2009-03-20 20:11:18 UTC
It seems like the fix for this penalizes our users for the mistake someone else made (the person that created the broken
jar).  Since other tools (like the jar command) do not choke on the invalid jar, maybe we should not either.

The behavior of 6.5 is better than the behavior of 6.7, so I would consider the current behavior regressive.
Comment 34 Jiri Skrivanek 2009-03-23 13:40:01 UTC
OK, if jar contains duplicate entries, I print warning and ignore them.
http://hg.netbeans.org/core-main/rev/d2b8959c277b
Comment 35 Quality Engineering 2009-03-24 23:31:30 UTC
Integrated into 'main-golden', will be available in build *200903241535* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/d2b8959c277b
User: Jiri Skrivanek <jskrivanek@netbeans.org>
Log: #144166 - If jar contains duplicate entries, log warning and ignore them.
Comment 36 Jiri Skrivanek 2009-03-31 08:52:23 UTC
*** Issue 159724 has been marked as a duplicate of this issue. ***
Comment 37 Jan Lahoda 2009-04-10 14:03:23 UTC
*** Issue 161289 has been marked as a duplicate of this issue. ***