Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 204060 - [publisher] absence of -publishArtifacts not honored properly
Summary: [publisher] absence of -publishArtifacts not honored properly
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Ian Bull CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 264389
  Show dependency tree
 
Reported: 2007-09-19 21:39 EDT by Pascal Rapicault CLA
Modified: 2009-02-24 22:46 EST (History)
2 users (show)

See Also:


Attachments
Patch (10.93 KB, patch)
2009-02-09 17:02 EST, Ian Bull CLA
no flags Details | Diff
Updated patch (9.19 KB, patch)
2009-02-18 15:47 EST, Ian Bull CLA
no flags Details | Diff
mylyn/context/zip (13.04 KB, application/octet-stream)
2009-02-18 15:47 EST, Ian Bull CLA
no flags Details
Updated patch (11.25 KB, patch)
2009-02-19 14:29 EST, Ian Bull CLA
jeffmcaffer: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Rapicault CLA 2007-09-19 21:39:51 EDT
When publishArtifacts is not on the command line and no artifact repository exists, the following exception occurs:
java.io.FileNotFoundException: d:\tmp\equinox.prov\servers\artifactRepository\artifacts.xml (The system cannot find the path specified)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(Unknown Source)
	at java.io.FileOutputStream.<init>(Unknown Source)
	at org.eclipse.equinox.internal.prov.artifact.repository.SimpleArtifactRepository.save(SimpleArtifactRepository.java:184)
	at org.eclipse.equinox.internal.prov.artifact.repository.SimpleArtifactRepository.addDescriptor(SimpleArtifactRepository.java:179)
	at org.eclipse.equinox.prov.metadata.generator.Generator.generateBundleIUs(Generator.java:214)
	at org.eclipse.equinox.prov.metadata.generator.Generator.generate(Generator.java:53)
	at org.eclipse.equinox.internal.prov.metadata.generator.EclipseGeneratorApplication.start(EclipseGeneratorApplication.java:87)
Comment 1 John Arthorne CLA 2007-10-30 16:08:26 EDT
You no longer get that exception, but you get a different exception saying that the artifact repository is invalid.  If -publishArtifacts is not specified, it should not complain if there is no artifact repository.  If -publishArtifacts is true, it's reasonable to throw an exception when initializing to say that the artifact repository is missing. Pushing to M4.
Comment 2 Pascal Rapicault CLA 2007-11-12 15:21:14 EST
I just got the initial exception again specifying -publishArtifacts.off on the command line.
Comment 3 Pascal Rapicault CLA 2008-09-08 21:11:03 EDT
Jeff, could you please confirm if this is still a problem?
Comment 4 Ian Bull CLA 2009-02-06 16:44:16 EST
You now get an NPE if you don't have an artifact repository listed.

Interestingly, if you have an artifact repo listed, but don't have publishArtifacts specified, you still get the artifacts.  I assume this is not the desired behaviour.

Although, do we really need the "publishArtifacts" flag?  Can we not just use the presence or absence of the artifactRepositoryflag for this? Maybe it is reasonable to list a artifactRepository without the expectation of publishing the artifacts.

Comment 5 Ian Bull CLA 2009-02-06 16:45:04 EST
Jeff,

I'm going to assign this to myself.  I hope that's ok.
Comment 6 Ian Bull CLA 2009-02-09 17:02:36 EST
Created attachment 125176 [details]
Patch

This patch fixes this problem.  I added an InvalidConfigurationException that can be thrown whenever an invalid configuration is detected (for example, calling -publishArtifacts, but not having an artifact repo).  This exception is caught in the AbstractionPublisherApplication#run method.  The exception will contain a proper i18n string that is displayed to the user.

ready for review.
Comment 7 Jeff McAffer CLA 2009-02-18 11:30:40 EST
comments on the patch:
- The addition of an exception seems heavy handed in this case.  can't we just call a validate method or something. or just use the ProvisionException.

- There are a few sysout.printlns in there.  They need to log I think.  not sure what we do in applications in general.

Comment 8 Ian Bull CLA 2009-02-18 12:08:05 EST
I introduced the exception because I expect other ConfigurationExceptions to occur. By using the exception we can detect the configuration problem at the lowest level, as opposed to trying to validate all the parameters up front.  I worried that if we try to validate up front, we may get into a nightmare of state management.

There are other uses of Sysout in AbstractPublisherApplication, I just followed that pattern.
Comment 9 Ian Bull CLA 2009-02-18 15:47:26 EST
Created attachment 126064 [details]
Updated patch

This patch uses a provisioning exception instead of introducing a new one.
Comment 10 Ian Bull CLA 2009-02-18 15:47:30 EST
Created attachment 126065 [details]
mylyn/context/zip
Comment 11 Jeff McAffer CLA 2009-02-18 21:08:59 EST
Thanks for the updated patch.  Some further comments.

- There is some very similar code in PublisherTask.  Does it need to be addressed?

- suggest stashing the status not the status.getMessage.  We have the status, pulling out the message and keeping that is throwing away information that someone might want. Change getErrorMessage to getStatus.  

- nit: avoid type-based names like provisionException.  "e" is the norm for exception vars
Comment 12 Ian Bull CLA 2009-02-19 14:29:38 EST
Created attachment 126206 [details]
Updated patch

This patch follows Jeff's suggestions:
1. I have added the same checks to the abstract publisher task
2. Stashed the status now (not just the message)
3. Changed the exception variable name to 'e'.

ready for review.
Comment 13 Jeff McAffer CLA 2009-02-24 22:46:29 EST
patch committed. Thanks.  closing.