Skip to content
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
12 changes: 3 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,16 @@ subprojects {
group = 'org.hyperledger.fabric-chaincode-java'
version = rootProject.version

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

compileJava {
if (javaCompiler.get().metadata.languageVersion.canCompileOrRun(10)) {
options.release = 11
}
options.release = 11
options.compilerArgs += ['-Werror', '-Xlint:all']
}

dependencies {
implementation 'commons-cli:commons-cli:1.10.0'
implementation 'commons-logging:commons-logging:1.3.5'

testImplementation platform('org.junit:junit-bom:5.13.4')
testImplementation platform('org.junit:junit-bom:6.0.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.assertj:assertj-core:3.27.6'
Expand Down
3 changes: 2 additions & 1 deletion examples/fabric-contract-example-as-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ repositories {
dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.7'
implementation 'org.json:json:20250517'
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
testImplementation platform('org.junit:junit-bom:6.0.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.27.6'
testImplementation 'org.mockito:mockito-core:5.20.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
4 changes: 3 additions & 1 deletion examples/fabric-contract-example-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ repositories {
dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.7'
implementation 'org.json:json:20250517'
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
testImplementation platform('org.junit:junit-bom:6.0.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.27.6'
testImplementation 'org.mockito:mockito-core:5.20.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

shadowJar {
Expand Down
22 changes: 13 additions & 9 deletions examples/fabric-contract-example-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<logback.version>1.5.19</logback.version>
<slf4j.version>2.0.17</slf4j.version>

<!-- Test -->
<junit.jupiter.version>5.13.4</junit.jupiter.version>
<junit.platform.version>1.13.1</junit.platform.version>

</properties>

<repositories>
Expand All @@ -31,7 +27,19 @@
</repository>
</repositories>

<dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>6.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<!-- fabric-chaincode-java -->
<dependency>
Expand Down Expand Up @@ -69,19 +77,16 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
Expand All @@ -102,7 +107,6 @@
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
Expand Down
4 changes: 3 additions & 1 deletion examples/ledger-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ repositories {
dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.7'
implementation 'org.json:json:20250517'
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
testImplementation platform('org.junit:junit-bom:6.0.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.27.6'
testImplementation 'org.mockito:mockito-core:5.20.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

shadowJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@
/** Logger class to use throughout the Contract Implementation. */
public class Logger extends java.util.logging.Logger {

/**
* Subclasses must ensure that a parent logger is set appropriately, for example:
*
* <p>{@code logger.setParent(java.util.logging.Logger.getLogger("org.hyperledger.fabric"))}
*
* @param name A name for the logger.
*/
protected Logger(final String name) {
super(name, null);

// ensure that the parent logger is set
super.setParent(java.util.logging.Logger.getLogger("org.hyperledger.fabric"));
}

/**
* @param name
* @return Logger
*/
public static Logger getLogger(final String name) {
return new Logger(name);
Logger result = new Logger(name);
result.setParent(java.util.logging.Logger.getLogger("org.hyperledger.fabric"));
return result;
}

/** @param msgSupplier */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
import io.github.classgraph.ScanResult;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -41,15 +42,20 @@ public SerializerInterface getSerializer(final String name, final Serializer.TAR
return contents.get(key);
}

private SerializerInterface add(
final String name, final Serializer.TARGET target, final Class<SerializerInterface> clazz)
private void add(final String name, final Serializer.TARGET target, final Class<?> clazz)
throws InstantiationException, IllegalAccessException {
LOGGER.debug(() -> "Adding new Class " + clazz.getCanonicalName() + " for " + target);
final String key = name + ":" + target;
final SerializerInterface newObj = clazz.newInstance();
this.contents.put(key, newObj);

return newObj;
try {
final SerializerInterface newObj =
(SerializerInterface) clazz.getDeclaredConstructor().newInstance();
this.contents.put(key, newObj);
} catch (InvocationTargetException | NoSuchMethodException e) {
InstantiationException wrapper = new InstantiationException(
"Exception constructing " + clazz.getCanonicalName() + ": " + e.getMessage());
wrapper.addSuppressed(e);
throw wrapper;
}
}

/**
Expand All @@ -67,10 +73,10 @@ public void findAndSetContents() throws InstantiationException, IllegalAccessExc
final Set<String> seenClass = new HashSet<>();

try (ScanResult scanResult = classGraph.scan()) {
for (final ClassInfo classInfo :
scanResult.getClassesWithAnnotation(this.ANNOTATION_CLASS.getCanonicalName())) {
for (final ClassInfo classInfo : scanResult.getClassesWithAnnotation(ANNOTATION_CLASS.getCanonicalName())) {
LOGGER.debug(() -> "Found class with contract annotation: " + classInfo.getName());
final Class<SerializerInterface> cls = (Class<SerializerInterface>) classInfo.loadClass();

final Class<?> cls = classInfo.loadClass();
LOGGER.debug("Loaded class");

final String className = cls.getCanonicalName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public T next() {
}

@Override
public void close() throws Exception {
public void close() {

final ByteString requestPayload = QueryStateClose.newBuilder()
.setId(currentQueryResponse.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
*
* @param <T> the type of elements returned by the iterator
*/
public interface QueryResultsIterator<T> extends Iterable<T>, AutoCloseable {}
public interface QueryResultsIterator<T> extends Iterable<T>, AutoCloseable {
@Override
void close();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
public interface QueryResultsIteratorWithMetadata<T> extends Iterable<T>, AutoCloseable {
/** @return Query Metadata */
QueryResponseMetadata getMetadata();

@Override
void close();
}