Upgrade dependencies; prepare for release
* Upgrade to Gradle `7.3.3` * Upgrade to the latest milestones for releasing * Upgrade to Kryo-5.2.1 and update source code according breaking changes * Upgrade to H2-2.1.210 and re-enable respective stored procedure tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,69 +27,71 @@ import org.springframework.util.Assert;
|
||||
import com.esotericsoftware.kryo.Kryo;
|
||||
import com.esotericsoftware.kryo.io.Input;
|
||||
import com.esotericsoftware.kryo.io.Output;
|
||||
import com.esotericsoftware.kryo.pool.KryoFactory;
|
||||
import com.esotericsoftware.kryo.pool.KryoPool;
|
||||
import com.esotericsoftware.kryo.util.Pool;
|
||||
|
||||
/**
|
||||
* Base class for {@link Codec}s using {@link Kryo}.
|
||||
* Manages pooled {@link Kryo} instances.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public abstract class AbstractKryoCodec implements Codec {
|
||||
|
||||
protected final KryoPool pool; // NOSONAR final
|
||||
protected final Pool<Kryo> pool; // NOSONAR final
|
||||
|
||||
protected AbstractKryoCodec() {
|
||||
KryoFactory factory = () -> {
|
||||
Kryo kryo = new Kryo();
|
||||
kryo.setRegistrationRequired(true);
|
||||
// configure Kryo instance, customize settings
|
||||
configureKryoInstance(kryo);
|
||||
return kryo;
|
||||
this.pool = new Pool<>(true, true) {
|
||||
|
||||
@Override
|
||||
protected Kryo create() {
|
||||
Kryo kryo = new Kryo();
|
||||
kryo.setRegistrationRequired(true);
|
||||
// configure Kryo instance, customize settings
|
||||
configureKryoInstance(kryo);
|
||||
return kryo;
|
||||
}
|
||||
|
||||
};
|
||||
// Build pool with SoftReferences enabled (optional)
|
||||
this.pool = new KryoPool.Builder(factory).softReferences().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(final Object object, OutputStream outputStream) {
|
||||
Assert.notNull(object, "cannot encode a null object");
|
||||
Assert.notNull(outputStream, "'outputSteam' cannot be null");
|
||||
final Output output = (outputStream instanceof Output ? (Output) outputStream : new Output(outputStream));
|
||||
this.pool.run(kryo -> {
|
||||
|
||||
Kryo kryo = this.pool.obtain();
|
||||
try (Output output = (outputStream instanceof Output ? (Output) outputStream : new Output(outputStream))) {
|
||||
doEncode(kryo, object, output);
|
||||
return Void.class;
|
||||
});
|
||||
output.close();
|
||||
}
|
||||
finally {
|
||||
this.pool.free(kryo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T decode(byte[] bytes, Class<T> type) throws IOException {
|
||||
Assert.notNull(bytes, "'bytes' cannot be null");
|
||||
final Input input = new Input(bytes);
|
||||
try {
|
||||
try (Input input = new Input(bytes)) {
|
||||
return decode(input, type);
|
||||
}
|
||||
finally {
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T decode(InputStream inputStream, final Class<T> type) {
|
||||
Assert.notNull(inputStream, "'inputStream' cannot be null");
|
||||
Assert.notNull(type, "'type' cannot be null");
|
||||
final Input input = (inputStream instanceof Input ? (Input) inputStream : new Input(inputStream));
|
||||
T result = null;
|
||||
try {
|
||||
result = this.pool.run(kryo -> doDecode(kryo, input, type));
|
||||
|
||||
Kryo kryo = this.pool.obtain();
|
||||
try (Input input = (inputStream instanceof Input ? (Input) inputStream : new Input(inputStream))) {
|
||||
return doDecode(kryo, input, type);
|
||||
}
|
||||
finally {
|
||||
input.close();
|
||||
this.pool.free(kryo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,10 @@ public abstract class AbstractKryoRegistrar implements KryoRegistrar {
|
||||
|
||||
protected static final Kryo KRYO = new Kryo();
|
||||
|
||||
static {
|
||||
KRYO.setRegistrationRequired(false);
|
||||
}
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass()); // NOSONAR property is final
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,8 @@ import com.esotericsoftware.kryo.io.Output;
|
||||
* is declared transient.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public class FileSerializer extends Serializer<File> {
|
||||
@@ -40,8 +42,8 @@ public class FileSerializer extends Serializer<File> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File read(Kryo kryo, Input input, Class<File> type) {
|
||||
String path = input.readString();
|
||||
public File read(Kryo kryo, Input input, Class<? extends File> type) {
|
||||
String path = input.readString();
|
||||
return new File(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,13 +28,17 @@ import com.esotericsoftware.kryo.io.Output;
|
||||
|
||||
/**
|
||||
* Kryo Serializer for {@link MessageHeaders}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
class MessageHeadersSerializer extends Serializer<MessageHeaders> {
|
||||
|
||||
@Override
|
||||
public void write(Kryo kryo, Output output, MessageHeaders headers) {
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : headers.entrySet()) {
|
||||
if (entry.getValue() != null) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
@@ -44,7 +48,7 @@ class MessageHeadersSerializer extends Serializer<MessageHeaders> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageHeaders read(Kryo kryo, Input input, Class<MessageHeaders> type) {
|
||||
public MessageHeaders read(Kryo kryo, Input input, Class<? extends MessageHeaders> type) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> headers = kryo.readObject(input, HashMap.class);
|
||||
return new MessageHeaders(headers);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,13 +27,16 @@ import com.esotericsoftware.kryo.io.Input;
|
||||
|
||||
/**
|
||||
* Kryo Serializer for {@link MutableMessageHeaders}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
class MutableMessageHeadersSerializer extends MessageHeadersSerializer {
|
||||
|
||||
@Override
|
||||
public MessageHeaders read(Kryo kryo, Input input, Class<MessageHeaders> type) {
|
||||
public MessageHeaders read(Kryo kryo, Input input, Class<? extends MessageHeaders> type) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> headers = kryo.readObject(input, HashMap.class);
|
||||
return new MutableMessageHeaders(headers);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import com.esotericsoftware.kryo.Kryo;
|
||||
import com.esotericsoftware.kryo.io.Input;
|
||||
import com.esotericsoftware.kryo.io.Output;
|
||||
import com.esotericsoftware.kryo.util.DefaultInstantiatorStrategy;
|
||||
|
||||
/**
|
||||
* Kryo Codec that can encode and decode arbitrary types. Classes and associated
|
||||
@@ -34,6 +35,7 @@ import com.esotericsoftware.kryo.io.Output;
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public class PojoCodec extends AbstractKryoCodec {
|
||||
@@ -99,7 +101,7 @@ public class PojoCodec extends AbstractKryoCodec {
|
||||
|
||||
@Override
|
||||
protected void configureKryoInstance(Kryo kryo) {
|
||||
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
|
||||
kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
|
||||
if (this.kryoRegistrar != null) {
|
||||
this.kryoRegistrar.registerTypes(kryo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user