This is an automated email from the ASF dual-hosted git repository.
alien11689 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/aries.git
The following commit(s) were added to refs/heads/trunk by this push:
new 63708801e ARIES_2165: Build blueprint on java 11, 17, 21, 25 (#785)
63708801e is described below
commit 63708801e74635f6af4ef0c7761267d8e9fa6a94
Author: Dominik Przybysz <[email protected]>
AuthorDate: Sat Nov 7 19:45:40 2026 +0100
ARIES_2165: Build blueprint on java 11, 17, 21, 25 (#785)
---
.github/workflows/blueprint.yml | 2 +-
.../impl/AuthorizationInterceptor.java | 27 +++++++++++++--
blueprint/blueprint-bundle/pom.xml | 1 -
blueprint/blueprint-core/pom.xml | 1 -
.../namespace/NamespaceHandlerRegistryImpl.java | 40 ++++++++++++----------
blueprint/itests/blueprint-itests/pom.xml | 6 ++++
.../aries/blueprint/itests/SpringExtenderTest.java | 2 ++
.../apache/aries/blueprint/itests/SpringTest.java | 2 ++
8 files changed, 57 insertions(+), 24 deletions(-)
diff --git a/.github/workflows/blueprint.yml b/.github/workflows/blueprint.yml
index 9d95d99ba..06a2122e0 100644
--- a/.github/workflows/blueprint.yml
+++ b/.github/workflows/blueprint.yml
@@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- java: [ 8 ]
+ java: [ 8, 11, 17, 21, 25 ]
os: [ ubuntu-latest ]
name: JDK${{ matrix.java }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
diff --git
a/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/AuthorizationInterceptor.java
b/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/AuthorizationInterceptor.java
index 9d9e5c3ae..a337c8dfb 100644
---
a/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/AuthorizationInterceptor.java
+++
b/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/AuthorizationInterceptor.java
@@ -19,6 +19,7 @@
package org.apache.aries.blueprint.authorization.impl;
import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessControlContext;
import java.security.AccessControlException;
@@ -38,6 +39,29 @@ import org.slf4j.LoggerFactory;
public class AuthorizationInterceptor implements Interceptor {
private static final Logger LOGGER =
LoggerFactory.getLogger(AuthorizationInterceptor.class);
+
+ // Subject.current() is available since Java 18, and Subject.getSubject()
is not supported anymore since Java 23
+ private static final Method SUBJECT_CURRENT = findSubjectCurrent();
+
+ private static Method findSubjectCurrent() {
+ try {
+ return Subject.class.getMethod("current");
+ } catch (NoSuchMethodException e) {
+ return null;
+ }
+ }
+
+ private static Subject getCurrentSubject() {
+ if (SUBJECT_CURRENT != null) {
+ try {
+ return (Subject) SUBJECT_CURRENT.invoke(null);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new IllegalStateException("Unable to get the current
JAAS subject", e);
+ }
+ }
+ AccessControlContext acc = AccessController.getContext();
+ return Subject.getSubject(acc);
+ }
private Class<?> beanClass;
public AuthorizationInterceptor(Class<?> beanClass) {
@@ -65,8 +89,7 @@ public class AuthorizationInterceptor implements Interceptor {
rolesAr = ((RolesAllowed) ann).value();
}
Set<String> roles = new HashSet<String>(Arrays.asList(rolesAr));
- AccessControlContext acc = AccessController.getContext();
- Subject subject = Subject.getSubject(acc);
+ Subject subject = getCurrentSubject();
if (subject == null) {
throw new AccessControlException("Method call " +
m.getDeclaringClass() + "." + m.getName() + " denied. No JAAS login present");
}
diff --git a/blueprint/blueprint-bundle/pom.xml
b/blueprint/blueprint-bundle/pom.xml
index ce877f935..0a8440467 100644
--- a/blueprint/blueprint-bundle/pom.xml
+++ b/blueprint/blueprint-bundle/pom.xml
@@ -111,7 +111,6 @@
<org.apache.aries.proxy.api.version>1.1.2</org.apache.aries.proxy.api.version>
<org.apache.aries.proxy.version>2.0.0</org.apache.aries.proxy.version>
<org.apache.aries.quiesce.api.version>1.0.1</org.apache.aries.quiesce.api.version>
-
<org.apache.aries.versioning.plugin.version>0.3.1</org.apache.aries.versioning.plugin.version>
<osgi.cmpn.version>4.3.1</osgi.cmpn.version>
<slf4j.version>2.0.20</slf4j.version>
</properties>
diff --git a/blueprint/blueprint-core/pom.xml b/blueprint/blueprint-core/pom.xml
index 5741a84fb..17efc731e 100644
--- a/blueprint/blueprint-core/pom.xml
+++ b/blueprint/blueprint-core/pom.xml
@@ -100,7 +100,6 @@
<easymock.version>5.7.0</easymock.version>
<maven-release-plugin.version>3.3.1</maven-release-plugin.version>
<org.apache.aries.quiesce.api.version>1.0.1</org.apache.aries.quiesce.api.version>
-
<org.apache.aries.versioning.plugin.version>0.3.1</org.apache.aries.versioning.plugin.version>
<org.apache.felix.utils.version>1.11.10</org.apache.felix.utils.version>
<osgi.cmpn.version>4.3.1</osgi.cmpn.version>
<osgi.core.version>4.3.1</osgi.core.version>
diff --git
a/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
b/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
index bfb2d9969..a404db475 100644
---
a/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
+++
b/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
@@ -474,6 +474,7 @@ public class NamespaceHandlerRegistryImpl implements
NamespaceHandlerRegistry, S
final List<StreamSource> sources = new ArrayList<StreamSource>();
final Map<String, URL> loaded = new HashMap<String, URL>();
final Map<String, String> namespaces = new HashMap<String,
String>();
+ final Map<String, URL> urls = new HashMap<String, URL>();
@Override
public LSInput resolveResource(String type, String namespaceURI,
String publicId, String systemId, String baseURI) {
// Compute id
@@ -514,15 +515,9 @@ public class NamespaceHandlerRegistryImpl implements
NamespaceHandlerRegistry, S
//---------------
// For relative uris, don't use the namespace handlers, but
simply resolve the uri
// and use that one directly to load the resource.
- String resolved = resolveIfRelative(systemId, baseURI);
- if (resolved != null) {
- URL url;
- try {
- url = new URL(resolved);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return createLSInput(url, id, namespaceURI);
+ URL resolvedUrl = resolveIfRelative(systemId, baseURI);
+ if (resolvedUrl != null) {
+ return createLSInput(resolvedUrl, id, namespaceURI);
}
// Only support xml schemas from now on
if (namespaceURI == null ||
!W3C_XML_SCHEMA_NS_URI.equals(type)) {
@@ -576,6 +571,7 @@ public class NamespaceHandlerRegistryImpl implements
NamespaceHandlerRegistry, S
sources.add(ss);
loaded.put(id, resource);
namespaces.put(url, namespace);
+ urls.put(url, resource);
return ss;
}
@@ -593,20 +589,26 @@ public class NamespaceHandlerRegistryImpl implements
NamespaceHandlerRegistry, S
private boolean isCorrectUrl(URL url) {
return url != null && !loaded.values().contains(url);
}
- private String resolveIfRelative(String systemId, String baseURI) {
+ private URL resolveIfRelative(String systemId, String baseURI) {
if (baseURI != null && systemId != null) {
URI sId = URI.create(systemId);
if (!sId.isAbsolute()) {
- URI resolved = URI.create(baseURI).resolve(sId);
- if (resolved.isAbsolute()) {
- return resolved.toString();
- } else {
- try {
- return new URL(new URL(baseURI),
systemId).toString();
- } catch (MalformedURLException e) {
- LOGGER.warn("Can't resolve " + systemId + "
against " + baseURI);
- return null;
+ try {
+ URL base = urls.get(baseURI);
+ if (base != null) {
+ // Resolve against the URL object that was
handed out in the first place: creating
+ // it again from its string form may pick the
stream handler of another framework
+ // instance running in the same JVM, which
can't find the resource
+ return new URL(base, systemId);
+ }
+ URI resolved = URI.create(baseURI).resolve(sId);
+ if (resolved.isAbsolute()) {
+ return new URL(resolved.toString());
}
+ return new URL(new URL(baseURI), systemId);
+ } catch (MalformedURLException e) {
+ LOGGER.warn("Can't resolve " + systemId + "
against " + baseURI);
+ return null;
}
}
}
diff --git a/blueprint/itests/blueprint-itests/pom.xml
b/blueprint/itests/blueprint-itests/pom.xml
index ce7630ef4..3f00e3eed 100644
--- a/blueprint/itests/blueprint-itests/pom.xml
+++ b/blueprint/itests/blueprint-itests/pom.xml
@@ -56,6 +56,7 @@
<blueprint.sample.version>1.0.1-SNAPSHOT</blueprint.sample.version>
<commons-jexl.version>2.1.1</commons-jexl.version>
<depends-maven-plugin.version>1.5.0</depends-maven-plugin.version>
+ <javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<maven-surefire-plugin.version>3.6.1</maven-surefire-plugin.version>
<objenesis.version>3.6</objenesis.version>
<org.apache.aries.proxy.version>2.0.1-SNAPSHOT</org.apache.aries.proxy.version>
@@ -115,6 +116,11 @@
<version>${objenesis.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>${javax.annotation-api.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.spring-context</artifactId>
diff --git
a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringExtenderTest.java
b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringExtenderTest.java
index f10f48f26..56c954ce8 100644
---
a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringExtenderTest.java
+++
b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringExtenderTest.java
@@ -61,6 +61,8 @@ public class SpringExtenderTest extends
AbstractBlueprintIntegrationTest {
mvnBundle("org.apache.aries.blueprint",
"org.apache.aries.blueprint.spring"),
mvnBundle("org.apache.aries.blueprint",
"org.apache.aries.blueprint.spring.extender"),
// Spring
+ // javax.annotation is not provided by the JDK since Java 11
+ mvnBundle("javax.annotation", "javax.annotation-api"),
mvnBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.aopalliance"),
mvnBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.spring-core"),
mvnBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.spring-context"),
diff --git
a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
index 6ed5d6e20..061d97dce 100644
---
a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
+++
b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
@@ -64,6 +64,8 @@ public class SpringTest extends
AbstractBlueprintIntegrationTest {
// Blueprint spring
mvnBundle("org.apache.aries.blueprint",
"org.apache.aries.blueprint.spring"),
// Spring
+ // javax.annotation is not provided by the JDK since Java 11
+ mvnBundle("javax.annotation", "javax.annotation-api"),
mvnBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.aopalliance"),
mvnBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.spring-core"),
mvnBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.spring-context"),