Skip to content

Commit

Permalink
Release 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mizosoft committed May 9, 2022
1 parent 23d906d commit cff03de
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 41 deletions.
91 changes: 86 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,105 @@
# Change Log

## Version 1.7.0

*8-5-2022*

A full year has passed since the last Methanol release! Time truly flies. It's been difficult to
find the time to cut this release due to my senior college year & other life circumstances, but here
we are!

* The Jackson adapter has been reworked to support the multitude of formats supported by Jackson,
not only JSON ([#45](https://github.com/mizosoft/methanol/issues/45)). That means you can now pass
arbitrary `ObjectMapper` instances along with one or more `MediaTypes` describing their formats.
For instance, here's a provider for a Jackson-based XML decoder.

```java
public static class JsonDecoderProvider {
private JsonDecoderProvider() {}

public static BodyAdapter.Decoder provider() {
return JacksonAdapterFactory.createEncoder(new XmlMapper(), MediaType.TEXT_XML);
}
}
```

Binary formats (e.g. protocol buffers) usually require a schema for each type. `ObjectReaderFacotry` &
`ObjectWritierFactory` have been added for this purpose. For instance, here's a provider for a
protocol-buffers decoder. You'll need to know which types to expect beforehand.

```java
public static class ProtobufDecoderProvider {
private ProtobufDecoderProvider() {}

record Point(int x, int y) {}

public static BodyAdapter.Decoder provider() {
var schemas = Map.of(
Point.class,
ProtobufSchemaLoader.std.parse(
"""
message Point {
required int32 x = 1;
required int32 y = 2;
}
"""), ...);

// Apply the corresponding schema for each created ObjectReader
ObjectReaderFactory readerFactory =
(mapper, type) -> mapper.readerFor(type).with(schemes.get(type.rawType()));
return JacksonAdapterFactory.createEncoder(
new ProtobufMapper(), readerFactory, MediaType.TEXT_XML);
}
}
```

* To avoid ambiguity, `JacksonAdapterFactory::createDecoder` & `JacksonAdapterFactory::createEncoder`
have been deprecated and replaced with `JacksonAdapterFactory::createJsonDecoder` & `JacksonAdapterFactory::createJsonEncoder`
respectively.

* Added timeouts for receiving all response headers ([#49](https://github.com/mizosoft/methanol/issues/49)).
You can use these along with read timeouts to set more granular timing constraints for your requests
when request timeouts are too strict.
```java
var client = Methanol.newBuilder()
.headersTimeout(Duration.ofSeconds(30))
.readTimeout(Duration.ofSeconds(30))
...
.build()
```

* Fix ([#40](https://github.com/mizosoft/methanol/issues/40)): Methanol had a long-lived issue that
made it difficult for service providers to work with custom JAR formats, particularly the one used
by [Spring Boot executables](https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html).
Instead of the system classloader, Methanol now relies on the classloader that loaded the library
itself for locating providers. This is not necessarily the system classloader as in the case with
Spring Boot.
* Fix ([#46](https://github.com/mizosoft/methanol/issues/46)): `ProgressTracker` now returns `MimeBodyPublisher`
if the body being tracked is itself a `MimeBodyPublisher`. This prevents "swallowing" the `MediaType` of such bodies.
* Upgraded Jackson to `2.13.2`.
* Upgraded Gson to `2.9.0`.
* Upgraded Reactor to `3.4.17`.

## Version 1.6.0

*30-5-2021*
*30-5-2021*

* Added [`HttpCache.Listener`](https://mizosoft.github.io/methanol/api/latest/methanol/com/github/mizosoft/methanol/HttpCache.Listener.html).
*Added [`HttpCache.Listener`](https://mizosoft.github.io/methanol/api/latest/methanol/com/github/mizosoft/methanol/HttpCache.Listener.html).
* Added `TaggableRequest`. This facilitates carrying application-specific data throughout interceptors & listeners.

```java
var interceptor = Interceptor.create(request -> {
var taggableRequest = TaggableRequest.from(request);
var myContext = taggableRequest.tag(MyContext.class).orElseGet(MyContext::empty);
var context = taggableRequest.tag(MyContext.class).orElseGet(MyContext::empty);
...
});
var client = Methanol.newBuilder()
.interceptor(interceptor)
.build();

var myContext = ...
var context = ...
var request = MutableRequest.GET("https://example.com")
.tag(MyContext.class, myContext);
.tag(MyContext.class, context);
var response = client.send(request, BodyHandlers.ofString());
```

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ is given to object mapping, so integration with libraries like Jackson or Gson b
### Gradle

```gradle
implementation 'com.github.mizosoft.methanol:methanol:1.6.0'
implementation 'com.github.mizosoft.methanol:methanol:1.7.0'
```

### Maven
Expand All @@ -31,7 +31,7 @@ implementation 'com.github.mizosoft.methanol:methanol:1.6.0'
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ext {
allprojects {
group = 'com.github.mizosoft.methanol'
ext.artifactId = getArtifactId(project)
version = '1.7.0-SNAPSHOT'
version = '1.7.0'

repositories {
mavenCentral()
Expand Down
16 changes: 1 addition & 15 deletions methanol-benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Benchmarks are available as a runnable Jar in [Maven][benchmarks_maven]. You run them as following:

```bsh
java -jar benchmarks-1.6.0-all.jar
java -jar benchmarks-1.7.0-all.jar
```

## Results
Expand All @@ -28,19 +28,5 @@ Compare Methanol's non-blocking decoders with available `InputStream` ones:
Results show that `BodyDecoder` implementations are on par with available `InputStream` based
decoders. Note that the brotli benchmark is biased as it also compares native C vs pure Java implementations.

### Jackson UTF-8 coercion

[methanol-jackson][methanol_jackson] uses Jackson's non-blocking JSON parser for better memory
efficiency. The parser however only supports UTF-8 and ASCII. Instead of falling back to the
byte array parser for other response charsets, an efficient operator is used to decode the response
from source charset then encode it back to UTF-8. This might seem awkward at first but measurement
shows that performance is not that different from the byte array parser (tested with UTF-16):

| Parser | Mode | Cnt | Score | Error | Units |
|-------------------|-------|-----|-----------|---------|-------|
| ASYNC_PARSER | thrpt | 5 | 10557.752 | 133.519 | ops/s |
| BYTE_ARRAY_PARSER | thrpt | 5 | 11167.702 | 128.353 | ops/s |

[jmh]: https://openjdk.java.net/projects/code-tools/jmh/
[benchmarks_maven]: https://mvnrepository.com/artifact/com.github.mizosoft.methanol/benchmarks/
[methanol_jackson]: https://github.com/mizosoft/methanol/tree/master/methanol-jackson
4 changes: 2 additions & 2 deletions methanol-brotli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Provides [brotli][brotli] decompression.
### Gradle

```gradle
implementation 'com.github.mizosoft.methanol:methanol-brotli:1.4.1'
implementation 'com.github.mizosoft.methanol:methanol-brotli:1.7.0'
```

### Maven
Expand All @@ -16,7 +16,7 @@ implementation 'com.github.mizosoft.methanol:methanol-brotli:1.4.1'
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol-brotli</artifactId>
<version>1.4.1</version>
<version>1.7.0</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions methanol-gson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Adapters for JSON using [Gson][gson].
### Gradle

```gradle
implementation 'com.github.mizosoft.methanol:methanol-gson:1.6.0'
implementation 'com.github.mizosoft.methanol:methanol-gson:1.7.0'
```

### Maven

```xml
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol-gson</artifactId>
<version>1.6.0</version>
<artifactId>methanol-gson</artifactId>
<version>1.7.0</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions methanol-jackson-flux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ With the exception of `Mono`, any subtype of `org.reactivestreams.Publisher` or
### Gradle

```gradle
implementation 'com.github.mizosoft.methanol:methanol-jackson-flux:1.6.0'
implementation 'com.github.mizosoft.methanol:methanol-jackson-flux:1.7.0'
```

### Maven

```xml
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol-jackson-flux</artifactId>
<version>1.6.0</version>
<artifactId>methanol-jackson-flux</artifactId>
<version>1.7.0</version>
</dependency>
```

Expand Down
8 changes: 4 additions & 4 deletions methanol-jackson/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# methanol-jackson

Adapters for JSON using [Jackson][jackson].
Adapters for [Jackson][jackson].

## Installation

### Gradle

```gradle
implementation 'com.github.mizosoft.methanol:methanol-jackson:1.6.0'
implementation 'com.github.mizosoft.methanol:methanol-jackson:1.7.0'
```

### Maven

```xml
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol-jackson</artifactId>
<version>1.6.0</version>
<artifactId>methanol-jackson</artifactId>
<version>1.7.0</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions methanol-jaxb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Adapters for XML using [JAXB][jaxb].
### Gradle

```gradle
implementation 'com.github.mizosoft.methanol:methanol-jaxb:1.6.0'
implementation 'com.github.mizosoft.methanol:methanol-jaxb:1.7.0'
```

### Maven

```xml
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol-jaxb</artifactId>
<version>1.6.0</version>
<artifactId>methanol-jaxb</artifactId>
<version>1.7.0</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions methanol-protobuf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ Any subtype of `MessageLite` is supported by encoders & decoders. Decoders can o
### Gradle

```gradle
implementation 'com.github.mizosoft.methanol:methanol-protobuf:1.6.0'
implementation 'com.github.mizosoft.methanol:methanol-protobuf:1.7.0'
```

### Maven

```xml
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol-protobuf</artifactId>
<version>1.6.0</version>
<artifactId>methanol-protobuf</artifactId>
<version>1.7.0</version>
</dependency>
```

Expand Down

0 comments on commit cff03de

Please sign in to comment.