Skip to content

migrate java8 to java11 #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
displayName: 'Install NuGet Tool'
- pwsh: |
Get-Command mvn
mvn -version
displayName: 'Check Maven is installed'
- task: JavaToolInstaller@0 # This step is necessary as Linux image has Java 11 as default
inputs:
Expand All @@ -149,7 +150,7 @@ jobs:
curl -sSL https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh | bash /dev/stdin -v '6.0.100-rc.2.21505.57' -c 'release' --install-dir /usr/share/dotnet
displayName: 'Install the .Net version used by the Core Tools for Linux'
condition: eq( variables['Agent.OS'], 'Linux' )
- pwsh: | # Download JDK for later installation
- pwsh: | # Download JDK for later installation
Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -O "$(JAVA_VERSION).tar.gz"
$current = get-location | select -ExpandProperty Path
Write-Host "##vso[task.setvariable variable=downloadPath;]$current"
Expand Down
4 changes: 4 additions & 0 deletions package-pipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Write-Host "Building azure-functions-java-worker"
mvn clean package --no-transfer-progress -B
StopOnFailedExecution

Write-Host "Running Integration tests of azure-functions-java-worker"
mvn failsafe:integration-test --no-transfer-progress -B
StopOnFailedExecution

Write-Host "Creating nuget package Microsoft.Azure.Functions.JavaWorker"
Write-Host "buildNumber: " $buildNumber
Get-Command nuget
Expand Down
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,23 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<systemPropertyVariables>
<testing-project-jar>${project.artifactId}-${project.version}-tests.jar</testing-project-jar>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- This plugin is used to generated test jar which contains all test classes -->
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public JavaWorkerClient(IApplication app) {
this.channel = chanBuilder.build();
this.peer = new AtomicReference<>(null);
this.handlerSuppliers = new HashMap<>();
this.classPathProvider = new FactoryClassLoader().createClassLoaderProvider();
this.classPathProvider = new FunctionClassLoaderProvider();

this.addHandlers();
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* Used to executor of arbitrary Java method in any JAR using reflection.
* Thread-Safety: Multiple thread.
*/
public class EnhancedJavaMethodExecutorImpl implements JavaMethodExecutor {
public EnhancedJavaMethodExecutorImpl(FunctionMethodDescriptor descriptor, Map<String, BindingInfo> bindingInfos, ClassLoaderProvider classLoaderProvider)
public class FunctionMethodExecutorImpl implements JavaMethodExecutor {
public FunctionMethodExecutorImpl(FunctionMethodDescriptor descriptor, Map<String, BindingInfo> bindingInfos, ClassLoaderProvider classLoaderProvider)
throws ClassNotFoundException, NoSuchMethodException
{
descriptor.validateMethodInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import com.microsoft.azure.functions.rpc.messages.*;
import com.microsoft.azure.functions.worker.Constants;
import com.microsoft.azure.functions.worker.WorkerLogManager;
import com.microsoft.azure.functions.worker.binding.BindingDataStore;
import com.microsoft.azure.functions.worker.binding.ExecutionRetryContext;
import com.microsoft.azure.functions.worker.binding.ExecutionTraceContext;
Expand All @@ -35,7 +34,7 @@ public void loadMethod(FunctionMethodDescriptor descriptor, Map<String, BindingI
descriptor.validate();

addSearchPathsToClassLoader(descriptor);
JavaMethodExecutor executor = new FactoryJavaMethodExecutor().getJavaMethodExecutor(descriptor, bindings, classLoaderProvider);
JavaMethodExecutor executor = new FunctionMethodExecutorImpl(descriptor, bindings, classLoaderProvider);

this.methods.put(descriptor.getId(), new ImmutablePair<>(descriptor.getName(), executor));
}
Expand Down Expand Up @@ -148,22 +147,6 @@ private boolean isTesting(){
}
}

void verifyLibrariesExist (File workerLib, String workerLibPath) throws FileNotFoundException{
if(!workerLib.exists()) {
throw new FileNotFoundException("Error loading worker jars, from path: " + workerLibPath);
} else {
File[] jarFiles = workerLib.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.isFile() && file.getName().endsWith(".jar");
}
});
if(jarFiles.length == 0) {
throw new FileNotFoundException("Error loading worker jars, from path: " + workerLibPath + ". Jars size is zero");
}
}
}

