Bug 419759 - NPE when exporting product containing a license feature
Do not try to replace license text with a null license text coming from
the license feature. Also, do not replace non-empty license URL with
empty URL. This makes it consistent with the Tycho behavior.
Change-Id: I8fc5023c21603eb814efeb3ba56d38e4d5179dbe
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java
index 32ea2f5..fa20f24 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Marc-Andre Laperle (Ericsson) - Fix NPE (Bug 419759)
*******************************************************************************/
package org.eclipse.pde.internal.build.tasks;
@@ -76,8 +77,10 @@
if (startLicenseText > 0 && endLicenseText > startLicenseText) {
// Replace license text
- buffer.replace(startLicenseText, endLicenseText, licenseText);
- contentChanged = true;
+ if (licenseText != null) {
+ buffer.replace(startLicenseText, endLicenseText, licenseText);
+ contentChanged = true;
+ }
} else if (insertionPoint > -1) {
//insert new license after <feature>
StringBuffer newLicense = new StringBuffer();
@@ -86,7 +89,8 @@
if (licenseURL != null)
newLicense.append(licenseURL);
newLicense.append(" >"); //$NON-NLS-1$
- newLicense.append(licenseText);
+ if (licenseText != null)
+ newLicense.append(licenseText);
newLicense.append(LICENSE_END_TAG);
buffer.insert(insertionPoint, newLicense.toString());
@@ -109,7 +113,7 @@
// Replace non-empty payload URL
if (licenseURL == null) {
// with empty license URL
- buffer.replace(startURLWord, endURLText + 1, ""); //$NON-NLS-1$
+ // No-op
} else {
// with non-empty license URL
buffer.replace(startURLText, endURLText + 1, licenseURL);