Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2021-03-16 13:15:12 +0000
committerThomas Watson2021-03-16 13:41:03 +0000
commit480fff1c579af9243d7a24d02ff111596ea027bc (patch)
treec3479898a3a8ae5ef6c389382caa59393e00e726
parent2c87374a21099c4bea7a895fbfe4e4a2dcc6a18a (diff)
downloadrt.equinox.framework-I20210319-1800.tar.gz
rt.equinox.framework-I20210319-1800.tar.xz
rt.equinox.framework-I20210319-1800.zip
Must use Optional.orElse instead of Optional.orElseGet to return null. The orElseGet expects a function and the function must not be null. Change-Id: Id45654e6b97ce629dcdcdf16919f79f682050d81 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.osgi.tests/pom.xml2
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java22
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java4
4 files changed, 26 insertions, 4 deletions
diff --git a/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
index 3a0941068..8a7e34d72 100644
--- a/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Core OSGi Tests
Bundle-SymbolicName: org.eclipse.osgi.tests;singleton:=true
-Bundle-Version: 3.16.200.qualifier
+Bundle-Version: 3.16.300.qualifier
Bundle-Vendor: Eclipse.org
Require-Bundle:
org.eclipse.core.runtime,
diff --git a/bundles/org.eclipse.osgi.tests/pom.xml b/bundles/org.eclipse.osgi.tests/pom.xml
index 4e80d6f16..cae735161 100644
--- a/bundles/org.eclipse.osgi.tests/pom.xml
+++ b/bundles/org.eclipse.osgi.tests/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.tests</artifactId>
- <version>3.16.200-SNAPSHOT</version>
+ <version>3.16.300-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index 516f80c41..793aa056f 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -1744,6 +1744,28 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
global.loadClass("test.bug438904.frag.Test2");
}
+ public void testBuddyClassLoadingGlobalNotFound() throws Exception {
+ Bundle global = installer.installBundle("test.bug438904.global");
+
+ try {
+ global.loadClass("does.not.exist.Test");
+ fail("Expected class not found exception.");
+ } catch (ClassNotFoundException e) {
+ // expected
+ }
+ assertNull("Expected null resource found.", global.getResource("does/not/exist/Test.txt"));
+ }
+
+ public void testBuddyClassLoadingGlobalFound() throws Exception {
+ Bundle global = installer.installBundle("test.bug438904.global");
+
+ try {
+ global.loadClass("org.osgi.framework.Bundle");
+ } catch (ClassNotFoundException e) {
+ fail("Unexpected class not found exception.");
+ }
+ }
+
public void testUnitTestForcompoundEnumerations() {
Enumeration<Object> result = BundleLoader.compoundEnumerations(null, Collections.emptyEnumeration());
assertNotNull("Null result.", result);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java
index ac0a44670..d01648744 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java
@@ -55,7 +55,7 @@ public class GlobalPolicy implements IBuddyPolicy {
} catch (ClassNotFoundException e) {
return null;
}
- }).orElseGet(null);
+ }).orElse(null);
}
@Override
@@ -63,7 +63,7 @@ public class GlobalPolicy implements IBuddyPolicy {
return getExportingBundles(BundleLoader.getResourcePackageName(name)) //
.stream().findFirst().map(b -> {
return b.getResource(name);
- }).orElseGet(null);
+ }).orElse(null);
}
@Override

Back to the top