Skip to content
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

Use Java 21 runtime #364

Merged
merged 1 commit into from
Nov 28, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 11
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Push to registry ${{ matrix.publish_target }}
run: |
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 11
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Build the dependencies needed for the image
run: ./gradlew :fabric-chaincode-docker:copyAllDeps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Set up Go
uses: actions/setup-go@v5
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Build and Unit test
run: ./gradlew :fabric-chaincode-shim:build
Expand All @@ -36,7 +36,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Populate chaincode with latest java-version
run: |
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Build Docker image
run: ./gradlew :fabric-chaincode-docker:buildImage
6 changes: 3 additions & 3 deletions fabric-chaincode-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG JAVA_IMAGE=eclipse-temurin:11-jdk
ARG JAVA_IMAGE=eclipse-temurin:21-jdk

FROM ${JAVA_IMAGE} as builder
FROM ${JAVA_IMAGE} AS builder
ENV DEBIAN_FRONTEND=noninteractive

# Build tools
Expand All @@ -16,7 +16,7 @@ RUN source /root/.sdkman/bin/sdkman-init.sh \
&& sdk install gradle 8.11.1 \
&& sdk install maven 3.9.9

FROM ${JAVA_IMAGE} as dependencies
FROM ${JAVA_IMAGE} AS dependencies

COPY --from=builder /root/.sdkman/candidates/gradle/current /usr/bin/gradle
COPY --from=builder /root/.sdkman/candidates/maven/current /usr/bin/maven
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,23 @@
*/
package org.hyperledger.fabric.contract.routing;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.startsWith;

import contract.SampleContract;
import java.lang.reflect.Method;
import java.security.Permission;
import org.hyperledger.fabric.contract.Context;
import org.hyperledger.fabric.contract.ContractInterface;
import org.hyperledger.fabric.contract.ContractRuntimeException;
import org.hyperledger.fabric.contract.annotation.Contract;
import org.hyperledger.fabric.contract.annotation.Info;
import org.hyperledger.fabric.contract.routing.impl.ContractDefinitionImpl;
import org.junit.jupiter.api.Test;

final class ContractDefinitionTest {
@Test
void constructor() throws NoSuchMethodException, SecurityException {
void constructor() throws SecurityException {

final ContractDefinition cf = new ContractDefinitionImpl(SampleContract.class);
assertThat(cf.toString(), startsWith("samplecontract:"));
}

@Contract(name = "", info = @Info())
public class FailureTestObject {}

private boolean fail;
private static final int STEP = 1;

@Test
void unknownRoute() {

final SecurityManager tmp = new SecurityManager() {
private int count = 0;

@Override
public void checkPackageAccess(final String pkg) {

if (pkg.startsWith("org.hyperledger.fabric.contract")) {
if (count >= STEP) {
throw new SecurityException("Sorry I can't do that");
}
count++;
}
super.checkPackageAccess(pkg);
}

@Override
public void checkPermission(final Permission perm) {}
};

try {
final ContractDefinition cf = new ContractDefinitionImpl(SampleContract.class);
System.setSecurityManager(tmp);
this.fail = true;

cf.getUnknownRoute();
} catch (final Exception e) {
assertThat(e.getMessage(), equalTo("Failure to find unknownTransaction method"));
} finally {
System.setSecurityManager(null);
}
assertThat(cf.toString()).startsWith("samplecontract:");
}

@Test
Expand Down