Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.KryoException


    flush(); // Flush any partial chunk.
    if (TRACE) trace("kryo", "End chunks.");
    try {
      getOutputStream().write(0); // Zero length chunk.
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
  }
View Full Code Here


  protected int fill (byte[] buffer, int offset, int count) throws KryoException {
    if (inputStream == null) return -1;
    try {
      return inputStream.read(buffer, offset, count);
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
  }
View Full Code Here

   * @return the number of bytes remaining.
   * @throws KryoException if EOS is reached before required bytes are read (buffer underflow). */
  protected int require (int required) throws KryoException {
    int remaining = limit - position;
    if (remaining >= required) return remaining;
    if (required > capacity) throw new KryoException("Buffer too small: capacity: " + capacity + ", required: " + required);

    int count;   
    // Try to fill the buffer.
    if (remaining > 0) {
      count = fill(buffer, limit, capacity - limit);
      if (count == -1) throw new KryoException("Buffer underflow.");
      remaining += count;
      if (remaining >= required) {
        limit += count;
        return remaining;
      }
    }

    // Was not enough, compact and try again.
    System.arraycopy(buffer, position, buffer, 0, remaining);
    total += position;
    position = 0;

    while (true) {
      count = fill(buffer, remaining, capacity - remaining);
      if (count == -1) {
        if (remaining >= required) break;
        throw new KryoException("Buffer underflow.");
      }
      remaining += count;
      if (remaining >= required) break; // Enough has been read.
    }

View Full Code Here

  private void readChunkSize () {
    try {
      InputStream inputStream = getInputStream();
      for (int offset = 0, result = 0; offset < 32; offset += 7) {
        int b = inputStream.read();
        if (b == -1) throw new KryoException("Buffer underflow.");
        result |= (b & 0x7F) << offset;
        if ((b & 0x80) == 0) {
          chunkSize = result;
          if (TRACE) trace("kryo", "Read chunk: " + chunkSize);
          return;
        }
      }
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
    throw new KryoException("Malformed integer.");
  }
View Full Code Here

    kryo.writeObject(cipherOutput, object, serializer);
    cipherOutput.flush();
    try {
      cipherStream.close();
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
  }
View Full Code Here

    try {
      Cipher cipher = Cipher.getInstance("Blowfish");
      cipher.init(mode, keySpec);
      return cipher;
    } catch (Exception ex) {
      throw new KryoException(ex);
    }
  }
View Full Code Here

                return readName(input);
        }

        if (classID == memoizedClassId) return memoizedClassIdValue;
        final Registration registration = idToRegistration.get(classID - 2);
        if (registration == null) throw new KryoException("Encountered unregistered class ID: " + (classID - 2));
        memoizedClassId = classID;
        memoizedClassIdValue = registration;
        return registration;
    }
View Full Code Here

            type = getTypeByName(className);
            if (type == null) {
                try {
                    type = Class.forName(className, false, kryo.getClassLoader());
                } catch (ClassNotFoundException ex) {
                    throw new KryoException("Unable to find class: " + className, ex);
                }
                if (nameToClass == null) nameToClass = new ObjectMap<>();
                nameToClass.put(className, type);
            }
            nameIdToClass.put(nameId, type);
View Full Code Here

    }
  }

  static public class EnumSetSerializer extends Serializer<EnumSet> {
    public void write (Kryo kryo, Output output, EnumSet object) {
      if (object.isEmpty()) throw new KryoException("An empty EnumSet cannot be serialized.");
      Serializer serializer = kryo.writeClass(output, object.iterator().next().getClass()).getSerializer();
      output.writeInt(object.size(), true);
      for (Object element : object)
        serializer.write(kryo, output, element);
    }
View Full Code Here

      super(fieldSerializer);
    }

    public Object getField (Object object) throws IllegalArgumentException, IllegalAccessException {
      if (accessIndex != -1) return ((FieldAccess)access).get(object, accessIndex);
      throw new KryoException("Unknown acess index");
    }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.KryoException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.