Skip to content
Open
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
5 changes: 2 additions & 3 deletions .github/workflows/branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]
java: [ 17, 21, 25 ]
steps:
- uses: actions/checkout@v2
- name: Setup java
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 17
server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
Expand All @@ -45,4 +45,3 @@ jobs:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

3 changes: 1 addition & 2 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 17
- name: Bump version using Maven
if: ${{ inputs.maven-modules == 'true' }}
run: './mvnw versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -B'
Expand All @@ -44,4 +44,3 @@ jobs:
This PR performs the bump of the SDK to ${{ github.event.inputs.version }}.
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).

2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]
java: [ 17, 21, 25 ]
name: Java ${{ matrix.java }} Test
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Supported features of the specification:
| AVRO Event Format | :x: | :x: |
| HTTP Protocol Binding | :heavy_check_mark: | :heavy_check_mark: |
| - [Vert.x](http/vertx) | :heavy_check_mark: | :heavy_check_mark: |
| - [Jakarta EE 8 Restful WS](http/restful-ws) | :heavy_check_mark: | :heavy_check_mark: |
| - [Jakarta EE 9+ Restful WS](http/restful-ws-jakarta) | :heavy_check_mark: | :heavy_check_mark: |
| - [Basic](http/basic) | :heavy_check_mark: | :heavy_check_mark: |
| - [Spring](spring) | :heavy_check_mark: | :heavy_check_mark: |
Expand Down Expand Up @@ -69,7 +68,6 @@ Javadocs are available on [javadoc.io](https://www.javadoc.io):
- [cloudevents-protobuf](https://www.javadoc.io/doc/io.cloudevents/cloudevents-protobuf)
- [cloudevents-xml](https://www.javadoc.io/doc/io.cloudevents/cloudevents-xml)
- [cloudevents-http-basic](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-basic)
- [cloudevents-http-restful-ws](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-restful-ws)
- [cloudevents-http-restful-ws-jakarta](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-restful-ws-jakarta)
- [cloudevents-http-vertx](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-vertx)
- [cloudevents-kafka](https://www.javadoc.io/doc/io.cloudevents/cloudevents-kafka)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ public static byte[] getPayloadAsByteArray(final Section payload) {
return null;
}

if (payload instanceof Data) {
final Data body = (Data) payload;
if (payload instanceof Data body) {
return body.getValue().getArray();
} else if (payload instanceof AmqpValue) {
final AmqpValue body = (AmqpValue) payload;
} else if (payload instanceof AmqpValue body) {
if (body.getValue() instanceof byte[]) {
return (byte[]) body.getValue();
} else if (body.getValue() instanceof String &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private static Stream<Arguments> binaryTestArguments() {
private static final SimpleEntry<String, Object> property(final String name, final Object value) {
return name.equalsIgnoreCase("ignored") ?
new SimpleEntry<>(name, value) :
new SimpleEntry<>(String.format(PREFIX_TEMPLATE, name), value);
new SimpleEntry<>(PREFIX_TEMPLATE.formatted(name), value);
}

@SafeVarargs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private Message translateStructured(final CloudEvent event, final EventFormat fo
}
private void addProperty(final Map<String, Object> map, final String name, final String value, final boolean prefix) {
if (prefix) {
map.put(String.format("cloudEvents:%s", name), value);
map.put("cloudEvents:%s".formatted(name), value);
} else {
map.put(name, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ default CloudEventContextWriter withContextAttribute(String name, OffsetDateTime
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*
* @deprecated CloudEvent specification only permits {@link Integer} type as a
* numeric value.
* numeric value. Use {@link #withContextAttribute(String, Integer)} instead.
*/
@Deprecated
default CloudEventContextWriter withContextAttribute(String name, Number value) throws CloudEventRWException {
return withContextAttribute(name, value.toString());
}
Expand Down Expand Up @@ -122,7 +123,7 @@ default CloudEventContextWriter withContextAttribute(String name, Boolean value)
}

/**
* Set attribute with a binary type.
* Set the attribute with a binary type.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
Expand Down
15 changes: 4 additions & 11 deletions benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.23</jmh.version>
<javac.target>1.8</javac.target>
<!-- Name of the benchmark Uber-JAR to generate. -->
<uberjar.name>benchmarks</uberjar.name>
<maven.javadoc.skip>true</maven.javadoc.skip>
Expand Down Expand Up @@ -80,16 +79,6 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
<configuration>
<compilerVersion>${javac.target}</compilerVersion>
<source>${javac.target}</source>
<target>${javac.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down Expand Up @@ -135,6 +124,10 @@
<artifactId>maven-clean-plugin</artifactId>
<version>3.5.0</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.4</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;

import java.util.Optional;

import static io.cloudevents.core.test.Data.V1_WITH_JSON_DATA_WITH_EXT;

public class KafkaConsumerMessageToCloudEventBenchmark {
Expand All @@ -45,12 +47,12 @@ public BinaryMessage() {
0,
0,
TimestampType.NO_TIMESTAMP_TYPE,
-1L,
ConsumerRecord.NULL_SIZE,
ConsumerRecord.NULL_SIZE,
"aaa",
inRecord.value(),
inRecord.headers()
inRecord.headers(),
Optional.empty()
);
}
}
Expand Down Expand Up @@ -81,12 +83,12 @@ public StructuredJsonMessage() {
0,
0,
TimestampType.NO_TIMESTAMP_TYPE,
-1L,
ConsumerRecord.NULL_SIZE,
ConsumerRecord.NULL_SIZE,
"aaa",
inRecord.value(),
inRecord.headers()
inRecord.headers(),
Optional.empty()
);
}
}
Expand Down
5 changes: 0 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@
<artifactId>cloudevents-http-vertx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-restful-ws</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-kafka</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/io/cloudevents/core/CloudEventUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ private CloudEventUtils() {}
* @return the reader implementation
*/
public static CloudEventReader toReader(CloudEvent event) {
if (event instanceof CloudEventReader) {
return (CloudEventReader) event;
if (event instanceof CloudEventReader reader) {
return reader;
} else {
return new CloudEventReaderAdapter(event);
}
Expand All @@ -63,8 +63,8 @@ public static CloudEventReader toReader(CloudEvent event) {
* @return the context reader implementation
*/
public static CloudEventContextReader toContextReader(CloudEventContext event) {
if (event instanceof CloudEventContextReader) {
return (CloudEventContextReader) event;
if (event instanceof CloudEventContextReader reader) {
return reader;
} else {
return new CloudEventContextReaderAdapter(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class BytesCloudEventData implements CloudEventData {
* @param value the bytes to wrap
* @deprecated use {@link BytesCloudEventData#wrap(byte[])}
*/
@Deprecated
public BytesCloudEventData(byte[] value) {
Objects.requireNonNull(value);
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ public void readAttributes(CloudEventContextWriter writer) throws RuntimeExcepti
}

public void readExtensions(CloudEventContextWriter writer) throws RuntimeException {
for (String key : event.getExtensionNames()) {
Object value = event.getExtension(key);
if (value instanceof String) {
writer.withContextAttribute(key, (String) value);
} else if (value instanceof Number) {
writer.withContextAttribute(key, (Number) value);
} else if (value instanceof Boolean) {
writer.withContextAttribute(key, (Boolean) value);
} else if (value instanceof URI) {
writer.withContextAttribute(key, (URI) value);
} else if (value instanceof OffsetDateTime) {
writer.withContextAttribute(key, (OffsetDateTime) value);
for (String extensionName : event.getExtensionNames()) {
Object value = event.getExtension(extensionName);
if (value instanceof String string) {
writer.withContextAttribute(extensionName, string);
} else if (value instanceof Number number) {
writer.withContextAttribute(extensionName, number);
} else if (value instanceof Boolean bool) {
writer.withContextAttribute(extensionName, bool);
} else if (value instanceof URI uri) {
writer.withContextAttribute(extensionName, uri);
} else if (value instanceof OffsetDateTime time) {
writer.withContextAttribute(extensionName, time);
} else {
// This should never happen because we build that map only through our builders
throw new IllegalStateException("Illegal value inside extensions map: " + key + " " + value);
throw new IllegalStateException("Illegal value inside extensions map: " + extensionName + " " + value);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/io/cloudevents/core/test/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class Data {
.withExtension("integer", 42)
.withExtension("decimal", new BigDecimal("42.42"))
.withExtension("float", 4.2f)
.withExtension("long", new Long(4200))
.withExtension("long", Long.valueOf(4200))
.build();

public static final CloudEvent V03_MIN = CloudEventBuilder.v03(V1_MIN).build();
Expand Down
1 change: 0 additions & 1 deletion docs/http-basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ This module is designed to be usable with various HTTP APIs.
There are also more specialized HTTP bindings:

- [`cloudevents-http-vertx`](http-vertx.md)
- [`cloudevents-http-restful-ws`](http-jakarta-restful-ws.md) (deprecated, please use `cloudevents-http-restful-ws-jakarta`)
- [`cloudevents-http-restful-ws-jakarta`](http-jakarta-restful-ws-jakarta.md)
- [`cloudevents-spring`](spring.md)

Expand Down
Loading
Loading