Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pr-builder.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build the project on pull requests with tests
# Uses:
# OS: ubuntu-latest
# JDK: Adopt JDK 11
# JDK: Adopt JDK 21

name: PR Builder

Expand All @@ -24,10 +24,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Adopt JDK 11
- name: Set up Adopt JDK 21
uses: actions/setup-java@v2
with:
java-version: "11"
java-version: "21"
distribution: "adopt"
- name: Cache local Maven repository
id: cache-maven-m2
Expand Down
28 changes: 16 additions & 12 deletions core/feature-manager/org.wso2.carbon.feature.mgt.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId>
<exclusions>
<exclusion>
<groupId>org.wso2.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</exclusion>
<exclusion>
Expand All @@ -68,7 +68,7 @@
<artifactId>org.eclipse.equinox.http.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.jsp.jasper</artifactId>
</exclusion>
<exclusion>
Expand All @@ -90,39 +90,39 @@
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.director</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata.repository</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.repository</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.simpleconfigurator</artifactId>
</dependency>
<dependency>
Expand Down Expand Up @@ -162,6 +162,10 @@
<Export-Package>
org.wso2.carbon.feature.mgt.core.*
</Export-Package>
<!-- TODO this is wrong. Just trying out -->
<Provide-Capability>
osgi.service;objectClass=org.eclipse.equinox.p2.core.IProvisioningAgentProvider
</Provide-Capability>
</instructions>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@
<artifactId>org.wso2.carbon.feature.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.repository</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions core/feature-manager/org.wso2.carbon.p2.touchpoint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

<dependencies>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
</dependency>
</dependencies>
Expand Down
10 changes: 0 additions & 10 deletions core/javax.cache/src/main/java/javax/cache/CacheManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

package javax.cache;

import javax.transaction.UserTransaction;

/**
* A CacheManager is used for looking up Caches and controls their lifecycle. It represents a collection of caches.
* <p/>
Expand Down Expand Up @@ -127,14 +125,6 @@ public interface CacheManager {
*/
boolean removeCache(String cacheName);

/**
* This method will return a UserTransaction.
*
* @return the UserTransaction.
* @throws UnsupportedOperationException if JTA is not supported
*/
UserTransaction getUserTransaction();

/**
* Indicates whether a optional feature is supported by this CacheManager.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
*/
package org.wso2.carbon.caching.impl;

import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;

import javax.cache.Cache;
import javax.cache.CacheBuilder;
import javax.cache.CacheException;
import javax.cache.CacheManager;
import javax.cache.OptionalFeature;
import javax.cache.Status;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.cache.Cache;
import javax.cache.CacheBuilder;
import javax.cache.CacheException;
import javax.cache.CacheManager;
import javax.cache.OptionalFeature;
import javax.cache.Status;

import static org.wso2.carbon.caching.impl.CachingConstants.ILLEGAL_STATE_EXCEPTION_MESSAGE;

