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 251987 - IllegalArgumentException: number of workunits cannot be negative
Summary: IllegalArgumentException: number of workunits cannot be negative
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P1 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-22 12:56 UTC by emelyanov
Modified: 2015-08-31 15:30 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emelyanov 2015-04-22 12:56:18 UTC
I'm trying to update remote maven repository.
File nexus-maven-repository-index.gz has Content-Length: 2787423206 (LONG! not INT)
Bug is detected in the Netbeans 7.4 and 8.0.2
Comment 1 emelyanov 2015-04-22 12:58:41 UTC
Stack trace
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.netbeans.modules.maven.repository.RepositoryNode$RefreshIndexAction$1
java.lang.IllegalArgumentException: number of workunits cannot be negative
	at org.netbeans.modules.progress.spi.InternalHandle.toDeterminate(InternalHandle.java:193)
	at org.netbeans.api.progress.ProgressHandle.switchToDeterminate(ProgressHandle.java:134)
	at org.netbeans.modules.maven.indexer.RemoteIndexTransferListener.transferStarted(RemoteIndexTransferListener.java:105)
	at org.apache.maven.wagon.events.TransferEventSupport.fireTransferStarted(TransferEventSupport.java:104)
	at org.apache.maven.wagon.AbstractWagon.fireGetStarted(AbstractWagon.java:543)
	at org.apache.maven.wagon.AbstractWagon.getTransfer(AbstractWagon.java:306)
	at org.apache.maven.wagon.AbstractWagon.getTransfer(AbstractWagon.java:287)
	at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:97)
	at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
	at org.apache.maven.index.updater.WagonHelper$WagonFetcher.retrieve(WagonHelper.java:219)
	at org.apache.maven.index.updater.WagonHelper$WagonFetcher.retrieve(WagonHelper.java:201)
	at org.apache.maven.index.updater.DefaultIndexUpdater.loadIndexDirectory(DefaultIndexUpdater.java:191)
	at org.apache.maven.index.updater.DefaultIndexUpdater.access$300(DefaultIndexUpdater.java:76)
	at org.apache.maven.index.updater.DefaultIndexUpdater$LuceneIndexAdaptor.setIndexFile(DefaultIndexUpdater.java:642)
	at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:862)
	at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:157)
	at org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl.indexLoadedRepo(NexusRepositoryIndexerImpl.java:452)
	at org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl.access$200(NexusRepositoryIndexerImpl.java:113)
	at org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl$3.run(NexusRepositoryIndexerImpl.java:519)
	at org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl$3.run(NexusRepositoryIndexerImpl.java:513)
	at org.openide.util.Mutex.writeAccess(Mutex.java:404)
	at org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl.indexRepo(NexusRepositoryIndexerImpl.java:513)
	at org.netbeans.modules.maven.indexer.api.RepositoryIndexer.indexRepo(RepositoryIndexer.java:58)
	at org.netbeans.modules.maven.repository.RepositoryNode$RefreshIndexAction$1.run(RepositoryNode.java:241)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2042)
Comment 2 emelyanov 2015-04-22 13:07:18 UTC
class org.netbeans.modules.maven.indexer.RemoteIndexTransferListener:

	public void transferStarted(TransferEvent arg0) {
         long contentLength = arg0.getResource().getContentLength();
         this.handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(RemoteIndexTransferListener.class, "LBL_Transfer_TAG")//NII18N
                 + info.getName());
         handle.start((int) contentLength / 1024);
         if (debug) {
             writer.println("File Size :" + (int) contentLength / 1024);//NII18N
 
         }
     }

Error in string: "handle.start((int) contentLength / 1024);" - contentLength convert to int!!!
Comment 3 Tomas Stupka 2015-04-30 15:57:52 UTC
fixed in jet-main #77a7279dfbea
Comment 4 Quality Engineering 2015-05-01 02:54:14 UTC
Integrated into 'main-silver', will be available in build *201505010001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/77a7279dfbea
User: Tomas Stupka <tstupka@netbeans.org>
Log: Issue #251987 - IllegalArgumentException: number of workunits cannot be negative
Comment 5 cbourque 2015-08-27 22:56:56 UTC
The bug is still there in NetBeans IDE 8.1 Beta (Build 201508041349)!

INFO [org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl]: could not (re-)index main java.io.EOFException: Unexpected end of ZLIB input stream

The downloaded index has a size of 2147483647 bytes (Integer.MAX_VALUE) when in fact the real archive is 2949372869 bytes!
Comment 6 psilvaggio 2015-08-28 03:39:05 UTC
Confirming Dr. cbourque issue with this fact:

maven.indexer depends on ext/indexer-core-5.1.1-patched.jar

which depends on maven-wagon 2.3

Tracing calls shows that we end up calling getTransfer( resource, stream, is, true, Integer.MAX_VALUE ).

I don't know about you, but that's bad.

I suggest overriding maven-wagon to a more recent version, i.e.: 2.9 which should be backward compatible!?
Comment 7 psilvaggio 2015-08-28 03:45:59 UTC
BTW, I just noticed it's maven-wagon 2.4 not 2.3 (must be the repack...).
Comment 8 Tomas Stupka 2015-08-31 13:36:14 UTC
> The bug is still there in NetBeans IDE 8.1 Beta (Build 201508041349)!
no, the originally reported problem in this issue was about wrong handling of long Resource.getContentLength() in the nb code base and was fixed.

filed #254873 to cover the getTransfer(..., Integer.MAX_VALUE) issue in the bundled http wagon 2.4
Comment 9 cbourque 2015-08-31 15:30:20 UTC
Cool thanks!