Skip to content

3.8.2 Deprecations and breaking changes

Julien Viet edited this page Oct 14, 2019 · 14 revisions

Vert.x Core

Deprecate Json elements referencing Jackson types

We deprecate and provide replacement for these elements of the Json API referencing directly Jackon's types.

  • Json#mapper field replaced by DatabindCodec#mapper() method
  • Json#prettyMapper field replaced by DatabindCodec#prettyMapper() method
  • Json#decodeValue(Buffer, TypeReference<T>) method replaced by JacksonCodec#decodeValue(Buffer, TypeReference)
  • Json#decodeValue(String, TypeReference<T>) method replaced by JacksonCodec#decodeValue(String, TypeReference)

These are available in Vert.x 4

Here are a few migration examples:

With TypeReference

// Now deprecated
List<Foo> foo1 = Json.decodeValue(json, new TypeReference<List<Foo>>() {});

// You should use instead
List<Foo> foo2 = io.vertx.core.json.jackson.JacksonCodec.decodeValue(json, new TypeReference<List<Foo>>() {});

Referencing an ObjectMapper:

// Now deprecated
ObjectMapper maper = Json.mapper;

// You should use instead
mapper = io.vertx.core.json.jackson.DatabindCodec.mapper();

Setting an ObjectMapper:

// Now deprecated
Json.mapper = someMapper;

// You cannot write anymore the mapper instance instead you should use your own static mapper
// or configure the Databind#mapper() instance

Vert.x Web

StaticHandler changes

The factory create(String, ClassLoader) is deprecated and will be removed on 4.0. Users are advised to add classpath resources to the classpath directly instead of having a classloader.

SockJSHandler changes

The SockJSHandler#socketHandler(...) and SockJSHandler#bridge(...) methods now return a Router object instead of being fluent. This allows the sockjs handler to be mounted as a sub-router. Previously it was being handled as a Handler however this would not handle failures correctly. The correct way to mount SockJS should be:

router.mountSubRouter("/eventbus", SockJS.create(vertx).bridge(...));

In the future the SockJS handler shall stop implementing the Handler<RoutingContex> interface too.

This change also means that the methods:

  • socketHandler(Handler)
  • bridge(BridgeOptions)

Are not fluent anymore and return a Router instead.

The example above shows the change.

Vert.x Circuit Breaker

Rename executeCommandXXX to executeXXX then deprecate them

In Vert.x 4, executeCommandXXX methods are renamed executeXXX for futurization purpose. In the 3.x branch we deprecate these methods and we add the new methods as deprecation replacements.

// Now this is deprecated
breaker.executeCommand(promise -> ..., res -> ...);

// Instead you should use
breaker.execute(promise -> ..., res -> ...);

Vert.x Service Discovery

ServiceDiscovery async create deprecation for removal in Vert.x 4

The ServiceDiscovery creation methods with an Handler are deprecated for removal in Vert.x 4.

The completion handler will not take in account failure. The completion handler actually runs the ServiceImporter#start and ServiceExporter#init methods, so calling these methods will result in them being called twice, once at registration time and once by the initialisation callback.

If this prevents an actual use case in community we can still provide a better alternative.

Vert.x Config

In Vert.x 4 this method is now an instance method of ConfigRetriever, so we deprecate this in 3.x

// deprecated
Future<JsonObject> fut = ConfigRetriever. getConfigAsFuture(retriever);

// instead use in 3.X
fut = Future.future(retriever::getConfig);

// or in 4.0
fut = retriever.getConfig();

Vert.x SQL Client

RowSet is a generic type as RowSet<R> allowing the API to return other types than row.

// before
client.query("SELECT * FROM users WHERE id='julien'", ar -> {
  if (ar.succeeded()) {
    RowSet rows = ar.result();
  } else ...
});

// in 3.8.2
client.query("SELECT * FROM users WHERE id='julien'", ar -> {
  if (ar.succeeded()) {
    RowSet<Row> rows = ar.result();
  } else ...
});
Clone this wiki locally
You can’t perform that action at this time.