Skip to content

Instantly share code, notes, and snippets.

View vietj's full-sized avatar
🤖
Coding the Future

Julien Viet vietj

🤖
Coding the Future
View GitHub Profile
private static int branchless1(byte c) {
// 48 == 11 0000
// 49 == 11 0001
// 50 == 11 0010
// 57 == 11 1001
byte b1 = (byte) ((c & 0b0001_0000) >> 4);
byte b2 = (byte) ((c & 0b0010_0000) >> 5);
byte b3 = (byte) ((c & 0b0100_0000) >> 6);
byte b4 = (byte) ((c & 0b1000_0000) >> 7);
byte b5 = (byte) (b1 & b2 & ~b3 & ~b4);
private static int indexOf(byte c) {
if (c == '-') {
return 26;
} else if (c >= '0' && c <= '9') {
return c;
} else if (c >= 'A' && c <= 'Z') {
return c - 'A';
} else if (c >= 'a' && c <= 'z') {
return c - 'a';
} else {
public Scope receiveRequest(Map<Object, Object> context, Object request, String operation, Iterable<Map.Entry<String, String>> headers, Iterable<Map.Entry<String, String>> tags) {
SpanContext sc = tracer.extract(Format.Builtin.HTTP_HEADERS, new TextMap() {
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return headers.iterator();
}
@Override
public void put(String key, String value) {
throw new UnsupportedOperationException();
}

Streams

There are several objects in Vert.x that allow items to be read from and written.

In previous versions the io.vertx.core.streams package was manipulating Buffer objects exclusively. From now, streams are not coupled to buffers anymore and they work with any kind of objects.

In Vert.x, write calls return immediately, and writes are queued internally.

package io.vertx.tracing.jaeger;
import io.jaegertracing.internal.JaegerSpanContext;
import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMap;
import io.opentracing.tag.Tags;
/*
* Copyright (c) 2011-2018 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
[INFO] +- io.swagger.parser.v3:swagger-parser:jar:2.0.5:compile
[INFO] | +- io.swagger.parser.v3:swagger-parser-v2-converter:jar:2.0.5:compile
[INFO] | | +- io.swagger:swagger-parser:jar:1.0.39:compile
[INFO] | | | \- io.swagger:swagger-core:jar:1.5.21:compile
[INFO] | | | \- io.swagger:swagger-models:jar:1.5.21:compile
[INFO] | | | \- io.swagger:swagger-annotations:jar:1.5.21:compile
[INFO] | | +- io.swagger:swagger-compat-spec-parser:jar:1.0.39:compile
[INFO] | | | +- com.github.java-json-tools:json-schema-validator:jar:2.2.8:compile
[INFO] | | | | +- com.github.java-json-tools:json-schema-core:jar:1.2.8:compile
[INFO] | | | | | +- org.mozilla:rhino:jar:1.7R4:compile
[INFO] +- io.vertx:vertx-web-api-contract:jar:3.6.0-SNAPSHOT:compile (optional)
[INFO] | +- com.networknt:json-schema-validator:jar:0.1.23:compile (optional)
[INFO] | +- io.swagger.parser.v3:swagger-parser:jar:2.0.5:compile (optional)
[INFO] | | +- io.swagger.parser.v3:swagger-parser-v2-converter:jar:2.0.5:compile (optional)
[INFO] | | | +- io.swagger:swagger-parser:jar:1.0.39:compile (optional)
[INFO] | | | | \- io.swagger:swagger-core:jar:1.5.21:compile (optional)
[INFO] | | | | \- io.swagger:swagger-models:jar:1.5.21:compile (optional)
[INFO] | | | | \- io.swagger:swagger-annotations:jar:1.5.21:compile (optional)
[INFO] | | | +- io.swagger:swagger-compat-spec-parser:jar:1.0.39:compile (optional)
[INFO] | | | | +- com.github.java-json-tools:json-schema-validator:jar:2.2.8:compile (optional)
@vietj
vietj / foo.md
Created November 12, 2018 08:23

Hi,

the first candidate of Vert.x 3.6 has been released.

This CR is a maven central release of the 3.6 jars.

The documentation you can previewed using the web-site snapshot build that contains the latest documentation.

Here is a quick summary of the new features you can find in 3.6:

public static void validateHeaderValue(CharSequence seq) {
int state = 0;
// Start looping through each of the character
for (int index = 0; index < seq.length(); index++) {
state = validateValueChar(seq, state, seq.charAt(index));
}
if (state != 0) {
throw new IllegalArgumentException("a header value must not end with '\\r' or '\\n':" + seq);