Skip to content

Commit 172edd4

Browse files
authored
NPE in IdeProcessingEnvImpl.replacePlaceholdersUsing() if Map entry has no value #4640 (#4641)
#4641
1 parent 0f10d7c commit 172edd4

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

org.eclipse.jdt.apt.pluggable.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.core;singleton:=true
5-
Bundle-Version: 1.4.600.qualifier
5+
Bundle-Version: 1.4.700.qualifier
66
Bundle-Activator: org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin
77
Bundle-Vendor: %providerName
88
Require-Bundle: org.eclipse.core.runtime,

org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public Map<String, String> getOptions() {
102102

103103
private Function<Entry<String, String>, String> replacePlaceholdersUsing(Map<String, String> commandLineOptions) {
104104
return option -> {
105-
String variable, replacement, optionValue = option.getValue();
105+
String variable, replacement, optionValue = option.getValue() == null ? "" : option.getValue();
106106
Matcher placeholder = Pattern.compile("%([^%]+)%").matcher(optionValue);
107107
if (placeholder.find() && (variable = placeholder.group(1)) != null
108108
&& (replacement = commandLineOptions.get(variable)) != null) {

org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.tests;singleton:=true
5-
Bundle-Version: 3.6.800.qualifier
5+
Bundle-Version: 3.6.900.qualifier
66
Bundle-Activator: org.eclipse.jdt.apt.pluggable.tests.Apt6TestsPlugin
77
Bundle-Localization: plugin
88
Require-Bundle: org.junit,

org.eclipse.jdt.apt.pluggable.tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<relativePath>../tests-pom/</relativePath>
2020
</parent>
2121
<artifactId>org.eclipse.jdt.apt.pluggable.tests</artifactId>
22-
<version>3.6.800-SNAPSHOT</version>
22+
<version>3.6.900-SNAPSHOT</version>
2323
<packaging>eclipse-test-plugin</packaging>
2424
<properties>
2525
<testSuite>${project.artifactId}</testSuite>

org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/BuilderTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,25 @@ public void testBug341298() throws Throwable {
415415
fullBuild();
416416
assertTrue("Processor should be able to compile with passed options", Bug341298Processor.success());
417417
}
418+
public void testGHIssue4640() throws Throwable {
419+
ProcessorTestStatus.reset();
420+
IJavaProject project = createJavaProject(_projectName);
421+
IPath root = project.getProject().getFullPath().append("src");
422+
env.addClass(root, "test341298", "Annotated",
423+
"package test341298;\n" +
424+
"@Annotation public class Annotated {}"
425+
);
426+
env.addClass(root, "test341298", "Annotation",
427+
"package test341298;\n" +
428+
"public @interface Annotation {}"
429+
);
430+
AptConfig.addProcessorOption(project, "classpath", "%classpath%");
431+
AptConfig.addProcessorOption(project, "sourcepath", "%sourcepath%");
432+
AptConfig.addProcessorOption(project, "phase", null);
433+
AptConfig.setEnabled(project, true);
434+
fullBuild();
435+
assertTrue("Processor should be able to compile with passed options", Bug341298Processor.success());
436+
}
418437

419438
public void testBug539663() throws Throwable {
420439
if (!canRunJava9()) {

0 commit comments

Comments
 (0)