/**
Expand Down Expand Up @@ -202,14 +203,6 @@ boolean removeLocalCaches() {
return this.caches.isEmpty();
}

@Override
public javax.transaction.UserTransaction getUserTransaction() {
Util.checkAccess(ownerTenantDomain, ownerTenantId);
checkStatusStarted();
touch();
return null; //To change body of implemented methods use File | Settings | File Templates.
}

@Override
public boolean isSupported(OptionalFeature optionalFeature) {
Util.checkAccess(ownerTenantDomain, ownerTenantId);
Expand Down
2 changes: 1 addition & 1 deletion core/org.wso2.carbon.application.deployer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
Expand Down
14 changes: 12 additions & 2 deletions core/org.wso2.carbon.base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>

<extensions>true</extensions>
<configuration>
<instructions>
Expand All @@ -48,7 +47,7 @@
org.wso2.carbon.base.*; version="1.0.0"
</Export-Package>
<Import-Package>
javax.activation.*;version="[0.0.0, 1.0.0)",
javax.activation.*;version="[0.0.0, 1.0.0)";resolution:=optional,
javax.servlet; version="${imp.pkg.version.javax.servlet}",
javax.servlet.http; version="${imp.pkg.version.javax.servlet}",
org.wso2.securevault.*,
Expand All @@ -59,6 +58,9 @@
<Import-Package>
*;resolution:=optional
</Import-Package>
<Provide-Capability>
osgi.service;objectClass=org.wso2.carbon.base.api.ServerConfigurationService
</Provide-Capability>
</instructions>
</configuration>
</plugin>
Expand All @@ -67,12 +69,19 @@
<artifactId>maven-surefire-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<argLine>
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
</argLine>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.wso2.org.ops4j.pax.logging:pax-logging-api</classpathDependencyExclude>
</classpathDependencyExcludes>
<systemPropertyVariables>
<java.util.logging.manager>org.apache.logging.log4j.jul.LogManager</java.util.logging.manager>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -118,6 +127,7 @@
<groupId>org.eclipse.equinox</groupId>
<artifactId>javax.servlet</artifactId>
</dependency>

<dependency>
<groupId>org.wso2.orbit.xerces</groupId>
<artifactId>xercesImpl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wso2.carbon.base.api;

import org.osgi.service.component.annotations.Component;
import org.w3c.dom.Element;

import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.wso2.carbon.base.CarbonBaseConstants;
import org.wso2.carbon.base.CarbonBaseUtils;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.base.ServerConfigurationException;
import org.wso2.carbon.base.api.ServerConfigurationService;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletException;
import java.io.*;

/**
* Activator of the {@link org.wso2.carbon.base} bundle
Expand All @@ -52,7 +55,6 @@ public void start(BundleContext bundleContext) throws Exception {
System.setProperty("portOffset", portOffset);
//register carbon server confg as an OSGi service
registration = bundleContext.registerService(ServerConfigurationService.class.getName(), carbonServerConfiguration, null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log Improvement Suggestion No: 3

Suggested change
registration = bundleContext.registerService(ServerConfigurationService.class.getName(), carbonServerConfiguration, null);
registration = bundleContext.registerService(ServerConfigurationService.class.getName(), carbonServerConfiguration, null);
log.info("Carbon server configuration service registered successfully");


}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ public class CarbonBaseUtilsTest {
private static final String COLLECTIONS_UNMODIFIABLE_MAP = "java.util.Collections$UnmodifiableMap";
private static final String FIELD_M = "m";

@BeforeClass
public void setSecurityManager() {
URL resourceURL = CarbonBaseUtilsTest.class.getClassLoader().getResource("");
if (resourceURL != null) {
String resourcePath = resourceURL.getPath();
resourcePath = resourcePath + "policy-test.policy";
System.setProperty("java.security.policy", resourcePath);
System.setSecurityManager(new SecurityManager());
}
}

@AfterClass
public void clearSecurityManager() {
System.clearProperty("java.security.policy");
}

@Test(groups = {"org.wso2.carbon.base"})
public void testGetCarbonConfigDirPath() throws ClassNotFoundException, IllegalAccessException,
NoSuchFieldException {
Expand All @@ -82,24 +66,6 @@ public void testGetCarbonHome() {
assertEquals(CarbonBaseUtils.getCarbonHome(), "/wso2am-2.1.0", "Must provide the carbon home ");
}

@Test(groups = {"org.wso2.carbon.base"})
public void testCheckSecurityWithClasses() {
List<String> allowedClasses = Arrays.asList("org.junit.runners.model.FrameworkMethod$1.runReflectiveCall",
"org.wso2.carbon.base.CarbonBaseUtils.checkSecurity", "org.junit.internal.runners.statements" +
".InvokeMethod.evaluate", "org.junit.runner.JUnitCore.run", "org.junit.runners.ParentRunner.run");
CarbonBaseUtils.checkSecurity(allowedClasses);
}

@Test(groups = {"org.wso2.carbon.base"})
public void testCheckSecurityWithMethods() {
Map<String, String> allowedMethods = new HashMap<>();
allowedMethods.put("sun.reflect.NativeMethodAccessorImpl", "invoke");
allowedMethods.put("sun.reflect.DelegatingMethodAccessorImpl", "invoke");
allowedMethods.put("java.lang.reflect.Method", "invoke");
allowedMethods.put("org.junit.internal.runners.statements.InvokeMethod", "evaluate");
CarbonBaseUtils.checkSecurity(allowedMethods);
}

/**
* Sets environment variable for a given key and value.
*
Expand All @@ -126,19 +92,6 @@ private void setEnvironmentVariables(Map<String, String> newVariables) throws Il
setEnvVariables(newEnv);
}

/**
* Unsets environment variable for a given key.
*
* @param key Environment variable key.
*/
private void unsetEnvironmentVariables(String key) throws IllegalAccessException, NoSuchFieldException,
ClassNotFoundException {
Map<String, String> newEnv = new HashMap<>();
newEnv.putAll(System.getenv());
newEnv.remove(key);
setEnvVariables(newEnv);
}

/**
* Sets environment variable from given map.
*
Expand Down
Loading