public void setWorkerDirectory(String workerDirectory) {
this.workerDirectory = workerDirectory;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import com.microsoft.azure.functions.worker.*;
import com.microsoft.azure.functions.worker.broker.*;
import com.microsoft.azure.functions.rpc.messages.*;

import static com.microsoft.azure.functions.worker.Util.getJavaVersion;
import com.microsoft.azure.functions.worker.util.Util;

public class InvocationRequestHandler extends MessageHandler<InvocationRequest, InvocationResponse.Builder> {
public InvocationRequestHandler(JavaFunctionBroker broker) {
Expand All @@ -25,7 +24,7 @@ public InvocationRequestHandler(JavaFunctionBroker broker) {

@Override
String execute(InvocationRequest request, InvocationResponse.Builder response) throws Exception {
WorkerLogManager.getSystemLogger().log(Level.INFO, "Java version - " + getJavaVersion());
WorkerLogManager.getSystemLogger().log(Level.INFO, "Java version - " + Util.getJavaVersion());
WorkerLogManager.getSystemLogger().log(Level.INFO, "InvocationRequest received by the Java worker");
final String functionId = request.getFunctionId();
final String invocationId = request.getInvocationId();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import com.microsoft.azure.functions.worker.*;

public class EnhancedClassLoaderProvider implements ClassLoaderProvider {
public EnhancedClassLoaderProvider() {
public class FunctionClassLoaderProvider implements ClassLoaderProvider {
public FunctionClassLoaderProvider() {
customerUrls = Collections.newSetFromMap(new ConcurrentHashMap<URL, Boolean>());
workerUrls = Collections.newSetFromMap(new ConcurrentHashMap<URL, Boolean>());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.azure.functions.worker;
package com.microsoft.azure.functions.worker.util;

public class Util {
public static boolean isTrue(String value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.microsoft.azure.functions.worker.test;
package com.microsoft.azure.functions.worker.binding;

import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import com.microsoft.azure.functions.TraceContext;
import com.microsoft.azure.functions.worker.binding.ExecutionTraceContext;

import org.junit.Test;

public class ExecutionTraceContextTests {
public class ExecutionTraceContextTest {

@Test
public void TraceContext_test_getAndset_nonEmpty() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.azure.functions.worker.binding.tests;
package com.microsoft.azure.functions.worker.binding;

import static org.junit.Assert.assertEquals;

Expand All @@ -9,10 +9,8 @@
import org.junit.Test;

import com.google.protobuf.ByteString;
import com.microsoft.azure.functions.worker.binding.BindingData;
import com.microsoft.azure.functions.worker.binding.RpcByteArrayDataSource;

public class RpcByteArrayDataSourceTests {
public class RpcByteArrayDataSourceTest {

@Test
public void rpcByteArrayDataSource_To_byteArray() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.azure.functions.worker.binding.tests;
package com.microsoft.azure.functions.worker.binding;

import com.google.protobuf.ByteString;
import com.microsoft.azure.functions.worker.binding.BindingData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package com.microsoft.azure.functions.worker.binding.tests;
package com.microsoft.azure.functions.worker.binding;

import com.microsoft.azure.functions.rpc.messages.CollectionDouble;
import com.microsoft.azure.functions.worker.binding.BindingData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.azure.functions.worker.binding.tests;
package com.microsoft.azure.functions.worker.binding;

import com.microsoft.azure.functions.rpc.messages.CollectionSInt64;
import com.microsoft.azure.functions.rpc.messages.CollectionSInt64.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.azure.functions.worker.binding.tests;
package com.microsoft.azure.functions.worker.binding;

import com.microsoft.azure.functions.rpc.messages.CollectionString.Builder;
import com.microsoft.azure.functions.rpc.messages.CollectionString;
Expand Down
Loading