Skip to content

v1.7.0

Latest
Compare
Choose a tag to compare
@mizosoft mizosoft released this 09 May 03:24
· 258 commits to master since this release

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). 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.

    public class JacksonXmlDecoderProvider {
      private JacksonXmlDecoderProvider() {}
    
      public static BodyAdapter.Decoder provider() {
        return JacksonAdapterFactory.createDecoder(new XmlMapper(), MediaType.TEXT_XML);
      }
    }

    Binary formats (e.g. protocol buffers) usually require applying a schema for each type. ObjectReaderFacotry & ObjectWriterFactory 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.

     public class JacksonProtobufDecoderProvider {
      private JacksonProtobufDecoderProvider() {}
    
      public record Point(int x, int y) {}
    
      public static BodyAdapter.Decoder provider() throws IOException {
        var schemas = Map.of(
            TypeRef.from(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.rawType()).with(schemas.get(type));
        return JacksonAdapterFactory.createDecoder(
            new ProtobufMapper(), readerFactory, MediaType.APPLICATION_X_PROTOBUF);
      }
    }
  • To avoid ambiguity, JacksonAdapterFactory::createDecoder & JacksonAdapterFactory::createEncoder that don't take an explicit MediaType have been deprecated and replaced with JacksonAdapterFactory::createJsonDecoder & JacksonAdapterFactory::createJsonEncoder respectively.

  • Added timeouts for receiving all response headers (#49). You can use these along with read timeouts to set more granular timing constraints for your requests when request timeouts are too strict.

    var client = Methanol.newBuilder()
        .headersTimeout(Duration.ofSeconds(30))
        .readTimeout(Duration.ofSeconds(30))
        ...
        .build()
  • Fix (#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's executable JARs. 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): 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.