2 * Copyright 2023 PANTHEON.tech, s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package io.atomix.utils.serializer;
18 import static java.util.Objects.requireNonNull;
20 import com.esotericsoftware.kryo.Kryo;
21 import com.esotericsoftware.kryo.KryoException;
22 import com.esotericsoftware.kryo.io.Input;
23 import com.esotericsoftware.kryo.serializers.JavaSerializer;
24 import io.atomix.storage.journal.JournalSerdes.EntryInput;
25 import java.io.IOException;
27 @Deprecated(forRemoval = true, since = "9.0.3")
28 final class KryoEntryInput implements EntryInput {
29 private final Kryo kryo;
30 private final Input input;
31 private final JavaSerializer javaSerializer;
33 KryoEntryInput(final Kryo kryo, final Input input, final JavaSerializer javaSerializer) {
34 this.kryo = requireNonNull(kryo);
35 this.input = requireNonNull(input);
36 this.javaSerializer = requireNonNull(javaSerializer);
40 public byte[] readBytes(final int length) throws IOException {
42 return input.readBytes(length);
43 } catch (KryoException e) {
44 throw new IOException(e);
49 public long readLong() throws IOException {
51 return input.readLong(false);
52 } catch (KryoException e) {
53 throw new IOException(e);
58 public Object readObject() throws IOException {
60 return javaSerializer.read(kryo, input, null);
61 } catch (KryoException e) {
62 throw new IOException(e);
67 public String readString() throws IOException {
69 return input.readString();
70 } catch (KryoException e) {
71 throw new IOException(e);
76 public int readVarInt() throws IOException {
78 return input.readVarInt(true);
79 } catch (KryoException e) {
80 throw new IOException(e);