Bug 232229 - Allow to ignore duplicate exception
Allow to ignore duplicate exception
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Module System
7.4
PC Windows 7
: P1 (vote)
: 7.4
Assigned To: Jaroslav Tulach
issues@platform
: API_REVIEW_FAST
Depends on:
Blocks: 219939
  Show dependency treegraph
 
Reported: 2013-07-03 21:11 UTC by František Mantlík
Modified: 2013-08-08 02:30 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Patch to ignore duplicate exception (1.09 KB, patch)
2013-07-03 21:11 UTC, František Mantlík
Details | Diff
The sample application which demonstrates the duplicate exception problem (18.72 KB, application/x-zip-compressed)
2013-07-08 12:18 UTC, František Mantlík
Details
Patch to ignore duplicate exception (updated) (3.52 KB, patch)
2013-07-24 10:57 UTC, František Mantlík
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description František Mantlík 2013-07-03 21:11:03 UTC
Created attachment 136679 [details]
Patch to ignore duplicate exception

Bunch of DuplicateExceptions is thrown when trying to start TestNG functional tests for a Maven RCP application. The exceptions are most probably harmless, they do not influence tests or tested application, but they pop up an exception reporting dialog.

Proposed patch introduces system property "netbeans.ignore.dupmodule". When set to "true", duplicate module is processed normally and a warning is logged:

--- o.n.bootstrap/src/org/netbeans/ModuleManager.java
+++ o.n.bootstrap/src/org/netbeans/ModuleManager.java
@@ -892,8 +892,12 @@
     private void subCreate(Module m) throws DuplicateException {
         Module old = get(m.getCodeNameBase());
         if (old != null) {
+            if (System.getProperty("netbeans.ignore.dupmodule", "false").equalsIgnoreCase("false")) {
             throw new DuplicateException(old, m);
+            } else {
+                Util.err.warning("Duplicate loading ignored: " + old + " and " + m);
         }
+        }
         modules.add(m);
         modulesByName.put(m.getCodeNameBase(), m);
         providersOf.possibleProviderAdded(m);
Comment 1 Jaroslav Tulach 2013-07-08 07:12:46 UTC
The property would have to be documented according to API review guidelines: http://wiki.netbeans.org/APIReviews

Anyway I am not convinced this is the right solution. Please attach sample application that shows your problem.
Comment 2 František Mantlík 2013-07-08 12:18:46 UTC
Created attachment 136817 [details]
The sample application which demonstrates the duplicate exception problem

Dear Jaroslav, thank you for your quick response. The proposed patch is not meant as a solution, but as a workaround to avoid duplicate exception report dialog when starting a RCP application for TestNG functional testing.

Attached find a simple application which demonstrates the problem. It is the maven RCP application created by the Netbeans Maven Application wizard. The Junit functional test in the application module is replaced by it's TestNG equivalent created with the use of the TextNG Test Case wizard and extended with simple Jemmy code to demonstrate that functional tests are working. 

The NetbeansRuntimeContainer class proposed in the Bug 219939 is used to setup and tear down the tested RCP application. It is derived from the NbJunit module. Jellytools and Jemmy in combination with TestNG tests do not need to wrap the tests into the runtime container like in case of Junit tests. It is enough to run the application before the individual tests from the same class loader and stop it when all tests are finished. Everything works fine with one exception, bootstrap process of the tested application complains about dual loading of several modules. I think that this is caused by the classloader constructed by the maven surefire plugin (or better failsafe plugin for safe application shut down when tests fail - not implemented in the presented example) which causes conflicts for several core application modules.
Comment 3 František Mantlík 2013-07-24 10:57:52 UTC
Created attachment 137682 [details]
Patch to ignore duplicate exception (updated)

In the updated patch apichanges.xml and arch.xml were updated with corresponding documentation.

Module specification version was increased.
Comment 4 Jaroslav Tulach 2013-07-24 15:36:34 UTC
Sending for review. As far as I can tell, the patch looks good and I am ready to integrate it. Just I prefer use of Boolean.getBoolean("...."), so I will likely use that method.
Comment 5 Jaroslav Tulach 2013-07-31 08:58:48 UTC
changeset:   afee5adee91f
tag:         tip
user:        Jaroslav Tulach <jtulach@netbeans.org>
date:        Wed Jul 31 10:58:04 2013 +0200
summary:     #232229: A way to ignore duplicated module. Contributed by mantlik@netbeans.org - thanks.
Comment 6 Quality Engineering 2013-08-08 02:30:26 UTC
Integrated into 'main-silver', will be available in build *201308072300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/afee5adee91f
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #232229: A way to ignore duplicated module. Contributed by mantlik@netbeans.org - thanks.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo